First time LAMP and domain setup on CentOs. Previous experience of this is in Ubuntu. Working on a dedicated server package of my local ISP. They installed default CentOs 6.2 and redirected my domain to the server. Pinging mydomain.com works fine to reach the server's IP.

I have successfully installed LAMP on the box using this howto explanation. All seems fine.

I have edited /etc/hosts:      mydomain.com

I have also edited the /etc/httpd/conf/httpd.conf and added the following at the end of the file, while keeping the rest default:

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName localhost

<VirtualHost *:80>
        ServerName mydomain.com
        ServerAlias www.mydomain.com
        ServerAdmin myemailaddress@email.com
        DocumentRoot /var/www/html/mydomain.com
        <Directory "/var/www/html/mydomain.com">
                Options Includes FollowSymLinks
                AllowOverride All
                allow from all
        ErrorLog /var/www/logs/mydopmain.com.default.log

And i also ran

chmod -R apache:apache /var/www/html

as a final attempt to get things going.

Both /var/www/html and /var/www/html/mydomain.com contain a basic index.php so that i can test that everything works.

The problem i get is when i try access the domain via the browser i get an "The connection has timed out: The server at mydomain.com is taking too long to respond."

Ubuntu used the sites-available and sites-enabled, so i am not sure if i am missing a setup somewhere or if something is missing from the ISP side?

Does anyone know how to setup virtualHosts on CentOs 6.2 for apache2?

Thank you, David

2 Answers 2


Verify that Apache is actually running:

ps -FC httpd

And listening on port 80:

sudo netstat -tlnp | grep httpd

And that you've allowed connections to port 80:

sudo system-config-firewall-tui
  • Many Thanks! After installing and using 'system-config-firewall-tui' I found that only SSH access was allowed but not HTTP. Enabling HTTP lead to my main index.php loading with success. So on to the next thing to get running! :P Jun 26, 2012 at 18:11

I believe CentOS has a firewall enabled by default. 'sudo /sbin/service iptables off' to completely disable it (this has security implications!).

When using name-based virtual hosting, if there is a name mismatch, the first defined virtual host will be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.