下載Apache
Apache的官網(http://httpd.apache.org)
1.把解壓后的Apache拷貝到要安裝的目標位置,建議拷貝到C盤根目錄下,因為這是其默認設定,
2.我選擇的是拷貝到C盤根目錄,這樣就需要對Apache組態檔C:\httpd\conf\httpd.conf進行修改,打開該檔案,將c:/Apache24全部替換成C:/httpd
3.運行cmd,進入httpd下的bin目錄,為了檢查httpd.conf有無問題,我們輸入httpd.exe -t,如果正常的話只會顯示一行Syntax OK,如果有錯的話則會告訴我們是哪兒錯了,
C:\httpd\bin>httpd.exe -t
AH00558: httpd.exe: Could not reliably determine the server's fully qualified do main name, using fe80::29b5:91f1:1dba:81be. Set the 'ServerName' directive globally to suppress this message
Syntax OK
我這里得到的錯誤資訊是說ServerName有問題,在httpd.conf中找到ServerName,原來是該設定默認是注釋掉的,去掉前面的#號,保存檔案,重新執行httpd.exe -t,測驗通過,
4.在控制臺中運行httpd.exe -k install將Apache安裝成windows服務,這樣Apache以后將自動運行,
D:\Apache24\bin>httpd.exe -k install
Installing the Apache2.4 service
The Apache2.4 service is successfully installed.
Testing httpd.conf....
Errors reported here must be corrected before the service can be started.
5.運行httpd.exe -k start啟動服務,如果沒有錯誤提示,在瀏覽器中輸入http://127.0.0.1或者http://localhost將顯示
下載php
6. 將PHP解壓后拷貝到安裝位置,我這里選擇的是C:/php,然后將php.ini-development復制并重命名為php.ini,如果是部署,則復制php.ini-production,
7. 編輯Apache的httpd.conf
查找LoadModule,在其后面增加下面配置,如果你的PHP在C盤的話,請將D:換成C:,另外注意路徑使用/,
LoadModule php7_module C:/php/php7apache2_4.dll
PHPIniDir C:/php
查找AddType,加入如下配置:
AddType application/x-httpd-php .php
查找DirectoryIndex,加入index.php,如果希望index.php優先于index.html,則將其放在前面,
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
8.保存配置,在命令列中運行httpd.exe -t檢查配置,如果沒有問題,則運行httpd.exe -k restart重啟Apache服務,
9.在Apache24\htdocs目錄下新建一個phpinfo.php檔案
** 如果有什么問題 請評論中回復,我會即使回復.謝謝,,,,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/137127.html
標籤:PHP
