How to config httpd.conf in Xampp

Some config httpd.conf in Xampp

First, you can check config httpd.conf in xampp details here: https://gist.github.com/rukku/3411602

Apache (httpd.conf) in Xampp

Configure Virtual Host: httpd-vhosts.conf

  • Open the file C:\xampp\apache\conf\extra\httpd-vhosts.conf with some editing tool.
  • Below the file we see that there is a sample configuration for port 80 that has been commented not to run with the # sign.
##<VirtualHost *:80>
    ##ServerAdmin webmaster@robertnguyen.example.com
    ##DocumentRoot "C:/xampp/htdocs/robertnguyen.example.com"
    ##ServerName robertnguyen.example.com
    ##ServerAlias www.robertnguyen.example.com
    ##ErrorLog "logs/robertnguyen.example.com-error.log"
    ##CustomLog "logs/robertnguyen.example.com-access.log" common
##</VirtualHost>
  • Below this sample code we add the following configuration code:
<VirtualHost *:82>
    DocumentRoot "C:/xampp/htdocs/demo_project"
    ServerName demo_project.local
    ServerAlias www.demo_project.local
    ErrorLog "C:/xampp/apache/logs/demo_project.local-error.log"
    CustomLog "C:/xampp/apache/logs/demo_project.local-access.log"
    <Directory "C:/xampp/htdocs/demo_project">
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>
  • <VirtualHost *:82> : This is one of the ports that have been added to httpd.conf, if configured to run domain, we can use port 80.
  • DocumentRoot The directory containing the project (required declaration)..
  • ServerName Server name, use domain name and port if available (required).
  • ServerAlias Alternative name for server name (optional declaration).
  • ErrorLog The path to the error log file, will see the error from here (optional declaration).
  • CustomLog The path to the Uri log file when the user requests it (optional declaration).
  • Directory Inside this tag used to grant permissions to the folder.

After the above configuration is complete, save it and need to restart Apache, by opening XAMPP click on the corresponding stop of Apache and start again, this time you try to run it in the browser again with the new path

Similarly, we can create many different Virtual Hosts in the httpd.conf . file
However, If you have any questions or comments, feel free to contact me here or comment below the post

So Thank you for your interest in my articles
Wish you a good day