安裝好Apache 2.2 和 Php 5.1後,在默認的設置下是沒法正常工做的,按照
網絡教程配置好之後(
注:這裏php配置成CGI形式),有時仍會遇到一些問題。
問題:運行php文件時,出現提示「
No input file specified.」
解決:將php.ini中的 doc_root 註釋掉或者正確設置它的值爲網站的根目錄。
問題:運行php文件時,無任何顯示或顯示不正常。
解決:多是php.ini中的 extension_dir 設置不正確,沒有加載須要的模塊,通常可改成"./ext/",而後搜索"extension="將須要的模塊取消註釋。
問題:session 沒法使用。
解決:修改php.ini中的 session.save_path,將其值改成有效的目錄,如"c:/windows/temp",注意是分隔符 是"/"。
問題:運行php文件時,出現以下錯誤:
您無權查看該網頁
您可能沒有權限用您提供的憑據查看此目錄或網頁。
... ...
HTTP 錯誤 403 - 禁止訪問
解決:Apache2.2默認設置有誤,修改以下:
<Directory "/">
Options FollowSymLinks
Allow from all #修改
Order Allow,Deny #修改
AllowOverride None
Satisfy all
</Directory>
重起Apache試試。
問題:運行php文件時,出現以下錯誤:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email]admin@synchrotimes.com[/email] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache 日誌文件(error.log)中有以下提示:
Premature end of script headers: php.exe, referer: [url]http://localhost/index.php[/url]
解決:按照
網絡教程設置,通常要在Apache的配置文件httpd.conf中加入下面這一行:
Action application/x-httpd-php "/php/php.exe"
而php剛裝好時,默認的php.exe是CLI模式的,應當吧php目錄下的php.exe更名,而後把php-cgi.exe更名爲php.exe便可,也能夠把上面那一行改成:
Action application/x-httpd-php "/php/php-cgi.exe"
重起Apache試試。