Installing AMP (Apache, MySQL and PHP) have become quite easier with single wizard based installations available as a packet these days. Like using XAMPP, WAMP you can just install them and use. But with these setups, you will have (or will not have) less knowledge about configuring them each in your own way because they will present some user interface where you can directly do configurations by one click. You will not know what exactly required for changing something in Apache, PHP or MySQL. So to have knowledge on configurations on them according to your requirement, you have to install each applications individually. I always recommend to do that and configure them for your purpose.
The installation and configurations of PHP, Apache and MySQL in Windows has also become quite easier these days because they provide some default configurations. As PHP, after its latest releases i.e.5.4, does not provide the downloads of VC6 version (the PHP compiled with Visual C++ 2006 compiler) these days because it is believed that the performance of the PHP compiled with VC9 (compiled with Visual C++ 2008 or later) has improved quite a lot than the compiled with VC6. So to work with the latest VC9 version of PHP, you must have installed PHP with VC9 compiled Apache as well or you use IIS as web server. VC9 compiled Apache is provided by Apache Lounge (apachelounge.com) not the original Apache (apache.org). Since I haven’t worked yet with IIS and always work with Apache in anyway, I don’t have knowledge about the IIS & PHP. Here I am going to explain few steps on how to install PHP 5.4 and Apache 2.4 in Windows.
Requirement
To run the applications compiled with VC8 or VC10, it is required to install the respective (or latest one is always better) Visual C++ redistributable packages. You can download the package from Microsoft’s official site for free.
- To download Visual C++ 2008 – http://www.microsoft.com/download/en/details.aspx?id=5582
- To download Visual C++ 2010 – http://www.microsoft.com/download/en/details.aspx?id=8328
Note: If you have any Visual Studio installed in your PC then you don’t have to install them separately.
Where to install?
Since I have not used any installers for both PHP and Apache, I will be downloading the pre compiled zipped packages and install them in my D drive. The folder structure will look like below:
- d:/etc/apache – Apache installation
- d:/etc/php – PHP installation
- d:/etc/mysql – MySQL installation
- d:/etc/mysql/databases – MySQL data folder
- d:/etc/www – document root folder
Note: You can change the drive and path for the installations in your own way.
Download
- Download the latest Apache 2.4.1 (as of writing this) from http://www.apachelounge.com/download/ (direct link for the current version – http://www.apachelounge.com/download/win32/bins/httpd-2.4.1-win32.zip) and unzip it in d:/etc/apache
- Download latest version 5.4 from http://windows.php.net/download and unzip it in d:/etc/php. While downloading PHP, choose the Thread Safe version for windows.
- Download the PHP and Apache connector DLL file from http://www.apachelounge.com/download/ (direct link: http://www.apachelounge.com/download/win32/mods-2.4/php5apache2_4.dll-php-5.4-win32.zip) and extract the file php5apache2_4.dll and copy it to d:/etc/php.
Configurations
Though the configurations may vary from individual’s requirement but here I will be discussing for some basic configurations in PHP and Apache.
Apache
- Open the file d:/etc/apache/conf/httpd.conf in any text editor (I use my lovely Notepad++) then find and make the following changes/configurations as per your installation path.
- Set the server root
ServerRoot "D:/etc/apache"
- Enable required Apache modules. I just uncomment one more for mod_rewrite module.
- Add the following lines somewhere (I did just below the module enabling)
LoadModule php5_module "d:/etc/php/php5apache2_4.dll" AddHandler application/x-httpd-php .php PHPIniDir "d:/etc/php"
- Change server admin email address
ServerAdmin info@yoursite.com
- Change the document root:
DocumentRoot "d:/etc/www" <Directory "d:/etc/www">
- If you want to allow .htaccess to be used under document root do the following under <Directory “d:/etc/www”>
AllowOverride All
- Find the follwoing and replace the path:
ScriptAlias /cgi-bin/ "d:/etc/apache/cgi-bin/" <Directory "d:/etc/apache/cgi-bin">
- Add index.php in directory index
DirectoryIndex index.html index.php
PHP
- Rename php.ini-development to php.ini
- Find extension directory setting and set the path as per your installation.
extension_dir = "d:\etc\php\ext"
- Uncomment (remove the simicolon ; from the beginning of the line) the extensions that you want to enable them. i.e.
extension=php_curl.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll extension=php_soap.dll
- If you want to test email sending from the PHP in local system, then you need to set the SMTP. i.e.
SMTP = smtp.yoursite.com smtp_port = 25 sendmail_from = youremail@sender.com
Rest of the changes/configurations are totally depends on requirement project wise.
Set Environment Variables for PHP (Windows 7)
To be available PHP globally in Windows, the path of the PHP has to be set.
- Right click on Computer and click Properties
- Click on Advanced system settings on the left side (top).
- Click on the Environment variables
- Under System variables, double click the Path variable name and add ;d:\etc\php without double quotes at the end where semicolon (;) is the separator.
- Click OK to save. Sometimes you may need to restart the computer this to take it into effect.
Install Apache as Service
Since we have just copied the files in a folder, the Apache is not yet not a windows service. To install it as a service follow the steps.
- Run the command line (cmd.exe) As Administrator. Browse the folder c:\Windows\System32\ and right click on cmd.exe and select Run as Administrator.
- Change directory to d:\etc\apache\binin the command line
cd d:\etc\apache\bin
- Run the command to install it
httpd -k install (or sometimes httpd.exe -k install if that does not work)
Now restart the computer and test both PHP and Apache. To test both together create a PHP file phpinfo.php in d:\etc\www. Now browse in the browser as http://localhost/phpinfo.php.
If you can see the PHP information then now you are done !
52 Comments to “Installing PHP 5.4 with Apache 2.4 in 32 bit of Windows !”
Post comment
About Me
I am an Opensource Developer. Currently I am working in a company as a Solution Architect. I have around 7 years of Web development experience in Advanced and Core PHP Programming and MySQL and PgSQL database as back end. It has been long time that I have nott been involved with RoR, Perl and ASP, Visual Basic but I had also worked with them. Specialties: PHP, Zend, YII, CodeIgniter, Joomla, Magento, JavaScript, MySQL, PgSQL, HTML, CSS, RoR, Perl, ASP!
Categories
- About Me (2)
- Apache (1)
- Facebook (1)
- JavaScript (6)
- Joomla (10)
- jQuery (5)
- Magento (10)
- MySQL (2)
- Opensource (2)
- PHP (18)
- phpmyadmin (2)
- Programming (19)
- Ubuntu (2)
- Zend Framework (1)
- कच्याक कुचुक (1)



Jhonatan says:
tks for you help. it’s works now.
Steffen says:
Hi,
Great article! Simple as it can be.
Apache 2.4.2 is now available at Apache Lounge, VC9 and VC10.
Typo in your title “Insatlling PHP…” must be Installing.
Steffen
rajug says:
Hi Steffen,
Thanks for pointing out the typo.
Regards
Raju Gautam
Ryan O'Hara says:
Thanks, this was an absolute lifesaver. That’s the first time I’ve ever had PHP and Apache work *the first time* I tried it!
Avaq says:
Nice guide! It helped me a lot installing these services for the first time. (Before, I used to use WAMP, but it started causing problems with php 5.4.)
What is a shame though is that this guide is not an entire substitute for “AMP”, because there are no steps for installing MySQL in this guide. I was expecting these because you wrote about MySQL in the first paragraphs.
Also you might want to fix the blatant typo in the title. It made me instantly doubt the quality of this guide when I entered the page through Google. (The typo is also in the URL even :\ )
rajug says:
Hi Avaq,
Thank you so much for pointing out the typo.
And about MySQL installation, I did not promise to provide it neither the post was all about that. I was only concerning about the PHP 5.4 with Apache 2.4 which has little different steps to install in Windows systems. There are nothing such complications with installing MySQL in windows. You download the MSI installer and go through the wizard will be enough.
Thanking you once again.
Regards,
Raju Gautam
Su8z3r0 says:
I am sorry to say this site do not provide the date of the posts, so I can not appreciate how old is it, but anyway I have to say that for me is the same fake. I succeeded to reach the point to install Apache24 as service, but when I tried to start apache I’ve got the same “httpd: Syntax error on line 110 of B:/server/Apache24/conf/httpd.conf: Cannot load B:/server/php/php5apache2_4.dll into server: The specified module could not be found”
Before that I installed:
- mysql-5.5.22-win_x64
- httpd-2.4.2-win32
- php-5.4.0-nts-Win32-VC9-x86
- php5apache2_4.dll-php-5.4-win32
and also I’ve uninstalled the Microsoft Visual C++ redistributable – x64 9.. and ~ 10.. (vcredist_x86_2010-SP1) and nothing changed, I get the same result.
I’m working on a windows 7 x64. I plan to go back on linux, it’s more simplier, than so many windows .dll’s about you never know if its working or not ..
rajug says:
Hi Su8z3r0,
Thanks for landing in my block.
First of all, I think you did not read the blog very closely. There is the date just below the title of the blog posted on 28th March. So it is not that much older one.
And about the problem that you are pointing about Apache not working, I suspect that is because you have Windows 7 64 bit. I did not find the DLL for 64 bit of Windows 7 and did not try myself with it. The process, steps mentioned here are for the 32 bit of Windows operating system.
Thanking you.
Regards
Raju Gautam
aud says:
Hi, I followed your instruction and have same issue. I also use windows 7 32 bit. So why it happened ? Thanks.
mridul_sust says:
You are using non thread safe version of php.Use thread safe version to avoid this error.The dll works with TS version.
Santosh Moktan says:
Technically error free article for setting up environment in windows machine.
It rocks.
Vedant says:
Notice: Undefined index: np_user in E:\Webserver\Apache2\htdocs\vsocial\index.php on line 3
Notice: Undefined index: token in E:\Webserver\Apache2\htdocs\vsocial\index.php on line 14
Notice: Undefined index: user in E:\Webserver\Apache2\htdocs\vsocial\index.php on line 15
Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in E:\Webserver\Apache2\htdocs\vsocial\index.php on line 22
Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone. in E:\Webserver\Apache2\htdocs\vsocial\index.php on line 23
Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone ‘UTC’ for now, but please set date.timezone to select your timezone.
I am getting These Errors please tell me how to disable these warnings
rajug says:
First recommended way for avoiding these notices and warnings would be to check the code itself and fix them. Otherwise see error_reporting configurations http://php.net/manual/en/function.error-reporting.php. For date issue, please check the respective pages in php.net manual and try to configure accordingly.
Naresh says:
I was able to install and configure Apache in one shot.
Very nice article bro!.
Jaise says:
Thank you!!! I was able to connect PHP with Apache server.
jax says:
Are you ok??
php5apache2_4.dll in php5.4????
Where is it?
Morosov Dmitry says:
Thank you. It works now.
RANJITH says:
thank u very much…. i got the result
Kofiko says:
Thanks bro, clear and easy article.
How should I config Apache2.2? | Jisku.com - Developers Network says:
[...] should I config Apache2.2? I tried to config Apache2.2.17 with PHP5.4 by this manual. But when I restarted my PC and went to http://localhost/phpinfo.php, I received this [...]
VDS says:
Hi,
I am trying to install php apache mysql onmy laptop.
First I installed APACHE and then PHP then I try to setup environment variables and path with some modification of files like httpd.cong and php.ini.
After doing the above configuration, when I restart the Apache for taking effect the above changes does not work. All services stopped and error comes infront of me.
Please guide me for successful installation of all important parts of web development using php,apache,ysql.
Regards:
VIKAS DEEP SINGH
M. +91-8884875421
Brad says:
Thanks! What a great tutorial!
Harshal says:
Thanx Raju… This is one straightforward guide for installing Apache and PHP with absolutely no hassles…recommended for freshers !
Harry says:
Finished installing and configuring everything on 64 bits windows. After fucking around for a few hours i have to read in the comments that 64 bits is not supported. Jeez.
rajug says:
Did you read the title of the post where its been written clearly that it is for 32 bit of windows ?
Hector says:
Thank you, very useful. The best tutorial I could find on the web.
paolo says:
Hi to all be very careful to choose what version of apache and php to use here is the compatible one for Apache try to use this httpd-2.4.3-win32 and for PHP try this php-5.4.8-Win32-VC9-x86 you will save lots of hours to configure the apache about the php5apache2_4.dll
Chris says:
Good article. Very useful . I followed the steps as is and the installation was successful.
Thanks ,
Aim-Utlimate site
Ehsan says:
Thanks a lot, very useful, clear and easy
keep up the good work.
sourav mukherjee says:
Hello Raju,
Thanks for your article.
I have followed your article and installed Apache2.4 and PHP 5.4.10 in my PC.
After installing i can run a php file from the command line with the PHP command.
Example:- php .php gives me the desired output.
But i cannot accress the server from the browser.
In httpd.conf i changed the port number to listen to 8080 instead of 80.
Now when i run http://localhost:8080/ or http://127.0.0.1:8080/ in the browser i get the following error message.
————————-
403 Forbidden
Forbidden
You don’t have permission to access /
on this server.
————————-
If you can provide any help it will be very helpful.
Sincerely,
Sourav Mukherjee
Kranti says:
Hi, It worked for me in the first shot itself. Thank You very much…
Bijosh says:
Hai Raju.
Thank you very much for this simple and finest article on the topic.
ramc says:
sir,
the following text coming and the cmd hangs when executing httpd.exe at command prompt.
AH00558: httpd.exe: Could not reliably determine the server’s fully qualified do
main name, using 192.168.1.100. Set the ‘ServerName’ directive globally to suppr
ess this message
ramc says:
Thanks very much.. it works
chris says:
Hi, what about the mysql part?
thank you.
rajug says:
Installing MySQL is quite easier, just download the installer file and simply install it like other programs with wizard based instructions !
OsobaC says:
Great article! Thank you a lot!
paul clarke says:
Excellent .. many many thanks. Have been battling all day with Apache PHP on windows 8. Your article made complete sense and it all worked first time. Much appreciated.
Abdul Anoop says:
Dear Mr. Rajug,
Thank You so much for the perfect guidance… I am an absolute beginner to Apache/PHP… I completely messed one day in installing/configuring. But today, from you post, it hardly took minutes to go with…..
First time i am appreciating a techie for his genius work….
Have a nice time Bro….
Take care.
Thanks Again.
Abdul Anoop
Saudi Arabia.
Marco Arcieri says:
Hi!
Try this guide here to install Apache 2.4.3! I tested and it works perfectly:
http://www.mamertum.it/installare-apache-2-4-http-server-su-windows/
dougie86 says:
after following the outlined installation process, mine is not loading the mysql and mysqli extensions
Steve S. says:
Raju,
Excellent! You rock. This saved me countless hours of headaches. Thank you!
Here are a few additional tips and updates:
Tips:
1. Obviously you should follow the directions step by step. I accidentally skipped a step and it cost me 30 minutes, be methodical.
2. I had previous version of both Apache and PHP installed, I left both intact and installed each in a new directory.
3. I find it will help you in the future if you place your initials next to any modifications you make to httpd.conf and php.ini.
4. When unzipping Apache, do not read the install notes (install.txt). I got off on a tangent and tried to figure out how to compile the binaries, only to find that Raju shows you how to do this in his last step.
Updates:
1. Apache 2.4.4 is the latest version as of March 1st, 2013 and it will require Visual C++ 2010, so do not bother with the 2008 version.
2. It took me a while to find the modules-2.4/php5apache2_4.dll-php-5.4-win32.zip file.
On the http://www.apachelounge.com website there is an “Additional” menu option in the upper left corner. Go to the “Additional” page and look under “VC9 Binaries”.
For version 2.4.4, here is the link: http://www.apachelounge.com/download/win32/modules-2.4/php5apache2_4.dll-php-5.4-win32.zip
Thanks again Raju!
Vaibhav says:
Hi Raju,
Nice article for the newbie.
I followed all the steps mentioned in the article but facing following issue,
httpd: Syntax error on line 527 of C:/Server/Apache24/conf/httpd.conf: Cannot lo ad c:/Server/php/php5apache2_4.dll into server: The specified module could not b e found.
Apache used : httpd-2.4.4-win32.zip
PHP used : php-5.4.12-nts-Win32-VC9-x86.zip
Dll used : PHP 5.4.9
My machine is Windows 7 64 bit.
Could you please help me to solve this problem.
Thanks in advance.
Ram says:
on windows7, while installing apache using command
“httpd.exe -k install”
i got an error message as
“httpd.exe: Syntax error on line 150 of I:/AMP/apache/Apache24/conf/httpd.conf: Cannot load I:/AMP/php/php5apache2_4.dll into server: The specified module could not be found.”
rajug says:
May be you did not download the correct version of DLL. Please note the steps/instructions given here are for the Windows 32 bit and you have to download everything that are compatible with 32 bit.
hcuser says:
can’t seem to be able to enable vhost on apache2.4.3, anyone know how?
Installing Apache mySql and php on Windows says:
[...] http://www.devraju.com/php/installing-php-5-4-with-apache-2-4-in-32-bit-of-windows/ [...]
samuel says:
it worked flawlessly, thanks
Suresh says:
Hello Devraju,
Excellent work. one silly spelling mistake and another wrong code, finally DONE IT.
3rd major achievement since last Wednesday; Installing successfully Ubuntu 12.10 and my TA software in Ubuntu 12.10 and now Apache, PHP in my Windows. Still long way to go.
If you can provide some guidance on installing mysql it will be great, if it is already there I will check.
Frankly, I don’t know anything about programming but not averse to learning at this age.
Thanks
Suresh
Bilal says:
Thanks very nice and concise article, thanks alot again.
if users have serverName error then just add the serverName in the httpd.conf file
Bilal says:
Thanks very nice and concise tutorial, servername error may occur and can be corrected by just adding servername in httpd.conf file
Lyle says:
Thanks greatly for sharing this information. I’m a novice at this and I went to this page http://www.apachelounge.com/download/ and found a zip for httpd-2.4.4-win32.zip and downloaded and extracted. I was hoping to find an msi package for 2.4.4 since I don’t want to compile anything. So I’m not sure what to do with the extracted files. I’ve installed MySql 5.6 and want install latest PHP also. So I’d much appreciate recommendations on installing this 2.4.4 version of Apache. The Apache download site only has msi for 2.2.22 which is dated 1-30-2012. I’m also not sure about whether to use SSL. I’m installing on win XP sp 3 on an older Dell laptop.
Much appreciate any thoughts.
Best,
Lyle