1.绑定域名:
vim /etc/hosts
添加域名:
127.0.0.1 www.aaa.com
2.打开apache的配置文件httpd.conf
cd /etc/https
vim httpd.conf
找到
#LoadModule rewrite_module modules/mod_rewrite.so
把前面#去掉。没有则添加,但必选独占一行,使apache支持 mod_rewrite 模块
找到:
<Directory "D:/ApacheServer/web">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
把
AllowOverride None 换成 AllowOverride All 使apache支持 .htaccess 文件
设置默认首页:
找到
DirectoryIndex index.html
在后面添加:
DirectoryIndex index.html index.php
3.绑定域名文件目录
cd /etc/https/extra
vim httpd-vhosts
在文件的最后添加:
<VirtualHost *:80>
ServerAdmin lwesite
DocumentRoot "D:/www/shop/public"
ServerName shop
##ErrorLog "logs/dummy-host2.example.com-error.log"
##CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
4.重新启动Apache:
/usr/local/apache/bin/apachectl restart