Named Virtual Hosts on AWS EC2

Named virtual hosts are not enabled by default on an Amazon AMI. To enable them, edit /etc/httpd/conf/httpd.conf and uncomment line 991:

NameVirtualHost *:80

You can then begin adding your named virtual hosts in the /etc/httpd/conf.d/ directory. Below is an example of a named virtual host file:

<VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog /var/log/httpd/error_example_com.log
    CustomLog /var/log/httpd/access_example_com.log common

The difference between a named virtual host and an IP-based virtual host is that you need an additional IP address on your server for each virtual host you want to implement. Named virtual hosts come in handy when you only have 1 external IP address or if you want to host multiple websites on the same web server.