Redhat Enterprise Linux (包括 CentOS Linux), 是使用最广的 Linux 服务器, 大量的网站应用都部署在其上. 1. 打开文件 /etc/httpd/conf/httpd.conf, 搜索 VirtualHost example, 找到代码如下: # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *:80> # ServerAdmin [email protected] # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> 2. 仿照例子, 添加一段代码来指定某一域名的网站. # # DocumentRoot 是网站文件存放的根目录 # ServerName 是网站域名, 需要跟 DNS 指向的域名一致 # <VirtualHost *:80> ServerAdmin [email protected]-host.example.com DocumentRoot /var/www/httpdocs/demo_neoease_com ServerName demo.neoease.com ErrorLog logs/demo.neoease.com-error.log CustomLog logs/demo.neoease.com-access.log common </VirtualHost> 3. 重启 httpd 服务, 执行以下语句. service httpd restart
Apache虚拟主机
Redhat Enterprise Linux (包括 CentOS Linux), 是使用最广的 Linux 服务器, 大量的网站应用都部署在其上.
1. 打开文件 /etc/httpd/conf/httpd.conf, 搜索 VirtualHost example, 找到代码如下:
# # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # #<VirtualHost *:80> # ServerAdmin [email protected] # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHost> |
2. 仿照例子, 添加一段代码来指定某一域名的网站.
# # DocumentRoot 是网站文件存放的根目录 # ServerName 是网站域名, 需要跟 DNS 指向的域名一致 # <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/httpdocs/demo_neoease_com ServerName demo.neoease.com ErrorLog logs/demo.neoease.com-error.log CustomLog logs/demo.neoease.com-access.log common </VirtualHost> |
3. 重启 httpd 服务, 执行以下语句.
service httpd restart |
时间: 2024-11-09 02:43:43