本文以apache爲例,敘述如何配置虛擬主目錄。
他有什麼作用呢,配置了他,訪問標好的域名時,可以訪問特定的目錄層級,比如直接訪問/www下的某個文件夾.
步驟:
1.打開相關配置;
2.對vhost配置文件進行參數配置,複製即可
3.重啓apache
1. sudo vim /etc/apache2/httpd.conf
開啓php模塊,去掉前邊的分號
2。
打開引入vhost文件.
sudo vi /etc/apache2/extra/httpd-vhosts.conf
輸入下面代碼:
<VirtualHost *:80>
ServerName www.mall.com [此處需修改成你的]
DocumentRoot "/Library/WebServer/Documents/mall"[此處需修改成你的]
<Directory "/Library/WebServer/Documents/mall">[此處需修改成你的]
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.php
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Library/WebServer/Documents"[此處需修改成你的]
<Directory "/Library/WebServer/Documents/mall">[此處需修改成你的]
Options FollowSymLinks IncludesNOEXEC Indexes
DirectoryIndex index.html index.htm index.php
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
3.重啓apache