Apache2 virtualhosts config problem

This is my first forray into setting up virtual hosts. I am moving 4 sites from Lunarpages to a linode. I set up a basic html page as a place holder for each of the four sites. One of the sites I simply switched the domain servers to linodes'. One of the others I used the import zone feature from linodes domain manager. The other two I left alone for now. Ok so I initally set up Apache, punched the ip into the browser and got the "IT WORKS!". Great. I then set out to set up some virtual hosts to handle the multiple sites.

  • I created directories for each of the sites in /var/www/public_html/domainname/public,private,log,etc…

  • I created a basic html file for each site and placed it /var/www/public_html/domainname/public/index.html

  • I edited the apache2.conf file and added the lines

Include /etc/apache2/sites-enabled/

ServerName 97.107.133.117

NameVirtualHost *:80

NameVirtualHost *:443

  • I created a vhost file for each domain and placed them /etc/apache2/sites-available/domain1.com

the content of the file was:

Place any notes or comments you have here

It will make any customisation easier to understand in the weeks to come

domain: domain1.com

public: /home/var/www/public_html/domain1.com/

# Admin email, Server Name (domain name) and any aliases

ServerAdmin webmaster@domain1.com

ServerName 97.107.133.117

ServerAlias www.****domain1.com****

Index file and Document Root (where the public files are located)

DirectoryIndex index.html

DocumentRoot /home/var/www/public_html/domain1.com/public

Custom log file locations

LogLevel warn

ErrorLog /home/var/www/public_html/domain1.com/log/error.log

CustomLog /home/var/www/public_html/domain1.com/log/access.log combined

-I used the command sudo a2ensite domain1.com for each of the sites. I rebooted Apache after each.

The problem is: I point the browser at the IP 97.107.133.117 and the default html does not show. I am not sure if I set things up right. Any help or comments would be appreciated

2 Replies

Im fairly new myself, so i dont know how (if possible) to point a IP to a number of vhosts.

Try setting up DNS, and try it with your config.

I think the problem is that you have the servername set to your IP address, if this is the same for each vhost, apache cant distinguish where to point to.

This is a sample of one of my vhosts.

 <virtualhost *:80="">ServerAdmin webmaster@domain.tld
    DocumentRoot "/srv/http/domain.tld"
    ServerName domain.tld
    ServerAlias domain.tld
    ErrorLog "/var/log/httpd/domain.tld.error_log"
    CustomLog "/var/log/httpd/domain.tld.access_log" common</virtualhost> 

Requests to the numeric IP address should go to the first virtual host for that IP ~~[http://httpd.apache.org/docs/2.0/vhosts/name-based.html#compat" target="_blank">](http://httpd.apache.org/docs/2.0/vhosts … tml#compat">http://httpd.apache.org/docs/2.0/vhosts/name-based.html#compat](.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct