• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 623
  • Last Modified:

Apache virtualhost not working


I recently setup a server in our office running centos 6, apache, php, mysql and I've installed webmin.

Up to now it's just been running a site from the standard document root of apache, but last night I tried to setup up a virtual host, first in webmin. The domain name I was using points to the server, but I just get the servers default page. I've tried editing the httpd.conf file manually but even then I can't get the apache to server the folder I want it to server.

Just incase I've set apache as the group and owner of the folder.

I've attached a snipped of my httpd.conf file.

If I uncomment the line;
I get the following error when I restart apache
[warn] NameVirtualHost has no VirtualHosts

Does anyone know why apache wouldn't be serving the site for that specific domain?

# NOTE: NameVirtualHost cannot be used without a port specifier 
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common

<VirtualHost mydomain.com>
	DocumentRoot "/var/www/hosts/mydomain.com"
	ServerName mydomain.com
	<Directory "/var/www/hosts/mydomain.com">
	allow from all
	Options +Indexes

Open in new window

  • 2
1 Solution
SheppardDigitalAuthor Commented:
I figured this out myself.

It turns out that this line
<VirtualHost mydomain.com>

should have been

<VirtualHost *.80>
SheppardDigitalAuthor Commented:
Managed to resolve this issue myself

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now