LNMP中APACHE配置虚拟主机和个人主页
关掉主配置文件中的网页设置#DocumentRoot "/usr/local/apache2//htdocs"
#
# Options Indexes FollowSymLinks
# AllowOverride None
#
# Require all granted
# Require not ip 192.168.193.1
#
#
开启虚拟主机选项
Include etc//extra/httpd-vhosts.conf
基于IP的虚拟主机:
一台服务器,多个IP,搭建多个网站
vim etc/extra/httpd-vhosts.conf
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache2/htdocs/baidu"
ServerName www.baidu.com
# ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
require all granted
# ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/apache2/htdocs/xdl"
ServerName www.xdl.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
require all granted
基于端口的虚拟主机
一台服务器,一个ip,搭建多个网站,每个网络使用不同端口访问
vim etc/extra/httpd-vhosts.conf
#Listen 80
Listen 8080
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache2/htdocs/baidu"
ServerName www.baidu.com
"etc/extra/httpd-vhosts.conf" 53L, 1717C 23,1 顶端
DocumentRoot "/usr/local/apache2/htdocs/baidu"
ServerName www.baidu.com
# ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
require all granted
options Indexes
Allowoverride None
# ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/apache2/htdocs/xdl"
ServerName www.xdl.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
require all granted
options Indexes
Allowoverride None
基于域名的虚拟主机
一台服务器,一个ip,搭建多个网站,每个网站使用不同域名访问
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache2/htdocs/baidu"
ServerName www.baidu.com
页:
[1]