Search code examples
phplinuxapachelamphttpd.conf

Apache2.4.11 virtualhostconfiguration is not working


I have tried the below code to point the domain name to specific directory into linux

NameVirtualHost *.80
<VirtualHost *:80>
     ServerName example.com
     DocumentRoot /var/www/html/example.com
</VirtualHost> 

but the above code is not working.


Solution

  • the above code is for apache2.2, so you just replace above code with

    <VirtualHost *:80>
       ServerName     example.com
       ServerAlias    www.example.com
       ServerAdmin    root@example.com
       DocumentRoot   "/var/www/html/example.com"
       CustomLog      "/var/www/html/example.com/access_log" combined
       ErrorLog       "/var/www/html/example.com/error_log"
    </VirtualHost>