Installing Apache Server in Windows

Installing Apache on Windows

Download apache zip from https://www.apachelounge.com/download/ extract zip at C:
rename to ‘apache’ open the file httpd.conf at C:\apache\conf\httpd.conf change Define SRVROOT "c:/Apache24" to Define SRVROOT "c:/apache" change #ServerName www.example.com:80 to ServerName localhost:80 open the powershell in admin then cd into C:\apache\bin and type .\httpd.exe change Listen 80 to Listen 81 if port 80 is busy

Apache Server logs

Apache server will print its logs in location C:\apache\logs. check the logs first in case of any problem.

Errors

[Sun Sep 27 12:08:17.784582 2020] [mpm_winnt:notice] [pid 20448:tid 648] AH00418: Parent: Created child process 20928
PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: C:\\php\\ext\\curl (The specified module could not be found.), C:\\php\\ext\\php_curl.dll (The specified module could not be found.)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: C:\\php\\ext\\intl (The specified module could not be found.), C:\\php\\ext\\php_intl.dll (The specified module could not be found.)) in Unknown on line 0

Running Apache as Service

To install open the powershell in admin then cd into C:\apache\bin and type .\httpd.exe -k install To uninstall open the powershell in admin then cd into C:\apache\bin and type .\httpd.exe -k uninstall press windows key + r type services.msc in the run dialogue box and press enter. Find the Apache2.4 service and start You can also stop from this services window Start service from powershell net start apache2.4 Stop service from powershell net stop apache2.4

Enabling the php

file named as php7apache2_4.dll present at root of php folder will link php to apache.

we will write the following configurations to our httpd.conf file which is in C:\apache\conf to link the php with apache. restart the apache to read changes in configuration file

LoadModule php7_module "C:/php/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "c:/php"

Setting Up Virtual Hosts in apache

Enable Virtual Host in httpd.conf

Virtual hosts
Include conf/extra/httpd-vhosts.conf

open the file named as httpd-vhosts.conf in C:\apache\conf\extra directory add the following code at the end of the file


<VirtualHost *:80>
    DocumentRoot "C:/apache/htdocs"
    ServerName localhost
    <Directory "C:/apache/htdocs/">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
---
<VirtualHost *:80>
    DocumentRoot "C:/apache/htdocs/test1"
    ServerName test1.local
    <Directory "C:/apache/htdocs/test1">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

---
<VirtualHost *:80>
    DocumentRoot "C:/apache/htdocs/test2"
    ServerName test2.local
    <Directory "C:/apache/htdocs/test2">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

in C:\Windows\System32\drivers\etc

https://www.osradar.com/how-to-install-apache-virtual-host-in-windows-10/

Edit the hosts file

file is at C:\Windows\System32\drivers\etc named as hosts, make your entries at the end of file, examples are given below.

127.0.0.1 localhost
::1 localhost
127.0.0.1 test1.local
::1 test1.local
127.0.0.1 test2.local
::1 test2.local
127.0.0.1 dolibarr-dev.local
::1 dolibarr-dev.local
127.0.0.1 dolibarr-staged.local
::1 dolibarr-staged.local
127.0.0.1 dolibarr-prod.local
::1 dolibarr-prod.local

Installing Xdebug

use wizard to download the dll https://xdebug.org/wizard rename the dll to php_xdebug.dll

add below settings in php.ini

[Xdebug]
zend_extension = C:\php\ext\php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_port=9000

Now install Xdebug helper extension. open the extension options and set the IDE KEY to PHPSTORM

Previous
Next