Daily Archives: 2015年10月12日

CentOS 添加虚拟主机VirtualHost及伪静态Rewrite

1、找到Apache的配置文件 /etc/httpd/conf/httpd.conf

2、找到配置文件中的以下代码

LoadModule vhost_alias_module modules/mod_vhost_alias.so

如果前面有#号注释,去掉#号注释,这代表是否开启虚拟主机服务

3、找到配置文件中的以下代码,一般在配置文件的最末尾部分

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier 
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
 
#
# 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>

需要用到的部分有[……]

继续阅读