- Follow my instructions on installing Apache on Windows Vista
- And then follow my instructions on installing PHP on Windows Vista
Installing PHP with Apache on Windows Vista is a relatively simple task until you try an configure the settings in php.ini. Problems can occur and stem from the fact that when you install PHP and edit the php.ini file, you need to not only be logged in as Administrator, but run the installer and Notepad text editor as Administrator. The php.ini file also needs to be located in the Windows directory.
Below is an outline of the steps to get your PHP installation running and configured correctly.
- Run Notepad as Administrator. Go to All Programs > Accessories Right-click “Notepad” and select “Run as Administrator”. Open the php.ini file, in my case:
- Edit the php.ini file as necessary, e.g.:
extension_dir = "C:\PHP5\ext" upload_max_filesize = 16M upload_tmp_dir = "C:\PHP5\upload" session.save_path = "C:\PHP5\session"
- Enable the extensions you need by deleting the semi-colon at the beginning of the line. For example, you will commonly need the following MySQL extensions:
extension = php_mysql.dll extension = php_mysqli.dll
- Save the edited php.ini file into your Windows directory. This is very important as Vista will not read the changes but will refer to the default settings.
- Check that the PHP directory has been added to your computers “Environment Variables”. Click Start, right-click on Computer, select Properties > Advanced > Environment Variables. Click on PATH and select Edit. If the PHP path is there, in my case “C:\PHP5\”, all is well, otherwise add the PHP path.
- System Properties:
- Environmental Variables
- Edit Environmental Variable – PATH
- System Properties:
- Open your Apache configuration file (httpd.conf). Ensure the following lines are present (at the bottom of the file):
LoadModule php5_module "C:\PHP5\php5apache2_2.dll" AddType application/x-httpd-php .php AcceptPathInfo on PHPIniDir "C:\Windows"
If there are additional
LoadModulelines, remove them, leaving only the one that relates to your version of Apache.
- Find the DirectoryIndex in the Apache config and append
<ifmodule dir_module> DirectoryIndex index.html index.php </ifmodule>
- Restart the Apache service.
- Create a index.php file in your webroot and add the following lines:
<?php phpinfo(); ?>
- Navigate to the file (e.g. http://localhost/index.php) and you will be presented with all the PHP and server settings. You’re now good to go.