About
This article is a succession of step by step that shows you how to install Apache on Windows.
This article was done with the following application version but the principe stays and should work with all version
- Windows 10
- Apache 2.4
Steps
Download the binary
The Apache project does not provide the Windows binary.
The download php page recommends to use apachelounge because they use their binaries to build the Apache SAPIs.
Download the last binary at apachelounge
Example:
httpd-2.4.46-win64-VS16.zip
- VC15 stands for Visual Studio Compiler Version 15
- VS16 for Visual Studio 16
Unzip and move
- Unzip it (The file readme_first.html is the installation guide and is summarized below)
- Copy the file to
C:\Apache24
Add the php home directory path into the user and system path
On windows, from 7.4, the sqlite extension needs to get access to the libsqlite3.dll that is located into the php directory.
If you are running the service with the system path, you should add the php home directory in the system path.
Create the service
- Start the command prompt as admin
- Install the service and start it with the httpd binary
cd C:\Apache24\bin
httpd -k install
httpd -k start
- The http windows service should have been created
- A welcome page should also be seen at http://localhost. This page is located at: C:\Apache24\htdocs
There is more options. See the documentation
Configuration
Server Name
To get access to the main server:
ServerName local
Rewrite Module
The rewrite module permits to have nice url and is generally used.
Uncomment the line
LoadModule rewrite_module modules/mod_rewrite.so
Virtual host
Add virtual host
ServerName serverName
# Virtual Host
Include conf/extra/httpd-vhosts.conf
Php
Add php as module of Apache in the httpd.conf file
On Windows, to be able to load the intl extension (localization), you need also to add the ICU file. In the documentation, they said that you can also set them on the LD_LIBRARY_PATH.
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icudt64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuin64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuio64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuuc64.dll"
Then:
LoadModule php7_module "C:/php-7.2.28-Win32-VC15-x64/php7apache2_4.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php-7.2.28-Win32-VC15-x64"
<Directory "C:/php-7.2.28-Win32-VC15-x64/" >
AllowOverride None
Options None
Require all granted
</Directory>
FastCGI
If you want to boost your performance, FastCGI is the way to go. See this article that shows how to install it
Support
PHP Startup: Unable to load dynamic library 'intl'
If you get this error in the log:
- verify that you see the extension with php
php -m
- If this is the case, the root cause if mainly that the icu file as explained in the documentation where not found. They are all located in the php directory, you can add them into the Apache process space with the LoadFile directive as shown in the php section
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icudt64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuin64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuio64.dll"
LoadFile "C:\php-7.2.28-Win32-VC15-x64\icuuc64.dll"
Module not loading
For whatever reason, Apache locates the extension directory from the working directory. In the php.ini, be sure to put the qualified path.
extension_dir = "c:\php-7.2.28-Win32-VC15-x64\ext"
Sqlite module not loading
Be sure to add your php home directory into the user/system path that runs Apache. See bug 78957