Apache Web Server And PHP Setup For Windows

Apache Installation

1.Two directories named "webserver" and "www" are created.Server files are stored under "webserver" and site files are stored under "www".Create directories on another drive to avoid problems such as crashing the operating system or formatting the disk.An example would be D:/.

2.The 32-bit version of Apache is downloaded from https://www.apachelounge.com/download/VC11/.In this article, we describe Apache 2.4.29 Win32 VC11 (httpd-2.4.29-win32-VC11.zip) version.

3.The "Apache24" folder in the downloaded compressed file (.zip) is copied to the "D:/webserver" directory.

4.Open the "httpd.conf" file in "D:/webserver/apache24/conf" with "Notepad" or "Notepad++".Edit the following lines as indicated.


This line where the ServerRoot "c:/apache24" server home directory is specified

Change to ServerRoot "d:/webserver/apache24".

 #ServerName www.example.com:80 this line where the server name is specified

Change to ServerName  localhost.

DocumentRoot "c:/apache24/htdocs" this line specifying the directory where the site files will be located

Change to DocumentRoot  "d:/www".

 Line <Directory "c:/apache24/htdocs">

Specify the specific configuration for the "d:/www" directory where our site files will be located by changing it to <Directory "d:/www">.

 ScriptAlias /cgi-bin/ line "c:/apache24/cgi-bin/"

Change ScriptAlias /cgi-bin/ to "d:/webserver/apache24/cgi-bin/" to specify the directory where the server cgi files are located.

 Line <Directory "c:/apache24/cgi-bin">

Change to <Directory "d:/webserver/apache24/cgi-bin"> to specify the specific configuration to the directory where the server cgi files are located.


Php Installation

1.Download the 32-bit PHP files compatible with the downloaded Apache VC version from https://windows.php.net/download/.The VC versions of Apache and PHP need to be the same.Download php-5.6.34-Win32-VC11-x86 (php-5.6.34-Win32-VC11-x86.zip), compatible with Apache VC11.

2.Create and put the files in "php-5.6.34-Win32-VC11-x86.zip" into a folder named "php" in the "D:/websever" directory.

3.Find the file "php.ini-development" with PHP configuration settings in the "D:/webserver/php" directory and rename it to "php.ini".

4.Open the "php.ini" file with a text editor and edit the following lines:

instead of extension_dir = "ext"

Type extension_dir = "d:/webserver/php/ext".

 Remove the semicolons (;) at the beginning of the following lines (in the php.ini file, the semicolon (;) at the beginning of the line indicates that the line is a comment). The MySQL database connection becomes active.



 Find [Date] and for your country time zone:

Add date.timezone = "continent/city". If date.timezone is present and preceded by (;), remove it.


Connecting Apache and PHP

 1.For PHP integration with Apache, reopen the "httpd.conf" file in the "D:/webserver/Apache24/conf" directory with a text editor.

Add the following line at the bottom of the lines starting with LoadModule.

LoadModule php5_module d:/webserver/php/php5apache2_4.dll This enables PHP communication with Apache.

In the DirectoryIndex index.html line, the default index files are specified for the homepage detection of the sites, the index.php statement should be added to this line.

becomes DirectoryIndex index.html index.php. This introduces the .php extension index files on the site as the homepage.

 Introduce php files to Apache by adding the AddHandler application/x-httpd-php .php line,into the <IfModule mime_module> group,

 In order for Apache to access the settings in the php.ini file, add the directory where the file is located at the bottom of the "httpd.conf" file as follows.

PHPIniDir "d:/webserver/php"


Installing Apache as a Windows Service

 1.Finally run "httpd.exe" in "D:/webserver/Apache24/bin" directory. Apache can install it as a Windows Service instead of running it that way every time. To do this, run Command Prompt (cmd.exe) as administrator. Here;

2.Return to the C:/ home directory with the cd / command and then type D: to switch to the "d" disk.

3.Type cd D:/webserver/apache24/bin and navigate to the directory where the "httpd.exe" file is located.

4.After the directory line appears on the screen, type the command httpd.exe -k install -n "Apache HTTP Server" and install Apache as a Windows Service. Open "Services" in the start menu to check the installation. Right-click on the "Apache2.4" line in the incoming services list and select "Start" to start the service. If it runs without errors and the "Startup Type" is "Automatic", the Windows Service is ready. Now, when the computer restarts, "Apache" will start working automatically.


Testing of Apache and Php Installation

 1.To check that your installation is working, create a new file named "test.php" with a text editor in the "D:/www" directory, and write the following PHP codes in the file.

<?php echo phpinfo(); ?>

2.Open a browser and type "localhost/test.php" in the address bar and hit "enter". If the page opens without problems and shows PHP's features, it means that the installation has been completed successfully.

3.You can create your sites in the "D:/www" directory. To see your current sites, type "localhost" in your browser's address bar and press the "enter" button, you can test your sites on the browser from this list.


Our MySQL database server setup article: https://sanal.mobi/tr/Blog/164-windows-icin-mysql-56-ve-57-kurulumu

22/03/2018 23519


Expressions belong to readers / commenters. Sanal Yazılım Ltd. or sanal.mobi is not responsible for these reviews. Your name and surname are shown anonymously, and your e-mail address is not published.

PI*** LA***

Çok teşekkürler...



VA*** SA***

Yardımcı olma duygularınız için teşekkür ederim.
Ama iki gulhuvallah bir elham okuyup, bir de kurban kesmezsek olmaz gibi geliyor bana...
Wamp server, Xamp server kurmaktan başka çare yok gibi...
Ne dolambaçlı yollarmış..


Her seferinde buradan faydalanıyorum. Çok teşekkürler.

We use cookies to enhance user experience, analyze site usage and assist in our marketing efforts. By continuing to browse our site or closing this banner, you acknowledge that you have read and agree to our Cookie Policy.