一、apache 安裝配置:
1.安裝apache
1.1 下載地址:https://www.apachelounge.com/download/
1.2 將下載的文件解壓到你想安裝的目錄 D:\WAMP
2.配置apache(D:\WAMP\Apache24\conf\httpd.conf)
2.1 修改ServerRoot(服務器路徑) 改為apache的安裝目錄 ServerRoot "D:/WAMP/Apache24"
2.2 修改ServerName(服務器名稱) #ServerName www.example.com:80這是Apache的服務器地址,把前面的"#"去掉,把"www.example.com"改成"localhost"
2.3 修改 DocumentRoot(網站的根目錄) DocumentRoot "c:/Apache24/htdocs" 改為D:/WAMP/Apache24/www 同時修改htdocs文件夾名稱為www
2.4 修改 DocumentRoot 下的<Directory "c:/Apache24/htdocs"> 改成<Directory "D:/WAMP/Apache24/www">
2.5 修改ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/" 為ScriptAlias /cgi-bin/ "D:/WAMP/Apache24/cgi-bin/"
2.6 修改 <Directory "c:/Apache24/cgi-bin"> 為<Directory "D:/WAMP/Apache24/cgi-bin">
3.注冊和卸載apache服務
3.1 注冊服務
開始----運行-----cmd,進入apapche的bin目錄下,執行命令:httpd.exe -k install -n "Apache24"
3.2 卸載服務(先要停止這個服務)
開始----運行-----cmd,進入apapche的bin目錄下,執行命令:httpd.exe -k uninstall -n "Apache24"
二、php 安裝配置:
1.安裝php
1.1 下載地址:http://php.net/downloads.php
1.2 將下載的 zip 文件解壓到指定目錄,比如將其解壓到 D:\WAMP\php7.2
2.配置php(D:\WAMP\Apache24\conf\httpd.conf)
2.1 配置httpd.conf
2.1.1 添加PHP模塊
查找"Dynamic Shared Object (DSO) Support"的部分。大概是在62行附近。並在最后追加如下代碼:
LoadModule php7_module D:/WAMP/php7.2/php7apache2_4.dll
2.1.2 添加擴展名
查找"AddType"的部分。大概是在409行附近,並在最后追加如下現行代碼:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
2.1.3 指定php.ini配置文件路徑
在httpd.conf文件里指定PHP配置文件php.ini的目錄,這里定位到httpd.conf文件的未尾,在文本最后面一行添加如下代碼:
PHPIniDir "D:/WAMP/php7.2"(這里的"D:/WAMP/php7.2"為php.ini文件存放的實際路徑)
2.1.4 配置DirectoryIndex
查找"DirectoryIndex"的部分,大概在282行,在DirectoryIndex的后面追加一個"index.php"