apache-虚拟主机

apche支持3种类型虚拟主机:
基于IP的虚拟主机
基于端口的虚拟主机
基于主机名的虚拟主机

一、基于IP虚拟主机

[root@localhost conf.d]# vi virtualhost.conf

Options Indexes FollowSymLinks
AllowOverride None
Require all granted



DocumentRoot /data/web1
ServerName 192.168.95.10
ErrorLog /data/web1/logs/error_log
CustomLog /data/web1/logs/access_log combined



DocumentRoot /data/web2
ServerName 192.168.95.11
ErrorLog /data/web2/logs/error_log
CustomLog /data/web2/logs/access_log combined


二、基于端口

1、修改主配置文件
#Listen 80
Listen 192.168.95.11:80
Listen 192.168.95.11:81

2、修改虚拟主机文件


Options Indexes FollowSymLinks
AllowOverride None
Require all granted


DocumentRoot /data/web1
ServerName 192.168.95.11
ErrorLog /data/web1/logs/error_log
CustomLog /data/web1/logs/access_log combined



DocumentRoot /data/web2
ServerName 192.168.95.11
ErrorLog /data/web2/logs/error_log
CustomLog /data/web2/logs/access_log combined

三、基于名称的虚拟主机


Options Indexes FollowSymLinks
AllowOverride None
Require all granted


DocumentRoot /data/web1
ServerName [www.uplook.com](http://www.uplook.com/)
ErrorLog /data/web1/logs/error_log
CustomLog /data/web1/logs/access_log combined



DocumentRoot /data/web2
ServerName [www.uplooking.com](http://www.uplooking.com/)
ErrorLog /data/web2/logs/error_log
CustomLog /data/web2/logs/access_log combined


你可能感兴趣的:(apache-虚拟主机)