I am working Linux Mint 17.3, and trying to create virtual hosts on Apache 2.4. I have followed the following procedure, but I still can't browse the site.

  1. Create two new virtual hosts.

    sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf
  2. Modify each host.

    sudo vim /etc/apache2/sites-available/site1.com.conf 
    <VirtualHost *:80>  
      ServerName site1.com  
      ServerAlias www.site1.com  
      ServerAdmin [email protected]  
      DocumentRoot /var/www/site1.com/public_html  
      ErrorLog ${APACHE_LOG_DIR}/error.log  
      CustomLog ${APACHE_LOG_DIR}/access.log combined  
  3. Enable the new virtual host files.

    sudo a2ensite site1.com  
    // Disable original html host  
    sudo a2dissite 000-default.conf  
    sudo service apache2 reload 
  4. Add host info.

    sudo vim /etc/hosts   site1.com site2.com

I have checked out everything online that I could. I want to know what step I am missing here.

  • I have already asked this question on stackoverflow but still no answer.
    – Badar
    Mar 2, 2016 at 17:38
  • To be honest, I think it is much easier for small time usage to put both virtual hosts in 000-default.conf. Second, you should post the actual xml config you have done, because simple things like the interpolation of your apache log directory could be breaking the evaluation of the config. Also the port binding you declared is not evident with the information you provided, and your hosts file seems to indicate you wish apache to watch ports 88 and 89 which is a bit odd, when you can have it watch port 80 and route traffic to each host even if they have their own ports.
    – sanimalp
    Mar 2, 2016 at 17:59
  • @sanimalp, would you please show me how to do what you actually are trying to convey me. This might be the correct answer and will me and others in future. Thanks
    – Badar
    Mar 2, 2016 at 18:12

1 Answer 1


I would argue that your configuration should look something like this:

Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/example1"
    ServerName www.example.com

    # Other directives here

<VirtualHost *:80>
    DocumentRoot "/www/example2"
    ServerName www.example.org

    # Other directives here

Use 000-default.conf only, and forget about the other configuration until you get more comfortable with how this works. If you have an app server such as node or tomcat serving on specific ports, then you could configure the virtualhost port to be that app's port, but it looks like you are trying to serve static resources from /var/www/, so you don't even need multiple port mappings. Apache will just watch the request and route traffic to the right location for you. With this configuration, your host file becomes: example.com example.org

edit: since you have posted what might be most of your conf file, it looks like you are missing a listen 80 directive at the top of the file?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .