Apache-2.2

10.6 伺服器 - PHP 不工作

  • January 21, 2011

嘗試在 10.6.6 伺服器中啟用 PHP 並不斷載入 php 文本(我可以在我的 .php 文件中看到 php 程式碼)。

我已經在伺服器管理員中啟用了 php5 模組(並驗證了它在 httpd.conf 中).. 還有什麼我可以嘗試的嗎?

替代文字

我也吹掉了目前的httpd.conf,重新開始,沒有運氣….

原來我使用的是 php 短標籤,並沒有在 php.ini 中打開它:

; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It's been
; recommended for several years that you not use the short tag "short cut" and
; instead to use the full <?php and ?> tag combination. With the wide spread use
; of XML and use of these tags by other languages, the server can become easily
; confused and end up parsing the wrong code in the wrong context. But because
; this short cut has been a feature for such a long time, it's currently still
; supported for backwards compatibility, but we recommend you don't use them.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = On

您還需要確保執行 php 程式碼的配置到位

AddHandler php5-script .php
AddType text/html .php

引用自:https://serverfault.com/questions/224144