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 98.174.244.11, domain is example.com, subdomains are www and ex1 (e.g., ex1.example.com), 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 98.174.244.11 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 ex1.example.com DocumentRoot "/var/www/ex1.example.com/" </VirtualHost> <VirtualHost *:80> ServerName www.example.com DocumentRoot "/var/www/www.example.com/" </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
Namespaces
Variants
Views
Actions
Navigation