Red Hat & CentOS – Setting Up Virtual Hosts


For this quick and simple example, I will enable Virtual Hosts and configure itsmetommy.com to point at /var/www/itsmetommy.com/public_html/.

# vi /etc/httpd/conf/httpd.conf
virtualhost-itsmetommy
# mkdir /var/www/itsmetommy.com
# mkdir /var/www/itsmetommy.com/public_html/

Add the below line to /private/etc/apache2/extra/httpd-vhosts.conf or you will get the below error when restarting httpd.

ServerName localhost

“Starting httpd: httpd: apr_sockaddr_info_get() failed for YOURHOSTNAME
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName”

Example of the error:

httpd-start-error

Restart httpd

# service httpd restart