Apache's default document root not working

Hi all,

I have just installed and configured Apache on our new Linode which runs CentOS 6.

I also configured virtual hosts and it is working fine.

I have also installed and configured MySQL and PHP.

However, I have uploaded some applications like mysql to the default apache document root:

/var/www/html

but navigating via our server's IP this way: http://123.123.123.123/phpmyadmin

brings up:

"Not Found

The requested URL /phpmyadmin was not found on this server."

almost as if it is not calling up the default apache document root.

Could I have been doing something wrong?

To my undersanding, virtual hosts should not affect the default document root. Is this thinking right?

Thanks in advance for your help.

5 Replies

Do you have a VirtualHost block with 123.123.123.123 as either ServerName or ServerAlias? If not, then Apache will route requests for 123.123.123.123 to the first VirtualHost block it finds, which might not be the one you think.

Thanks @hoopycat.

Here's what the VirtualHost section of my Apache configuration file looks like:

ServerAdmin webmaster@mysite1.com

DocumentRoot /var/www/vhosts/mysite1.com/httpdocs/

ServerName mysite1.com

ServerAlias www.mysite1.com

AllowOverride all

ErrorLog logs/mysite1.com-error_log

CustomLog logs/mysite1.com-access_log common

ServerAdmin webmaster@mysite2.com

DocumentRoot /var/www/vhosts/mysite2.com/httpdocs/

ServerName mysite2.com

ServerAlias www.mysite2.com

AllowOverride all

Thanks.

It sounds like it is most likely treating "unknown" destinations as being part of mysite1.com, the first VirtualHost listed. A fix for this is to create a 'default' vhost, with perhaps ServerName localhost or some other generic thing, and put what you want for unknown destinations in there. Make sure it loads first: if you're using the sites-enabled directory structure, make the file come first in alphabetical order when you do an 'ls'.

Thanks @hoopycat.

It seems to be working fine now…

Here's what the virtual host section of my httpd.conf file now looks like:

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html/

ServerName localhost

ServerAlias http://localhost/

AllowOverride all

ErrorLog logs/localhost-error_log

CustomLog logs/localhost-access_log common

ServerAdmin webmaster@mysite1.com

DocumentRoot /var/www/vhosts/mysite1.com/httpdocs/

ServerName mysite1.com

ServerAlias www.mysite1.com

AllowOverride all

ErrorLog logs/mysite1.com-error_log

CustomLog logs/mysite1.com-access_log common

ServerAdmin webmaster@mysite2.com

DocumentRoot /var/www/vhosts/mysite2.com/httpdocs/

ServerName mysite2.com

ServerAlias www.mysite2.com

AllowOverride all

However, what did you mean by "if you're using the sites-enabled directory structure, make the file come first in alphabetical order when you do an 'ls'."?

How does that work (i.e a site enabled directory structure)?

Thanks a lot for your help.

Regards,

I don't believe CentOS uses it, so it doesn't apply in this case. Basically, each virtual host would get its own file in a directory called /etc/apache2/sites-available/, and then symlinks are created from /etc/apache2/sites-enabled/ to each of those files. But don't sweat it. :-)

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