標籤:
找到設定檔 httpd.conf 並用編輯器開啟。
在添加連接埠之前,我們可以查看連接埠是否已經被開啟,命令如下:
window查看連接埠:
# 查看所有連接埠
$ netstat -n -a
# 查看 8081 連接埠是否被佔用
$ netstat -aon|findstr "8081"
Mac查看連接埠:
lsof -i tcp:port
確認某個連接埠未被佔用,則設定該連接埠。我們在 httpd.conf 設定檔裡添加連接埠,並開啟虛擬機器主機。
添加連接埠:
Listen 8081
開啟虛擬機器主機:
# Virtual hosts #Include conf/extra/httpd-vhosts.conf
改為如下開啟虛擬機器主機。
# Virtual hosts Include conf/extra/httpd-vhosts.conf
儲存並關閉 httpd.conf 檔案。
然後打 conf/extra/httpd-vhosts.conf 檔案,配置連接埠資訊:
<VirtualHost *:8081> ServerAdmin [email protected] DocumentRoot "C:/PhpDocRoot/Site1" ServerName localhost ServerAlias localhost ErrorLog "logs/dummy-host.localhost-error.log" CustomLog "logs/dummy-host.localhost-access.log" common <Directory "C:/PhpDocRoot/Site1"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> </VirtualHost>
Windows下Apache連接埠配置