Aug 18, 2015
How to Install PHP on Windows Hopefully, you now have a working local installation of Apache on your Windows PC. In this article we will install PHP 5 as an Apache 2.2 module. Install and Configure MySQL for PHP Applications on IIS 7.; 5 minutes to read Contributors. In this article. By Ruslan Yakushev. While Microsoft® SQL Server® 2008 is the recommended database to use when hosting PHP applications on an Internet Information Services 7 (IIS 7) and above Web server, you can also use MySQL as the database.
How install Apache 2.4 PHP 5.6 and MySQL 5.6.26 on Windows 10
Windows 10 has been released on the world and so an updated how to guide for installing Apache, PHP and MySQL on the latest release. In this post like previous we will cover installing all the programs individually. This will cover installing 64 bit versions of the programs.
Apache 2.4 Install
First download Apache 2.4 from http://www.apachelounge.com/download/ (httpd-2.4.16-win32.zip) Apache 2.4.16 VC11
This release is supported by the PHP 5.6 install from windows.php.net for Apache 2.4.
This release is supported by the PHP 5.6 install from windows.php.net for Apache 2.4.
Extract the zip and copy it to the root of C:. This will be C:Apache24 when it is all done.
Microsoft Visual C++ 2012 Runtime
Download and install Microsoft Visual C++ VS 2012 x86 from https://support.microsoft.com/en-us/kb/2977003 this is required for Apache to run.
PHP 5.6.12 and higher
Download php-5.6.12-Win32-VC11-x86 from http://windows.php.net/download/ . Extract and rename folder to php and move to C:.
Edit Apache’s config file, c:Apache24confhttpd.conf and add the following lines to the bottom of the file.
2 4 | AddHandler application/x-httpd-php.php PHPIniDir'C:/php' |
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
2 4 6 8 | ;Directory inwhich the loadable extensions(modules)reside. ;extension_dir='./' extension_dir='ext' Uncomment mysql modules extension=php_mysqli.dll |
Save the changes and open a command prompt. Check to make sure it shows loaded modules.
Php Windows Download
So now we have Apache running and configured to use php. Lets create a file called info.php, save it and see if Apache parses the info correctly to display the results.
Install Mysql Module Php Windows Installer 2012
Open Notepad or your favorite Windows editor and type and save the following.
2 | phpinfo(); |
Open your browser and type, localhost/info.php for the location and you should receive alot of information about PHP.
MySQL
Download and install mysql-installer-community-5.6.26.0.msi. Change installation directory to C:MySQLMySQL Server 5.6 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root.
Download and install mysql-installer-community-5.6.26.0.msi. Change installation directory to C:MySQLMySQL Server 5.6 instead of Program files as there could be permissions issues. Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root.
At this point you should have a working Apache / PHP / MySQL installation running and ready for you to use!
Related Posts
- it says php not recognised as any internal or external command, operable program or batch file.
- Did you ever find a solution? I am experiencing the same error.
- Check your work. I followed his instructions after days of trying to follow other’s, and finally got it to work. Never had a problem with Apache 2.2 on Windows XP (or even Windows 10), but installing Apache 2.4 is different for some reason. Go figure. But it’s now working!
- Nice article, thanks, it worked for me. I’ve used php 7, apache 2.4 vc14 and Microsoft visual C++ 2015 update 1. I enjoy a clean installation, no need of WAMP, LAMP…
- Kindly Share the versions you have installed…Which version of php 7 preferably share the link to download
- Hi,
Thanks for these instructions, I am very new to anything to do with php or Mysql. I am trying to buid a database on my own computer (not for publishing on the web) and I am assuming I still need to install everything as per instructions. I managed to get apache up and running but get an error message when testing php.the error message is
c:> php -m
php is not recognized as an internal or external command, operable program or batch file.Can you give any advice on what might be causing the problem please? I think it might be to do with your instruction about editting the php.ini file. I found the code;Directory in which the loadable extension (modules) reside ….And inserted the codeUncomment mysql modules ….immediately afterextension_dir =”ext”But I am not sure if this is where it was meant to be inserted (the only bit of instruction I couldn’t follow).Any help would be greatly appreciated,Many thanks,
Rob - I have followed all the steps but in the end in “localhost/info.php” the page cant be found. my info.php y saved in httdocs
- I had the same error. How did you fix this error?Thanks
- I had this problem too. One more reboot fixed the problem for me
- I need some help with two things,
First what do I do with this part exactly? “Next we need to input a value for ServerName variable.” Do I change this line to something or simply leave it uncommented?ServerName http://www.example.com:80Also the part with the envrionment variables I do not think I am doing right.I can add:C:php
C:apache24
C:apache24binall separately in Path for Environment Variables but I cannot add;c:php;c:apache24;c:apache24bin;”How am I supposed to correctly edit the variables?- Actually I believe I did the environment variable part right but still don’t know what to do for servername.Also when I type c:Apache24binhttpd -S into the command prompt it says“httpd: Syntax error on line 72 of C:/Apache24/conf/httpd.conf: Cannot load modules/mod_access_compat.so into server: The specified module could not be found.”And whether I comment line 72 or not it will say that.
- Hi,Everything seems to be going great but when I installed apache and tested it, I get an error with the php setting in the config file that we added. Cannot Load C:/php/php5apache2_4.dll into server: %1 is not a valid Win32 application.I followed all the steps, what can be amiss? Thanks!
- Same problem here. The error is reported right during the installation of the Apache server “errors reported here ust be corrected before the service can be started. httpd: Syntax error on line 525 of C:/Apache24/conf/httpd.conf Cannot load c:/php/php5apache2_4.dll into server: %1 nx92 is not a valid Win32 application”Also followed all the steps and encounter this problem when installing the Apache server under Windows 10.
- And there I fixed it…If anyone get this error, it means that the installed versions of Apache and PHP are not the same (e.g. Apache 64bit and PHP 32bit).To fix the problem, I had to install the 64bit version of PHP (not the 86x version stated in the instructions), which means basically just downloading the right version, extract all files and replace the existing php folder with the folder containing the extracted files, renamed as “php”.Now everything works. Thanks for this great post!
- Simple and nice instructions. anyone having a little knowledge about technicality of computer can understand this. Worked for me! Thanks.
- Is this compatible to Window 7? Thank you.
- I had configured following your steps but when i try to start apache an pop up says : The request operation has failed!i don’t know what to do ;s
i have win 10 pro x64- I’m stuck at the same place. I’ve commented out those added lines in httpd.conf and the Apache server starts. The php server works fine. But when those lines are added back in and the Apache server restarted, it doesn’t start up.Any ideas, newlife007?
- You can entirely eliminate the need to manually configure Apache for PHP if you are using a managed hosting platform, like Cloudways (https://www.cloudways.com/en/php-cloud-hosting.php ). Their platform already has Apache, MySQL, Nginx, Memcached and Varnish configured.
- I am having the exact same problem that Miguel reported on March 22. when I type localhost/info.php my browser says “cannot reach this page. I didn’t see a reply with an answer to his problem which will probably solve mine too. My Apache server seems to startup and run properly because there were no errors reported. My path has been changed per the instructions and info.php was saved into the c:apache24htdocs directory.
- Not seen this mentioned, but have used this before, very easy to install and configure Apache and MySql with PHP install
- Was hoping to find steps for setting up LAMP in bash on the new WSL. Particularly how to actually hit the server once it’s running. Maybe a future how-to?Unrelated: how many geeks do you administer? ?
- I had the same problem, however I download php from http://windows.php.net/downloads/releases/php-7.0.12-nts-Win32-VC14-x86.zip and it works
- . And for php 5. I had downloaded php from http://windows.php.net/downloads/releases/php-5.6.27-nts-Win32-VC11-x86.zip and it works too.Best regards
- My Error to localhost/info.php:Installed Apache 2.4.23 webserver on windows 10.
64 bit AMD machine.
it was successful.Then installed PHP 7.1.13 Win32 VC14 x64from the above steps
everything worked tillphp -mERROR:
when tried to run
localhost/info.phpgot an HTTP ERROR 404SOLUTION (in my case):
As I have Skype and it uses port *80I set the PORT in APACHE config file to *8888Hence to access the info.php in browser typelocalhost:8888/info.php
localhost:/info.php - If you copy and paste changes to the httpd.conf from the screen
(LoadModule php5_module “c:/phpphp5apache2_4.dll”
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir “C:/php”)
, compare the existing quotes used in httpd.conf to what you pasted in. There is a difference between fancy quotes and regular quotes. Apache wont run if there are fancy quotes in the httpd.conf file. - i have followed the whole mentioned steps the same, and there is no error, but still localhost page can not be found through the browser.
- Hi Save your info.php file in to C:Apache24htdocs
- Just wanted to say thanks!
Everything worked perfectly – you the man! - Just thought i would add some thing to this nice tutorial……Some time in win 7 and win 10 in the Apache httpd you need to make this path the full. extension_dir = “ext” change to “C:php/ext” or in my case extension_dir = “C:php7/ext”Hope this helps a few
- exscuse me i ment in the PHP.ini my bad
- Thanks for this article, working perfectly.Thanks
- Apparently several others have had the same problem. I have installed Apache24, PHP7 and MySQL (64-bit versions) in Windows 10 exactly per the instructions provided.When DocumentRoot in httpd.conf is configured as C:apache24htdocs” info.php shows up perfectly. When DocumentRoot in httpd.conf is changed to another directory where all the website files exist, only the html files show up (for example, index.html for the website). However, info.php produces a blank screen. There is no error message, only a blank screen. (Note: Yes, I have a copy of the info.php file in DocumentRoot directory.)Have spent “hours” on this. Any help will be appreciated. Thanks.
- Have downloaded httpd-2.4.27-Win64-VC15 and php-7.1.9=nts-Win32-VC14-x64.
following your instructions
edit apache conf file with
LoadModule php5_module “c:/php/php5apache2_4.dll”
or
LoadModule php7_module “c:/php/php7apache2_4.dll”AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir “C:/php”
There is no file named php5apache2_4.dll in php5 download or php7apache2_4.dll in php7 downloadApache says cant locate module. - Hi,I’m almost done with this setup. Thank you for this article with detailed steps.I’ve installed Apache 2.4 server, PHP 5.6 and MySQL 5.5I’m able to run the index.html file as localhost/index.html
I’m also able to run the PHP program through command prompt successfully.
But, when I try to execute the index.php file, I could see the code is displayed as a plain text instead of executing the PHP code.Could you please help.
Thank you in advance!! - gracias sirvió y mucho
Trackbacks/Pingbacks
- QGIS Server on Windows 10 – level2 - […] instructions on this post – http://lifeofageekadmin.com/how-install-apache-2-4-php-5-6-and-mysql-5-6-26-on-windows-10/ (install 64bit versions in both cases, you can skip MySQL […]
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Jun 20, 2017How install Apache 2.4 PHP 7.1 and MySQL 5.7.18 on Windows Server 2016
Introduction
This post is a how to guide for installing Apache, PHP and MySQL on the latest release. In this post like previous we will cover installing all the programs individually. This will cover installing 64 bit versions of the programs.
Apache 2.4 Install
First download Apache 2.4 from http://www.apachelounge.com/download/ (httpd-2.4.25-win64-VC14.zip) Apache 2.4.25 VC14
This release is supported by the PHP 7.1.6 install from windows.php.net for Apache 2.4.
This release is supported by the PHP 7.1.6 install from windows.php.net for Apache 2.4.
Extract the zip copy Apache24 to the root of C:. This will be C:Apache24 when it is all done.
Microsoft Visual C++ 2015 Runtime
Download and install Microsoft Visual C++ VS 2015 x64 from https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads this is required for Apache to run.
PHP 7 and higher
Download php-7.1.6-Win32-VC14-x64 (thread safe) from http://windows.php.net/download/ . Extract and rename folder to php and move to C:.
Edit Apache’s config file, c:Apache24confhttpd.conf and add the following lines to the bottom of the file.
2 4 | AddHandler application/x-httpd-php.php PHPIniDir'C:/php' |
While we are at it we can add index.php to Apache’s list just incase we want to have a starting page as php.
Find Directory index and add index.php
Save the file changes. Next we need to register the path where the applications reside. This is done by editing the PATH variable.
Add
to PATH in Environment variables. PATH ENVIRONMENT (Control Panel | System Properties | Advanced | Environment Variables | System variables | Path).
Example:
;c:php;c:apache24;c:apache24bin;
Example:
;c:php;c:apache24;c:apache24bin;
We can also set this from the command prompt.
setx PATH “%PATH%;c:php;c:apache24;c:apache24bin” /M
Save and reboot the system.
Next we need to input a value for ServerName variable. You will have to un-comment it. Save the changes to the config file. Next move to the Register Apache Service step.
Register Apache Service
Now let’s register Apache as a service. Open a command prompt and type.
If do not want Apache starting automatically at start-up/reboot:
Command line
Install Mysql Module Php Windows Installer 2008 R2
Now lets check Apache settings by issuing the command,
c:Apache24binhttpd -S
At this point we can start Apache service and open a web browser and go to localhost and get the Apache It Works! page.
PHP Edits
Now we have to do a few edits to the php.ini file to tell it to load support for mysql and the location for the extensions. Since there is not a already set php.ini file we need to rename one of the two examples to php.ini.
Rename c:phpphp.ini-development to php.ini
Now let’s edit php.ini
Uncomment extension directory.
Uncomment extension directory.
2 4 6 8 | ;Directory inwhich the loadable extensions(modules)reside. ;extension_dir='./' extension_dir='ext' Uncomment mysql modules |
Save the changes and open a command prompt. Check to make sure it shows loaded modules.
So now we have Apache running and configured to use php. Lets create a file called info.php, save it and see if Apache parses the info correctly to display the results.
Open Notepad or your favorite Windows editor and type and save the following.
2 | phpinfo(); |
Open your browser and type, localhost/info.php for the location and you should receive alot of information about PHP.
MySQL
Download mysql-installer-community-5.7.18.1.msi. You will also need to install Microsoft Visual C++ VS 2015 x64 from https://www.microsoft.com/en-us/download/details.aspx?id=48145 and Microsoft Visual C++ VS 2013 x64 install first.
Download mysql-installer-community-5.7.18.1.msi. You will also need to install Microsoft Visual C++ VS 2015 x64 from https://www.microsoft.com/en-us/download/details.aspx?id=48145 and Microsoft Visual C++ VS 2013 x64 install first.
Once the installation is completed you can let the configuration wizard run and setup the database server. The defaults will work just fine, but remember what you set the password to for root and create a local user.
At this point you should have a working Apache / PHP / MySQL installation running and ready for you to use!
- Brilliant!This saved me a lot of time.So helpful. Thank you!
- HiWhat should i add at the bottom of httpd.conf file if i download httpd-2.4.29-Win64-VC15 version. Can you please guide me.Thanks a lot
- Good day, this tutorial is compatible with Windows server 2012 r2 or I need to change something?Thank you for you answer and congratulations for your work.
Trackbacks/Pingbacks
- Laravel on Windows cannot use MySQL – IlluminateDatabaseQueryException: could not find driver (SQL: select [duplicate] – Mysql Questions - […] the advise in this helpful post I editing my php.ini by uncommenting the following […]
This site uses Akismet to reduce spam. Learn how your comment data is processed.