PHP开发环境搭建--Windows
本文目錄
- 準備
- 開始
- PHP
- Apache 此處參考1 參考2
- MySQL
- 錯誤錦集
- 附httpd命令
搭建php開發環境有兩種方式,一種是自定義搭建;另一種是使用php服務組件,PHP服務器組件非常多有WampServer、XAMPP、AppServ、phpStudy、phpnow等。
本文介紹 自定義搭建
①準備
需要三個軟件:php,apache,mysql,要根據系統位數下載對應版本,下載地址如下:
| php | http://windows.php.net/download/ |
| apache | http://www.apachelounge.com/download/ |
| mysql | https://www.mysql.com/downloads/ |
②開始
解壓下載到的php、apache和mysql的壓縮包,這三個是綠色軟件,最好放在同一磁盤同一文件夾下。
Ⅰ.PHP
保存路徑隨意,建議和apache等統一存放。
Ⅱ.Apache 此處參考1 參考2
假設apache的安裝路徑在“D:\Apache\Apache24”
修改apache服務器的配置文件,即D:\Apache\Apache24\conf\httpd.conf文件。
修改完畢可以啟動apache。
建議不要用apache文件中bin目錄下的ApacheMonitor.exe啟動apache,因為這樣如果有錯誤不能知道錯誤的具體信息。
建議使用命令行,切換到apache安裝目錄下的bin目錄,運行”httpd.exe -k install ( -n “Apache Server2.4” 可以不用,防止錯誤,建議寫全 )“,如果沒有報錯,則打開瀏覽器并輸入http://localhost:8080,如果看到“it works”,則表明apache安裝成功。
確定apache安裝成功后開始關聯php。依然在httpd.conf文件中添加下面幾行,增加對php7的支持,添加位置在LoadModule的底部,代碼如下:
重啟Apache服務器(用命令行,httpd -k restart),在地址欄輸入 localhost 看到PHP相關配置,說明配置成功。
Ⅲ.MySQL
保存路徑隨意,建議和apache等統一存放。
tips.如果安裝Navicat管理數據庫,建議安裝路徑改為D盤,不要使用網上的注冊機注冊軟件,不知道是不是失效了,有一個破解工具,打開工具找到Navicat主程序文件就可以破解了。
③錯誤錦集
Installing the ‘Apache2.4’ service
(OS 5)拒絕訪問。 : AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?
打開運行,輸入cmd,回車,開啟apache時出錯,應該不是以管理員身份運行權限不夠造成的,windows10使用Windows PowerShell(管理員),就冇問題了
[Sun Jul 30 10:17:42.045393 2017] [mpm_winnt:error] [pid 3220:tid 424] (OS 2)系統找不到指定的文件。 : AH00436: No insta
lled service named “Apache2.4”.
服務名稱寫錯了,應該是“Apache Server2.4”
httpd : 無法將“httpd”項識別為 cmdlet、函數、腳本文件或可運行程序的名稱。請檢查名稱的拼寫,如果包括路徑
確,然后再試一次。
所在位置 行:1 字符: 1
+ httpd -d restart
+ \~\~\~\~\~
+ CategoryInfo : ObjectNotFound: (httpd:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+
Suggestion [3,General]: 找不到命令 httpd,但它確實存在于當前位置。默認情況下,Windows PowerShell 不會從
。如果信任此命令,請改為鍵入“.\httpd”。有關詳細信息,請參閱 “get-help about_Command_Precedence”。
Windows PowerShell 給出了建議,最前面添加“.\”
httpd.exe: Could not open configuration file restart/conf/httpd.conf: \xcf\xb5\xcd\xb3\xd5\xd2\xb2\xbb\xb5\xbd\xd6\xb8\x
b6\xa8\xb5\xc4\xc2\xb7\xbe\xb6\xa1\xa3
仔細查看發現,是命令敲錯了,“.\httpd.exe -d restart -n “Apache Server2.4””中“-d”應該是“-k”,注意默認服務名稱是“Apache2.4”,也會報錯,要寫-n “Apache Server2.4”
④附httpd命令
Usage: D:\\apache\\apache24\\bin\\httpd.exe [-D name] [-d directory] [-f file][-C "directive"] [-c "directive"][-w] [-k start|restart|stop|shutdown] [-n service_name][-k install|config|uninstall] [-n service_name][-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X] Options:-D name : define a name for use in <IfDefine name> directives -d directory : specify an alternate initial ServerRoot -f file : specify an alternate ServerConfigFile -C "directive" : process directive before reading config files -c "directive" : process directive after reading config files -n name : set service name and use its ServerConfigFile and ServerRoot -k start : tell Apache to start -k restart : tell running Apache to do a graceful restart -k stop|shutdown : tell running Apache to shutdown -k install : install an Apache service -k config : change startup Options of an Apache service -k uninstall : uninstall an Apache service -w : hold open the console window on error -e level : show startup errors of level (see LogLevel) -E file : log startup errors to file -v : show version number -V : show compile settings -h : list available command line options (this page) -l : list compiled in modules -L : list available configuration directives -t -D DUMP_VHOSTS : show parsed vhost settings -t -D DUMP_RUN_CFG : show parsed run settings -S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG -t -D DUMP_MODULES : show all loaded modules -M : a synonym for -t -D DUMP_MODULES -t -D DUMP_INCLUDES: show all included configuration files -t : run syntax check for config files -T : start without DocumentRoot(s) check -X : debug mode (only one worker, do not detach)總結
以上是生活随笔為你收集整理的PHP开发环境搭建--Windows的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 汉字 计算机 坟墓,墓字的意思4、墓的繁
- 下一篇: 你做一篇微信公众号文章要多久?