search
top

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.

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:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.

LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
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

DirectoryIndex index.html 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

;c:\php;c:\Apache24;c:\Apache24\bin

to PATH in Environment variables. PATH ENVIRONMENT (Control Panel | System Properties | Advanced | Environment Variables | System variables | Path).
Example:
;c:\php;c:\apache24;c:\apache24\bin;

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.

c:\apache24\bin\httpd -k install

If do not want Apache starting automatically at start-up/reboot:

Command line

C:\> sc config Apache2.4 start= demand

Now lets check Apache settings by issuing the command, c:\Apache24\bin\httpd -S

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:\php\php.ini-development to php.ini

Now let’s edit php.ini
Uncomment extension directory.

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

Uncomment mysql modules
extension=php_mysql.dll
extension=php_mysqli.dll

Save the changes and open a command prompt. Check to make sure it shows loaded modules.

C:\> php -m

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.

<?php
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:\MySQL\MySQL 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!

62 Responses to “How install Apache 2.4 PHP 5.6 and MySQL 5.6.26 on Windows 10”

  1. pradeep says:

    it says php not recognised as any internal or external command, operable program or batch file.

    • Tammy says:

      Did you ever find a solution? I am experiencing the same error.

      • newlife007 says:

        I haven’t looked but I will.

      • newlife007 says:

        I found I had x64 ns x86 mixed. I have updated the post. Here are the correct steps.

        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.

        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:\Apache24\conf\httpd.conf and add the following lines to the bottom of the file.

        LoadModule php5_module “c:/php/php5apache2_4.dll”
        AddHandler application/x-httpd-php .php
        # configure the path to php.ini
        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

        DirectoryIndex index.html 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

        ;c:\php;c:\Apache24;c:\Apache24\bin

        to PATH in Environment variables. PATH ENVIRONMENT (Control Panel | System Properties | Advanced | Environment Variables | System variables | Path).
        Example:
        ;c:\php;c:\apache24;c:\apache24\bin;

        Save and reboot the system.

        • Janne says:

          can you help me to start Apache on Windows 10

        • Greglim says:

          I installed Apache 2.4 and It Works but PHP does not run the info.php, screen stays blanks. No error no nothing.
          I ran c:\php\php -m and also works.It show all modules
          I was not able to change the environment variable because it says Path Variable to long even so I deleted other paths in the variable to add this new one does not allow it.I googleed and there is more people having the same problem. This is windows 10 jic.

          • newlife007 says:

            Open a command prompt and type setx PATH “%PATH%;c:\php;c:\Apache24;c:\Apache24\bin” /M

            Close the command prompt and open it again and try the command.

          • greglim says:

            I was able to modify the path on the environment variable by using regedit. I rebooted but the same problem.

      • newlife007 says:

        I have a question. In your view in libraries when looking at the files are the know extensions showing? By default they are hidden, the reason I ask is the file name may have .txt on the end of the file. Also, is the info.php file in the c:\Apache24\htdocs directory.
        On my Windows 10 install I ran into that issue with hidden extensions. Click View > Options > Click on view tab. Un-check Hide extensions for known filetypes. Click Apply and then apply to all folders and check the file name.

        • greglim says:

          I fixed the problem. The PHP was unable to work because the PHP versions I downloaded from PHP NET were wrong.
          the PHP.exe vas compiled with a different version of the one used to compile the pdo mysql driver. I tried with all all versions PHP 5.6 and 7 and 32/64 bit and nts and ts. All had the same problem. So I downloaded WAMP from Binami and installed it. Then I copied the PHP directory from WAMP to C:\php and modify PHP.ini removing all references to C:\wamp. Now it works.

    • William Otis says:

      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!

  2. Renato says:

    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…

    • Nitram says:

      Kindly Share the versions you have installed…

      Which version of php 7 preferably share the link to download

      • newlife007 says:

        The version I have installed on Windows 10 are just what I have listed in the post. Are you having any issues with a particular version? The main rule of thumb is to make sure you are installing 64 bit versions and you have the correct VC++ runtime version installed to match the version Apache was compiled with.

  3. Rob Russell says:

    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 code

    Uncomment mysql modules ….

    immediately after

    extension_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

    • newlife007 says:

      I think your issue is that Windows cannot find the php command. In the instructions there is a part to edit the path statement and add o the path and reboot.

      Add

      ;c:\php;c:\Apache24;c:\Apache24\bin

      to PATH in Environment variables. PATH ENVIRONMENT (Control Panel | System Properties | Advanced | Environment Variables | System variables | Path).
      Example:
      ;c:\php;c:\apache24;c:\apache24\bin;

      Save and reboot the system.

  4. Miguel says:

    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

  5. Nick says:

    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:80

    Also the part with the envrionment variables I do not think I am doing right.

    I can add:

    C:\php
    C:\apache24
    C:\apache24\bin

    all separately in Path for Environment Variables but I cannot add

    ;c:\php;c:\apache24;c:\apache24\bin;”

    How am I supposed to correctly edit the variables?

    • Nick says:

      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:\Apache24\bin\httpd -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.

      • newlife007 says:

        For the Cannot load modules/mod_access_compat.so error look in your c:\Apache24\modules directory to make sure it exists. If not re-extract the Apache zip file you downloaded and copy the files in the directory. If the files exist then you do no have the Visual C++ Redistributed downloaded and installed. If this is the x64 version and is the VC14 compile you need the Visual C++ 2015 x64 Redistributed. If it is the VC11 compiled you need the Visual C++ 2012 x64 Redistributed.

    • newlife007 says:

      To edit the path variables you need to add ;c:\php;c:\apache24;c:\apache24\bin; to the end of the path statement. To get to the path statement you can do this by right clicking on the windows icon in the lower left > Control Panel > System > Advanced System Settings > Click on Environment Variables button. In the System Variables box find the Path variable and double click on it and add the line ;c:\php;c:\apache24;c:\apache24\bin; and save it and reboot. For the Servername change the http://www.example.com to either the IP address of the system or the system name.

  6. logan says:

    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!

    • Lucien says:

      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 n\x92 is not a valid Win32 application”

      Also followed all the steps and encounter this problem when installing the Apache server under Windows 10.

      • Lucien says:

        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!

  7. hassan says:

    Simple and nice instructions. anyone having a little knowledge about technicality of computer can understand this. Worked for me! Thanks.

  8. Aries says:

    Is this compatible to Window 7? Thank you.

  9. Estacio says:

    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

    • melindac122 says:

      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?

  10. olivedev says:

    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.

  11. Rudy says:

    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:\apache24\htdocs directory.

  12. Stephen Hughes says:

    Not seen this mentioned, but have used this before, very easy to install and configure Apache and MySql with PHP install

    https://www.apachefriends.org/index.html

  13. Dave says:

    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? 😉

  14. Priscila says:

    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

  15. Priscila says:

    .. 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

  16. Omkar says:

    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 x64

    from the above steps
    everything worked till

    php -m

    ERROR:
    when tried to run
    localhost/info.php

    got an HTTP ERROR 404

    SOLUTION (in my case):
    As I have Skype and it uses port *80

    I set the PORT in APACHE config file to *8888

    Hence to access the info.php in browser type

    localhost:8888/info.php
    localhost:/info.php

  17. dave says:

    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.

  18. Shakiba says:

    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.

  19. Robert says:

    Just wanted to say thanks!
    Everything worked perfectly – you the man!

  20. Jessie James says:

    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

  21. Jessie James says:

    exscuse me i ment in the PHP.ini my bad

  22. gandhimathi says:

    Thanks for this article, working perfectly.

    Thanks

  23. David says:

    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:\apache24\htdocs” 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.

    • newlife007 says:

      Let me see if I can figure something out. I will get back to you.

    • newlife007 says:

      Here is a solution. Put your DocumentRoot back to the default. Go down to the end of the httpd.conf file and you will see the Supplemental Configuration section. What I would do is add a line to load a seperate configuration file and create one for the websites. There is an example httpd-vhosts.conf that you can use.

      • David says:

        Thank you, hopefully I am almost there 😉

        With http://localhost, the new setup pulls up the index.html page of the website, but I cannot go any deeper. The error message is “Forbidden … You don’t have permission to access …” for all other sub-directories/pages. I stay stuck at the index.html page. Of course, cannot bring up info.php either (same error message).

        However, as the Administrator I have full access to all website directories. I have verified this.

        Any help will be appreciated.

        • newlife007 says:

          I found the possible fix. As of 2.4.2 you need to add Require all granted. If you are not hosting multiple domain and not using Virtual Hosts, change your conf file


          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride All
          Order Allow,Deny
          Allow from all
          Require all granted

          If you are using Virtual Hosts try this


          ServerAdmin webmaster@localhost
          DocumentRoot “c:/webs”
          ServerName localhost
          ErrorLog “logs/localhost-error.log”
          CustomLog “logs/localhost-access.log” common

          • David says:

            I also found a fix at the Apache website yesterday. Because I had already created httpd-vhost.conf (as you had suggested), I simply added the following to it, and now it works.

            Require all granted

            As the administrator, if I have access to the full system and all directories, it is somewhat annoying that all of the above should be necessary to make things work in Windows 10. BTW, I did not have to do this in Windows 7 on a different computer. But that is another issue!

            Thank you very much for pointing me in the right direction.

  24. LeonM says:

    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 download

    Apache says cant locate module.

    • newlife007 says:

      First question is did you add c:\php to your path environment and also since you are using php 7 you need to use LoadModule php7_module “c:/php/php7apache2_4.dll” and make sure you have the VC15 version, they must match.

      • LeonM says:

        Thanks for your reply. Downloaded httpd-2.4.27-Win64-VC15.zip then php-7.1.9-nts-Win32-VC14-x64, and VC15. VC15 fails saying another version installed, remove vc17 then reinstall vc15 then install vc17. vc17 removes vc15. microsoft says vc17 includes vc15. Edit apache conf file at end. LoadModule php7 “c:/php/php7apache2_4.dll” etc. Path setup as instructions. register apache – “C:\>apache24\bin\httpd -k install
        Installing the ‘Apache2.4’ service
        The ‘Apache2.4’ service is successfully installed.
        Testing httpd.conf….
        Errors reported here must be corrected before the service can be started.
        httpd: Syntax error on line 535 of C:/apache24/conf/httpd.conf: Cannot load c:/php/php7apache2_4.dll into server: The specified module could not be found.” The module php7apache2_4.dll does not exist in apache or php downloads. Can you help?

        • newlife007 says:

          Did you edit your path environment variable for c:\php and renamed the extracted PHP 7 directory to PHP on root of C drive?

          • LeonM says:

            Yes. The path variable is correct. The extracted php is at C:\php.
            The problem is there is no file “php7apache2_4.dll”.
            I had downloaded the nts(not thread safe) version of php7. This does not contain “php7apache2_4.dll”. Only the thread safe versions of php7 contains it. So I downloaded the tread safe version of php. Now it all works! Thank you for your help.

  25. Purushothama Raju Prathigudupu says:

    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.5

    I’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!!

  26. Nicolas says:

    gracias sirvió y mucho

Trackbacks/Pingbacks

  1. 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 […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top