Download either the 32-bit version (httpd-2.4.20-win32-VC14.zip) or 64-bit version (httpd-2.4.20-win64-VC14.zip). Check if your Windows is 64-bit, you should always try to install 64-bit version of software. To find the OS version, you can use the msinfo32.exe. You can use this tool to gather information about your computer, to diagnose issues with your computer, or to access other tools.
To start this one, Run > type msinfo32 > hit Enter.
After you have find the right version, download the Zip file and then extract the file to a directory called C:\Apache24
Before start the Apache server, if you want change the listen port to 8181
Open C:\Apache24\conf\httpd.conf file in your text editor. Find this line:
Listen 80
and change it
Listen 8181
After the change, save it and you are ready to start the apache web server.
Open the Command Prompt as Administrator and change to the bin sub-directory
C:\Apache24\bin
Type httpd.exe and press Enter.
If you get an error dialog stating that MSVCR140.dll is missing, you’ll need to install the Visual C++ Redistributable for Visual Studio 2015. (Select vc_redist.x64.exe if your Windows is 64-bit)
https://www.microsoft.com/en-us/download/details.aspx?id=48145
Now open the browser and type http://localhost:8181 to see the demo web site up and running.
Install PHP 7 on Windows
PHP 7, a major update to the server-side web development language PHP. Download the VC14 x64 Thread Safe (2016-Apr-29 00:38:19) zip file (if you downloaded the 32 bit version of Apache then download PHP x86, don't mix versions).http://windows.php.net/download/
Create a folder named "php7" then extract the file php-7.0.6-Win32-VC14-x64.zip into the folder and move it to C:\
Configure Apache to use PHP
Open the Apache Configuration file C:\Apache24\conf\httpd.confCopy the following lines on the top of the file:
- AddHandler application/x-httpd-php .php
- AddType application/x-httpd-php .php .html
- LoadModule php7_module "c:/php7/php7apache2_4.dll"
- PHPIniDir "c:/php7"
<IfModule dir_module> DirectoryIndex index.php index.html </IfModule>
Save all. Now rename the file C:\php7\php.ini-development to C:\php7\php.ini
Enabling mod_rewrite for URL rewriting
Open the Apache Configuration file C:\Apache24\conf\httpd.confFind the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the hash ‘#’
Find any additional occurrences of the line "AllowOverride None" and change it to "AllowOverride All"
Configuring PHP with MySQL
Edit the php.ini file and uncomment the extension directory. Remove the ";" to uncomment:; Directory in which the loadable extensions (modules) reside. ; http://php.net/extension-dir ; extension_dir = "./" ; On windows: extension_dir = "ext"
Uncomment the following lines, this will enable the starting of the MySQL modules
extension=php_mysqli.dll extension=php_pdo_mysql.dll
and these other lines if you use the installation in a development environment
extension=php_curl.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_openssl.dll
Uncomment the error_log to enable file logging; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
error_log = c:\php7\php_errors.log
Save the file changes.
IMPORTANT! Set your PATH for Windows to find PHP
- Right-click on "My Computer"
- Properties
- Advanced Tab > Environment Variables
- Under System variables, scroll down to find "Path", select and click on Edit.
- Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
- Click Okay.
How to check if php is installed
Create the following text file C:\Apache24\htdocs\phpinfo.phpRegister Apache Service
If you want to register Apache as a Windows Service, open a command prompt and type:C:\Apache24\bin\httpd -k install
If do not want Apache starting automatically at start-up/reboot type:
C:\> sc config Apache2.4 start= demand
great tut... found what was I missing...
ReplyDeleteFinally a tutorial that works! CONGRATULATIONS! The first!
ReplyDeleteFinally a tutorial that works! Congratulations! The first !!!!!
ReplyDeleteAwesome tutorial! Thanks a million times, you just saved me hours of work. :-)
ReplyDeleteWow What a wounderful Tutorial. See ya from Brazil - Thank you. Fernando Passaia.
ReplyDeletewhen i am installing its giving error
ReplyDeletehttpd: Syntax error on line 3 of C:/Apache24/conf/httpd.conf: Cannot load c:/php
7/php7apache2_4.dll into server: The specified module could not be found.
needs solution ..... m dieing here
You may not be recognizing the .dll file because it has a dependency on the Visual C++ Redistributable for Visual Studio 2015. Once you downloaded and installed the exe files then after another all will work. Remember that php7apache2_4.dll is only in the thread safe version of php, the non-thread safe (nts) versions do not have it.
DeleteAwesome! Perfect tutorial. Thanks!
ReplyDeleteGreat tutorial, helped me to fix the issues with apache24.
ReplyDeleteI am fighting since days with the PHP_PDO.dll: can not fix "PHP Startup: Unable to load dynamic library 'c:\php\ext\php_pdo.dll' Is not a valid Win32 application
Do you have any idea how to fix it ?
Awesome tutorial congratulations
ReplyDeleteFantastic Tutorial.
ReplyDeleteVery clear and direct.
In my case to see the info I typed, localhost/phpinfo.php, with out the port, and works perfect.
Thanks.
Great job;
ReplyDeleteThanks a lot
Easy steps to follow!!! Nice work done
ReplyDelete