Windows 11 Pro: Apache/PHP Web Server Setup - Reverted Program Files Directory and conf/dist Folders
In this article, we will cover the installation and setup of a local Apache/PHP web server on Windows 11 Pro, focusing on reverting the Program Files directory and managing the conf/dist folders. This guide assumes that you have a basic understanding of web development and the Windows operating system.
Installing Apache
To get started, download the latest version of Apache for Windows from the official Apache website (https://httpd.apache.org/download.cgi?platform=win32). Once downloaded, extract the contents of the zip file to a directory of your choice (e.g. C:\Apache24).
Next, open the Command Prompt as an administrator and navigate to the Apache bin directory (e.g. C:\Apache24\bin). Run the following command to start the Apache server:
httpd.exeIf everything is set up correctly, you should see output indicating that the Apache server has started successfully.
Installing PHP
To install PHP, download the latest version of PHP for Windows from the official PHP website (https://www.php.net/downloads.php). Once downloaded, extract the contents of the zip file to a directory of your choice (e.g. C:\PHP).
Next, open the php.ini file located in the PHP directory and make the following changes:
- Uncomment the line "extension_dir = "ext""
- Add the following lines to the end of the file:
extension=curl
extension=fileinfo
extension=gd2
extension=mbstring
extension=openssl
extension=pdo_mysql
extension=xmlSave the changes and close the file.
Configuring Apache to Use PHP
To configure Apache to use PHP, open the httpd.conf file located in the Apache conf directory and make the following changes:
- Uncomment the line "LoadModule php7_module modules/libphp7.so"
- Add the following lines to the end of the file:
AllowOverride All
Require all granted
AddType application/x-httpd-php .php
PHPIniDir "C:\PHP"Save the changes and close the file.
Reverting the Program Files Directory
By default, Apache and PHP are installed in the Program Files directory. However, it is recommended to revert to the original Program Files directory to avoid any potential issues. To do this, move the Apache and PHP directories to a new location (e.g. C:\webserver) and update the paths in the httpd.conf and php.ini files accordingly.
Managing the conf/dist Folders
The conf/dist folder in Apache contains sample configuration files. It is recommended to make a copy of these files and move them to the conf folder, then modify them as needed. This will ensure that any updates to the sample files in future versions of Apache do not overwrite your custom configurations.
In this article, we have covered the installation and setup of a local Apache/PHP web server on Windows 11 Pro, focusing on reverting the Program Files directory and managing the conf/dist folders. By following these steps, you should be able to create a functional local development environment for your web projects.