Question

Setting up multiple virtual hosts with domain names

I’m trying to get my virtual hosts to work on Apache. I followed the tutorials here on this website, but for some reason both my domain names keep going to the standard Apache page instead of their own folders. I disables the 000-default.conf and enabled my own.

Here are my two configuration files:

<VirtualHost *:80>
	ServerAdmin info@insiteweb.xyz
	ServerName insiteweb.xyz
	ServerAlias www.insiteweb.xyz
	DocumentRoot /var/www/insiteweb.xyz/public_html

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
	ServerAdmin info@moviezzz.nl
	ServerName moviezzz.nl
	ServerAlias www.moviezzz.nl
	DocumentRoot /var/www/moviezzz.nl/public_html

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

Inside the folders /var/www/moviezzz.nl/public_html and /var/www/insiteweb.xyz/public_html are both an index.html file. Yet I stil get send to the standard " It works !

If you’re seeing this page via a web browser, it means you’ve setup Tomcat successfully. Congratulations!" page of apache.

Does anyone know what the problem might be?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

@hansen

I think you’re right that I have to do the redirection on Tomcat. Your code still gives a 404 and the link changes to http://insiteweb.xyz/insite-1.5.1.RELEASE. When I try the redirect without /insite-1.5.1.RELEASE it works, but it only goes to the regular Tomcat page.

For the redirect on Tomcat, do I have to set a redirect in the index.jsp of ROOT or is there another better way?

This comment has been deleted

@hansen Ok, I will use copying in the future.

And it’s a new droplet so I can reinstall it. You mean rebuild to Ubuntu 16.04 Base Image?

@martijnjansen I’ll start a new thread, since we maxed out the other one.

I would recommend that you run Apache publicly (*:80) and then do a reverse proxy to Tomcat (which will be running on a local port - let’s say 127.0.0.1:8080). That way your visitors don’t have to use a special port to access Tomcat, but will actually access Apache, which would just relay/proxy the connection to Tomcat. You only need to have Tomcat for WAR, so you’ll only use it for that.

@hansen @Woet ,

Thanks for the @ tip, I’m fairly new here.

You were right, Tomcat was still running so I stopped it. I’m getting another message now when I try to go to the website’s “ERR_CONNECTION_REFUSED”. It says the website is unavailable. The error.log shows the following:

https://gyazo.com/ba99adf2fa685f31ed585bb14bb5d9cb

Btw this is in the folder apache2, because the folder apache doesn’t exist for me.

Hi @martijnjansen I’m not sure why you’re seeing something about Tomcat, since that’s a Java web server, so I think you have both Tomcat and Apache running at the same time. Can you run this tail -50 /var/log/apache/error.log and paste that? Remember to use the @ symbol to make sure to notify people about your response.

The host files are located in /etc/apache2/sites-available/ I enabled them so now they’re also in sites-enabled. I did restart apache, always do after a change.

The command shows the following: https://gyazo.com/b001e7e2b96158a2233808c687f8e3f6

Where are your vhost files located? Did you restart apache? What does apache2ctl -S show?