1.配置httpd.conf
禁用詞語多個端口
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive. # Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses. #Listen 12.34.56.78:80
Listen 80
Listen 8081
Listen 8082
Listen 8083 等以下內容都設置以后,可以通過netstat -n -a查看端口是否開啟
開啟虛擬站點
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
改為
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
在末尾添加
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "E:/work/web/ftp/mobile_phone/public_html"
ServerName localhost
ServerAlias 127.0.0.1
<Directory "E:/work/web/ftp/mobile_phone/public_html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
NameVirtualHost *:8081
<VirtualHost *:8081>
DocumentRoot "E:/work/web/ftp/pc_web"
ServerName localhost:8081
ServerAlias 127.0.0.1:8081
<Directory "E:/work/web/ftp/pc_web">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
但是以“localhost:8081”訪問的時候,卻發現出現了“Access forbidden!”的403錯誤,顯示沒有訪問權限。具體的錯誤信息如下:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
權限<Directory>權限配置的問題,在httpd.conf
XAMPP默認的設置是這樣的:
#<Directory />
AllowOverride none
Require all denied
</Directory>
修改成下面的就可以了!
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
順利添加完成。
