Error404 February 2016

How to configure my virtual host properly on Apache in Ubuntu?

As the question says, I am trying to configure my virtual host on Apache in Ubuntu but I am getting some troubles. Here are the steps that I already done:

  • I created a folder on /var/rootfolder/host1.com/public where rootfolder it is my default directory (instead of /var/www). I created an index.html file inside of public folder.

  • After that I modify the file hosts on /etc/ and add the following line:

                              MY IP host1.com
    
  • Also I go to the folder /etc/apache2/sites-available and create the configuration of my new host. I named the file host1.com.conf and inside it I put:

<VirtualHost MY IP:Port that it is listening>

 ServerName host1.com
 ServerAlias www.host1.com
 ServerAdmin someone@host1.com
 DocumentRoot /var/rootfolder/host1.com/public
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  • I activated the new host: sudo a2ensite host1.com.conf

  • I reloaded Apache: service apache2 reload

but the problem I have it is that it is redirecting me to the page http://www.host1plus.com/ instead of the .html that I put on the folder public.

Am I missing some step? Is it my configuration in the correct way?

Thanks in advance!

Answers


Donatas Fe February 2016

at first, you are trying to use a registered domain while i may believe you are not the owner of it.

Check what results you get when you ping your configured domain. Does it point to your server address, or does it point to internet.

The second one, please check if you have a configuration in /etc/apache2/sites-enalbed/ that might be missing for website to work properly.


Donatas Fe February 2016

by default configuration files should be placed here: /etc/apache2/sites-enalbed/ ; /etc/apache2/sites-enabled/ - this directory should contain symlinks to original configration files. In my example:

VM:~$ ls -la /etc/apache2/sites-available/
total 24
drwxr-xr-x 2 root root 4096 Lap  4 14:16 .
drwxr-xr-x 8 root root 4096 Spa 27 19:44 ..
-rw-r--r-- 1 root root 1332 Geg 20  2015 000-default.conf
-rw-r--r-- 1 root root 6437 Geg 20  2015 default-ssl.conf
-rw-r--r-- 1 root root  264 Lap  4 14:16 snipeit.conf

VM:~$ ls -la /etc/apache2/sites-enabled/
total 8
drwxr-xr-x 2 root root 4096 Lap  4 14:16 .
drwxr-xr-x 8 root root 4096 Spa 27 19:44 ..
lrwxrwxrwx 1 root root   41 Lap  4 14:16 snipeit.conf -> /etc/apache2/sites-available/snipeit.conf

Post Status

Asked in February 2016
Viewed 3,132 times
Voted 4
Answered 2 times

Search




Leave an answer