I am trying to set up virtual host in Apache2 with Ubuntu 14.04. The contents of host1.com.conf file are :

<VirtualHost *:80>

    ServerAdmin admin@host1.com
    ServerName host1.com
    ServerAlias www.host1.com
    DocumentRoot /var/www/host1.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

  • contents of /etc/hosts :       localhost       chandni-X451CA       host1.com
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
  • contents of /etc/apache2/sites-available/default-ssl :

    <IfModule mod_ssl.c>
        <VirtualHost _default_:443>
             ServerAdmin admin@host1.com
             DocumentRoot /var/www/host1.com/public_html
             <Directory /var/www/host1.com/public_html>
                Require all granted
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            SSLEngine on
            SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
            SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                  SSLOptions +StdEnvVars
            <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
            BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
            BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  • disabled 000-default.conf and enabled host1.com from the terminal :

    sudo a2dissite 000-default.conf && sudo a2ensite host1.com.conf
  • restarted apache:

    sudo service apache2 restart

After doing all these,

  • When I go to localhost page I get 403 Forbidden error.
  • When I type my public IP address as URL, the page is not loaded
  • When I navigate to host1.com, the page is not loaded.

What may be the possible reason? Can anyone please help??


This error occures when your web server hasn't access to DocumentRoot folder. you must check permissions of parent folders of folder that you specify in DocumentRoot variable. www-data must access read and execute to parent folders and also access read to files under DocumentRoot directory. you can solve this by changing the owner of files and folders to www-data or give read and execute access to all others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.