Installing PHP & Apache on Vista
Everybody, who tried it, knows – installing PHP5 & Apache2.2 on Vista might be a little bit tricky (on Linux it might take a lot less time sometimes). Let’s assume we have Administrator access and latest versions of Apache. In my case it’s apache_2.2.10-win32-x86-no_ssl.msi & php-5.2.6-Win32.zip (note: I am not using .msi or anything similar for PHP).
Step 1: Apache install usually works perfectly and after it’s job is finished we have working Apache service, which we can test using simple url: http://localhost
Step 2: Unzipping PHP into directory of our choice – in my case it’s “C:/net/php5” and coping file called “c:\net\php5\php.ini-recommended” into “c:\net\php5\php.ini”
Step 3: Adding extra lines into httpd.conf file in order to get PHP working. Lines are really very simple:
LoadFile "c:/net/php5/php5ts.dll"
LoadModule php5_module "c:/net/php5/php5apache2_2.dll"
<Files "*.php">
AddHandler application/x-httpd-php .php
</Files>
PHPIniDir "c:/net/php5/php.ini"
Now all the magic starts and all kinds of problems appears from nowhere 😉
Gotcha 1: httpd.conf file must be edited with Administrator access – otherwise… nothing will be saved and nothing will happen. Unlike in Win2K or WinXP where file permissions are not that restrictive.
Step 4: Changing few directives in httpd.conf so Document Root will be in your favourite directory “C:/!www” for example and not in “C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\” (easy to access, isn’t it?)
Following lines have to be changed or added:
#changed
DocumentRoot "C:/!www"
#added or changed from default htdocs folder
<Directory "C:/!www">
Options Indexes FollowSymLinks
AllowOverride None
# Order deny,allow
Order allow,deny
# Deny from all
# Allow from all
Allow from 127.0.0.1
</Directory>
#changed
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
Step 5: Now we restart Apache and pray that anything is working 🙂
Step 6:How we test if anything is ok? We create file called “c:\!www\index.php” with the following content:
<?php
phpinfo();
?>
Gotcha 2: Note <?php in the start of the code? That’s because short tags are not supported by default by PHP anymore 😉
After file is created we open or beloved url: http://localhost and checking page. We should see something like that:
Gotcha 3: You might get error 403 and page will not be displayed. OK. Now check Apache error log file “” and you might see there something similar to that:
[error] [client 127.0.0.1] client denied by server configuration
Why?: Directory you trying to access in Apache Config file has bad properties.
Solution: Properties have to be changed.
<Directory "C:/!www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow, deny
Allow from all
#Allow from 127.0.0.1 - it will only give access from one specific IP
</Directory>
Now… the most interesting step – changing php.ini config in order to get some REALLY usefull extentions working.
Step 7: Changing php.ini – very important part. Here we can switch on/off some useful extensions.
OK, now the changes we gonna make:
;# do we want to use <? instead of <?php - if so - use "On" directive
short_open_tag = On
;# Two useful things to have
display_errors = On
display_startup_errors = On
;#Not sure if it's changes anything in our default installation, but what the heck?
doc_root = "c:\!www"
;# VERY IMPORTANT - this line says PHP where to find extensions
extension_dir = "c:/net/php5/ext/"
;#actual extensions ON/OFF
extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
extension=php_exif.dll
;extension=php_fdf.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_msql.dll
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
php.ini file contains so many features, but in order to get PHP working it’s enough.
Now – the most interesting part – we restart Apache and cannot see some of the extentions we need…
Gotcha 4: Apache error log contains something like that:
PHP Warning: PHP Startup: Unable to load dynamic library ‘c:/net/php5/ext/php_curl.dll’ – The specified module could not be found.\r\n in Unknown on line 0
or
<b>Warning</b>: PHP Startup: Unable to load dynamic library ‘c:/net/php5/ext/php_mysqli.dll’ – The specified module could not be found.
or
PHP Warning: PHP Startup: Unable to load dynamic library ‘c:/net/php5/ext/php_mysqli.dll’ – The specified module could not be found.\r\n in Unknown on line 0
or
PHP Warning: PHP Startup: Unable to load dynamic library ‘c:/net/php5/ext/php_curl.dll’ – The specified module could not be found.\r\n in Unknown on line 0
Now you check your “c:/net/php5/ext/” directory and all files are in there – WTF?!?, you think. Well – here is the trick. In fact your libraries are there but… PHP need something else to run properly:
In “c:\net\php5\” there are few .dll files – some of the php_* libraries need to run.
fdftk.dll
gds32.dll
libeay32.dll – needed by php_curl
libmcrypt.dll
libmhash.dll
libmysql.dll – needed by php_mysql and php_mysqli
msql.dll – needed by msql
ntwdblib.dll
ssleay32.dll – needed by php_curl
Best and easiest way is to just copy all that files into your “c:/windows/system32/” directory. Or add php5 directory into your system %PATH%.
(Added later – this is how to change %PATH% variable if you are not happy with coping files into system32):
Type “cmd” – then echo %PATH% – copy/paste into editor, add c:\net\php5\ and c:\net\php5\ext\ in there and run set PATH=your_value_after_editing
This is my sample:
set PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Roxio Shared\DLLShared\;c:\net\php5\;c:\net\php5\ext
And it’s not all – if you need php_exif.dll (Gotcha 5) – the specified module requires that php_mbstring.dll be loaded!
That’s it for the moment. This is how I was able to get PHP5 and Apache2.2 working together with all needed extentions on Vista.
In: English, Fighting the system · Tagged with: apache2.2, curl, mysql, mysqli, php5, problems, solutions, vista
on January 8, 2009 at 19:26