Installing your development environment

Dr Andres Baravalle

Installing your development environment

  • Installing Apache on Windows
  • Installing PHP on Windows

Installing Apache Windows

What will you need

Each week you will need:

  • Your textbook
  • Somewhere to make a backup of your data (pendrive, or similar)
  • a towel (ok that's not really needed)

Textbook and Documentation

PHP and MySQL developmentWeek by week you will have to perform a number of activities in class. To be able to engage effectively you must be familiar with your textbook and I do strongly suggest that you take your textbook in class every time.

If you get stuck at any point during this week's activity, please follow the documentation in your textbook. The documentation in the book is euxastive and covers Linux, Windows and Mac architectures.

The book will go through the installation of Apache 1.x; I do recommend that you install version 2.2 or 2.4 instead. Most of the steps in the installation are identical.

Installing your software stack

Your first step is to install the software that we are going to need to use PHP effectively - in this order:

  • Apache
  • PHP

This documentation will cover installing the software stack on Windows only. You can also use WAMP distributions instead - as XAMPP or WampServer and we will look at it later on in the second half of this module.

They are suitable as a development environment - but for production you should install the individual packages (ideally, on Linux or on another Unix-like system).

You need to be a superuser!

Before we start, keep in mind that you need to be able to install software in the system (be a "local administrator" or "elevated user" in Windows) to be able to proceed with the installation of Apache and PHP.

If you do not have the appropriate rights, you cannot proceed with the installation of Apache and PHP.

If you are in our lab, we will be doing this within a virtual machine.

Activity #1: Installing Apache on Windows

Download and install the latest stable version of Apache HTTPD available on the Apache Lounge web site. You should be able to follow the links and find the right version (64 bits vs 32 bits, depending on your operating system).

PHP is compiled using VC11, so we will need to use the VC11 version of Apache (as of 08/09/2015).

You can use the default settings - the task shouldn't take over 15 minutes.

Apache will be installed under your Programme Files or Programme Files (x86) folders.

After you have installed the web server, try to open your defaul home page at http://localhost/.

Please refer to Installing Apache Under Windows in your core text book if you run into troubles in the installation.

Activity #2: Configuring and managing Apache

The main web server configuration is located in conf/httpd.conf (we will need to modify this when installing PHP).

The log files (access_log and error_log) are located in the logs folder.

Open your error_log file and verify if any errors have been logged, and why.

Activity #3: Running Apache

You can stop the server to free resources and you must restart the server after any changes in the configuration. To start/stop/restart the server, you can use the Services administration tool or the command line (net start|stop apachexyz).

The Apache installation also installs a set of menu items to start/stop/restart the server.

For more details, follow the Microsoft documentation.

Installing PHP on Windows

Installing PHP - What VC version?

To use a recent version of PHP (PHP > 5.3), you will need a version of Apache compiled with Visual Studio 2012 - VC11.

Please refer to the Apache documentation.

Activity #4 : Installing PHP (1 of 2)

Download and install PHP the from the PHP web site. Download the thread safe version, and follow this documentation:

The version of VC used to compile PHP must match the one used for Apache (look for the string VC9, VC10 or VC11 in the PHP links). If you have installed an Apache compiled with VC11, you need to have a version of PHP compiled with VC11.

Activity #4 : Installing PHP (2 of 2)

Install PHP as an "Apache handler" and make sure that you change your httpd.conf file as per documentation.

Make sure that the DLL that you are loading matches both the version of Apache that you are using (e.g. 2.2) and the type of installation ("Apache handler"). For Apache 2.4 and PHP5, the files is php5apache2_4.dll. For Apache 2.2 and PHP5, the file is php5apache2_2.dll.

Installing PHP on Windows can be troublesome and can take anything between 10 minutes and several hours.

Configuring PHP

The main PHP configuration is located in php.ini. You will not need to modify the file now, but you may need to modify it for advanced usage of PHP, in the second part of this course.

Web server and command line

You can run PHP scripts:

  • Through a web server (e.g. http://localhost/test.php)
  • From the command line (e.g. php test.php)

Web server and command line (2)

You can use PHP both to write command line scripts and web pages/applications.

You should test and debug command line scripts in the proper environment; occasionally it might be convenient to debug web pages from the command line (e.g. to increase the level of verbosity without changing PHP settings).

Activity #5: Testing the PHP installation

Create a text file in your Apache root folder (htdocs) with your notepad and call it test.php.

Include this code:


Restart Apache and open http://localhost/test.php.

Activity #6: Running from the command line

You can run PHP scripts from the command line.

Open a command prompt and change to your Apache htdocs folder.


 c:\Program Files\php\php.exe test.php

Update paths as needed to reflect the local folder structure.

Installing Apache and PHP at home

Remember: we are going to use Open Source software only; Apache and PHP are available for Windows, Mac and Linux.

You can download and use the software at home.

If you use a Mac, you can use this guide as a starting point.

If you are using RHEL, Fedora or Centos Linux, just run:

yum install httpd php

If you are using Debian or Ubuntu Linux, just run:

sudo apt-get install lamp-server

If you have had any problems...

Seek help! You need to complete all the previous steps before moving forward.

If you can't use Apache

If, for any reason, the Apache + PHP combination doesn't work, you can still test you PHP page using the built-in web server included in PHP since version 5.4.

Copy your test.php file in the PHP folder.

Open a terminal in the PHP folder and run:

php.exe -S localhost:8000

Then open your browser at the address http://localhost:8000/test.php

Have you finished?

Share your experience on twitter #uel #cn5109

This work

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License

Creative Commons License