I'm having an odd issue with virtual hosts on my Apache server. They simply don't work, without any errors at all. I have looked in any guides I can find and read any forums I can find on this topic, but I don't find anything useful, or anything I'm doing wrong.
The virtual host configuration file is exactly as shown in the guides I've found. I have tried to change the folder in the default configuration file, just to check that it loads the website in this folder. This works. But when I create a new virtual host file, enter the path to the folder which contains the working website, enable the virtual host and finally restart the Apache2 service, I get the "website not found" message.
So, there is access to the folder and files where the website is. Any clue on how to figure out what's wrong?
The only thing I hate in Linux is when it just don't work, and no errors are given...
it might not display any errors to stdout, but have you checked the logs?
Thanks for the very quick answer. I'm not sure on what log files to check, and where they are located.
Oh. I found the error log. It says the following:
[Thu Apr 20 18:07:28.158389 2017] [core:notice] [pid 7256:tid 139622655655424] A
AH00094: Command line: '/usr/sbin/apache2'
on Debian based systems, its in /var/log/apache2
When i try to access the folder /var/log/apache2, I get a permission denied. Sudo cd /var/log/apache2 don't work for some reason.
ls -l /var/log | grep apache2
It should show what has access to this directory. Most often times its root and adm.
8 (edited by Jonnyboy1991 2017-04-24 12:33:55)
Can you post what you have in your configuration file? that might help us to see what is going on. Your DocumentRoot directive is the one which should have your directory path to serve all of your files from. Also, the reason why your default virtual host is working is it might have your defaults say as ServerName and Server Alias. without anything in them. So, check your host file and see if your ServerName and ServerAlias is in there. if you want the www.yourdomainname.com to to work, then that's what you would do with your ServerAlias and put that in there.
I hope this helps. I've been working with Linux systems for a while now so yeah.
edit: Note: the ServerName should have your domain as "domainname.com" or whatever you have your domain set to.