一、前言
安裝完成XAMPP后,瀏覽器輸入localhost或127.0.0.1,若遠(yuǎn)程服務(wù)器,替換對應(yīng)IP地址即可。因瀏覽網(wǎng)頁服務(wù)默認(rèn)的port都是80,因此只需輸入網(wǎng)址即可,不用輸入“:80”了,?
?
XAMPP默認(rèn)指向的文件地址是安裝目錄下的htdocs文件夾
##找到C:\xmapp\apache\conf
目錄(默認(rèn)安裝路徑,若自定義安裝路徑,應(yīng)該將C:\xmapp\替換為你的自定義路徑
)下的httpd.conf
文件,打開httpd.conf
文件,將L252?的DocumentRoot "C:/xampp/htdocs" <Directory "C:/xampp/htdocs">做對應(yīng)修改##
二 、步驟
1.C:\xampp\apache\conf\extra
文件夾下打開httpd-vhosts.conf
文件的最后添加如下代碼并保存
注:直接添加導(dǎo)致Apache啟動失敗,文末附error的解決方法。
<VirtualHost *:80>
? ? DocumentRoot "C:\xampp\htdocs\project1202"
? ? ServerName phppj.cn
</VirtualHost>
注:DocumentRoot 后面的"C:\xampp\htdocs\project1202"就是添加的php練習(xí)項目的目錄
? ? ? ?ServerName訪問域名地址為:phppj.cn
2.然后找到電腦的hosts文件C:\Windows\System32\drivers\etc下的hosts文件,添加127.0.0.1 phppj.cn,保存。
3.重新啟動xampp的Apache
注:當(dāng)xampp的Apache啟動為services時,計算機重新啟動,通常Apache已經(jīng)啟動;而僅在每次使用時點擊“start”的方式,則需在每次使用前點擊“start”
三、重啟出錯的解決
23:02:05 ?[Apache] ?? ?Status change detected: stopped
23:02:05 ?[Apache] ?? ?Error: Apache shutdown unexpectedly.
23:02:05 ?[Apache] ?? ?This may be due to a blocked port, missing dependencies,?
23:02:05 ?[Apache] ?? ?improper privileges, a crash, or a shutdown by another method.
23:02:05 ?[Apache] ?? ?Press the Logs button to view error logs and check
23:02:05 ?[Apache] ?? ?the Windows Event Viewer for more clues
23:02:05 ?[Apache] ?? ?If you need more help, copy and post this
23:02:05 ?[Apache] ?? ?entire log window on the forums
修改測試,將
<VirtualHost *:80>
? ? DocumentRoot "C:\xampp\htdocs\deeplearn"
????ServerName phpdeep.cn
</VirtualHost>
<VirtualHost *:80>
????DocumentRoot "C:\xampp\htdocs\project1202"
????ServerName phppj.cn
</VirtualHost>
修正為:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\deeplearn"
ServerName phpdeep.cn
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\project1202"
ServerName ?phppj.cn
</VirtualHost>
即將標(biāo)簽VirtualHost間的內(nèi)容頂格與標(biāo)簽左對齊,Apache啟動正常。
至此,XAMPP面板下Apache多項目站點測試完成,功能正常實現(xiàn)。
下圖為C:\xampp\htdocs\deeplearn下index.html的內(nèi)容,瀏覽器地址欄直接輸入phpdeep.cn,顯示index.html網(wǎng)頁的內(nèi)容。文章來源:http://www.zghlxwxcb.cn/news/detail-819039.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-819039.html
到了這里,關(guān)于用XAMPP搭建PHP服務(wù)器,配置部署多個項目的過程(附blocked port error解決方法)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!