天天看點

使用XAMPP建立PHP運作環境

1、下載下傳

從這裡下載下傳自己需要的版本。(我的生産環境用5.6.x 、7.x.x還有很多成熟的程式不支援)

https://sourceforge.net/projects/xampp/files/XAMPP%20Windows/

如果你選擇的xampp-win32-XXX-VCXXX.zip或xampp-win32-XXX-VCXX.7z,如出現VCRuntime錯誤請在下載下傳對應的

VC11, VC14 or VC15 (Visual Studio 2012, 2015 or 2017 compiler respectively)

https://windows.php.net/

2、安裝

如果你下載下傳的是安裝版直接輕按兩下,按向導執行就可以了。

輕按兩下:xampp-win32-XXX-XXX-installer.exe

如果你下載下傳的是xampp-win32-XXX-VCXXX.zip或xampp-win32-XXX-VCXX.7z,直接解壓到指定盤符下就可以了。(我一般用D盤 )

3、運作

打開盤符:xampp目錄運作xampp-control.exe就可以了。

4、端口問題

在檔案D:\xampp\apache\conf\httpd.conf中将Listen 80 改為你自己想用的端口号,可綁定IP,如:Listen 12.34.56.78:87。

5、多域名

想設定多域名請改檔案D:\xampp\apache\conf\extra\httpd-vhosts

#啟用這句

NameVirtualHost *:80

#保留本地預設站

<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/xampp/htdocs/"

    ServerName localhost

    ErrorLog "logs/localhost-error.log"

    CustomLog "logs/localhost-access.log" common

</VirtualHost>

#

<VirtualHost *:80>

    ServerAdmin [email protected]

    DocumentRoot "/xampp/htdocs/xampptest"

    ServerName xampptest.com

    ServerAlias www.xampptest.com

    ErrorLog "logs/xampptest.com-error.log"

    CustomLog "logs/xampptest.com-access.log" common

</VirtualHost>

如果沒有自己的域名可以用notepad++修改檔案

C:\Windows\System32\drivers\etc\hosts

加入

127.0.0.1       www.xampptest.com