Apache配置域名-繫結到指定專案目錄
1.首先,找到hosts檔案,C:\Windows\System32\drivers\etc\hosts,開啟hosts,IP指向一個域名;
2.開啟Apache配置檔案 httpd.conf,位於Apache\conf目錄下
搜尋‘LoadModule headers_module modules/mod_headers.so’,去掉前面的#號;
搜尋‘Include conf/extra/httpd-ahssl.conf’,前面加上#號;
3.Apache\conf\vhosts目錄下新建conf檔案,以指定域名命名,如圖:
4.在新建conf檔案中加入內容並儲存:
<VirtualHost *:80>
DocumentRoot "D:\env\Apache\htdocs\o2o" #專案路徑
ServerName shouxi.howy.com #指定域名
ServerAlias *.shouxi.com #二級域名
FcgidInitialEnv PHPRC "D:/env/PHP7" #PHP路徑
FcgidWrapper "D:/env/PHP7/php-cgi.exe" .php
DirectoryIndex index.html index.php
<Directory "D:\env\Apache\htdocs\o2o">
Options FollowSymLinks ExecCGI
AllowOverride All
Require all granted
</Directory>
<LocationMatch "/(Common|Conf|Extend|images|Lang|Lib|PigCms|tpl|uploads)/(.*).(php|php5|phps|asp|aspx|jsp)$">
Require all denied
</LocationMatch>
</VirtualHost>
5.重啟Apache;
6.成功。。。