Basic overview
Virtual Web Host
Run multiple Web sites on the same server, each of which does not occupy a single real computer
HTTPD supported virtual host types
- Domain-based virtual host
- IP address-based virtual host
- Port-based virtual host
Modify the Master profile for the httpd service
Enables Apache services to load a standalone configuration file
Vim/usr/local/httpd/conf/httpd.conf
1 # Virtual hosts 2 Include conf/extra/httpd-vhosts.conf // Remove Annotations
Domain-based web hosting
Vim/usr/local/httpd/conf/extra/httpd-vhosts.conf #修改独立的配置文件
1Namevirtualhost192.168.10.1: the2 3<directory'/www'>//control access to the entire virtual host directory4 Order Allow,deny5 allow from all6</Directory>7 8<virtualhost192.168.10.1>//First Web site9DocumentRoot"/www/spdir" //Site root directoryTenServerName www.spdir.com//the full domain name of the website OneErrorlog"Logs/www.spdir.com-error_log" //error log storage location ACustomlog"Logs/www.spdir.com-access_log"Common//Access log storage location -</VirtualHost> - the<virtualhost192.168.10.1>//a second website -DocumentRoot"/www/tt80" - ServerName www.tt80.com -Errorlog"Logs/www.tt80.com-error_log" +Customlog"Logs/www.tt80.com-access_log"Common -</VirtualHost> + A atThird website ...
httpd-vhosts.conf File Contents
Service httpd Restart #重新启动httpd
Port-based Web virtual host
Vim/usr/local/httpd/conf/extra/httpd-vhosts.conf #修改独立的配置文件
1Namevirtualhost192.168.10.12 3<directory'/www'>//control access to the entire virtual host directory4 Order Allow,deny5 allow from all6</Directory>7 8<virtualhost192.168.10.1: the>//First Web site9DocumentRoot"/www/spdir" //Site root directoryTenServerName www.spdir.com//the full domain name of the website OneErrorlog"Logs/www.spdir.com-error_log" //error log storage location ACustomlog"Logs/www.spdir.com-access_log"Common//Access log storage location -</VirtualHost> - the<virtualhost192.168.10.1:8080>//a second website -DocumentRoot"/www/tt80" - ServerName www.tt80.com -Errorlog"Logs/www.tt80.com-error_log" +Customlog"Logs/www.tt80.com-access_log"Common -</VirtualHost>
httpd-vhosts.conf File Contents
Service httpd Restart #重新启动httpd
Apache Virtual Host