Score:0

How do you set up multiple virtualhosts on apache2 using only the server ip and server alias?

sj flag

I'm trying to set up apache with multiple virtual hosts "filebrowser.com" and "videos.com" however, I'm only able to access filebrowser.com and not videos.com. I also have to enter the static IP of my server "172.16.0.6" in order to access the site. I'm assuming apache is using the most relevant host (alphabetically). Basically, I'm unable to load either site using the server alias.

Here is the config file for videos.com

<VirtualHost *:80>

ServerAdmin webmaster@localhost
ServerName 172.16.0.6
ServerAlias www.videos.com
DirectoryIndex index.html
DocumentRoot /home/usr/public/Videos


LogLevel info
ErrorLog ${APACHE_LOG_DIR}/VideosError.log
CustomLog ${APACHE_LOG_DIR}/VideosAccess.log combined

and here is the config file for filebrowser.com

<VirtualHost *:80>

ServerAdmin webmaster@localhost
ServerName 172.16.0.6
ServerAlias www.filebrowser.com
DirectoryIndex filebrowser.html
DocumentRoot /home/usr/public

LogLevel info
ErrorLog ${APACHE_LOG_DIR}/FileBrowserError.log
CustomLog ${APACHE_LOG_DIR}/fileBrowser.log combined

Now just to give some insight, my router does not allow me to configure DNS however, it does allow me to assign static ip's. Also, I can only access my web server by typing in the static ip 172.16.0.6.

diya avatar
la flag
Welcome to Server Fault! In your questions and your network please refrain from using random domain names and use either your *own domain* (one can register your own for (almost) free). Or redact your own domain with one of the [RFC 6761](https://tools.ietf.org/html/rfc6761#section-6.5) reserved domain names such as `example.com`, `example.org` or similar . Please refer to [this Q&A](http://meta.serverfault.com/q/963/37681) for our recommendations with regards to how and what (not) to obfuscate in your questions.
diya avatar
la flag
When you can't set up DNS, you can use your hosts file https://en.wikipedia.org/wiki/Hosts_(file) to simulate assigning multiple different hostname to an IP-address. For Name Based virtual hosting each `ServerName` must be unique and neither server names nor aliases should overlap in different VirtualHost stanza's for the same port.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.