How to host multiple subdomains with a single IP address on a Linux Apache Server

Jump to: navigation, search

Assumptioms: Linux, Apache2, Godaddy Registrar, Static WAN IP of, domain is, subdomains are www and ex1 (e.g.,, your webfiles are in /var/www/. For CentOS the default is /var/www/html/. Steps 1-5 are completed on your registrar. 1) On godaddy, click _domain details_. 2) Click _edit_ on your Name Server and park your domain. 3) Launch the DNS manager. 4) Set A(Host): Set the HOST to @ and POINTS TO to 5) Set CNAME(Alias): Set the HOST to ex1 and POINTS TO to @ Steps 6-8 are completed on your Linux server. 6) add the following lines to /etc/apache2/httpd.conf (/etc/httpd/conf/ is path on CentOS) NameVirtualHost *:80 NameVirtualHost *:443 <VirtualHost *:80> ServerName DocumentRoot "/var/www/" </VirtualHost> <VirtualHost *:80> ServerName DocumentRoot "/var/www/" </VirtualHost> 7) Restart Apache. sudo /etc/init.d/apache2 restart For CentOS. sudo /sbin/service httpd restart 8) investigate any errors reported when restarting apache

See also

Personal tools