我已經從原始程式碼編譯了 PHP 並將其安裝到/opt/php/5.5.15/
我還安裝了 (with yum
)httpd
和mod_fcgid
.
我正在嘗試配置虛擬主機來執行 php,如下所示:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/my-site.example.com/site/public
ServerName my-site.example.com
ErrorLog /var/www/my-site.example.com/logs/my-site.example.com-error_log
CustomLog /var/www/my-site.example.com/logs/my-site.example.com-access_log common
<Directory /var/www/my-site.example.com/site/public>
Options +indexes
AllowOverride all
Order allow,deny
Allow from all
Action application/x-httpd-php /php-5.5.15-bin/php-cgi
</Directory>
</VirtualHost>
<IfModule mod_fcgid.c>
IdleTimeout 3600
ProcessLifeTime 7200
MaxProcessCount 64
DefaultMaxClassProcessCount 8
IPCConnectTimeout 300
IPCCommTimeout 7200
BusyTimeout 300
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
ScriptAlias /php-5.5.15-bin/ /opt/php/5.5.15/bin/
<Directory "/opt/php">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</IfModule>
我收到此錯誤:
[Thu Aug 14 17:36:20 2014] [error] [client 127.0.0.1] (13)Permission denied: exec of '/opt/php/5.5.15/bin/php-cgi' failed, referer: http://my-site.example.com:10080/
[Thu Aug 14 17:36:20 2014] [error] [client 127.0.0.1] Premature end of script headers: php-cgi, referer: http://my-site.example.com:10080/
我已經嘗試過chmod 777 php-cgi
了chown apache:apache php-cgi
,兩者都沒有什麼區別。
有任何想法嗎?
注意:此設定在 Debian 上運作良好
答案1
所以事實證明 SELinux 拒絕了 php-cgi bin 上的 httpd 執行權限。
查看 /var/log/audit/audit.log 顯示了這一點。
運行以下命令可以實現:
sudo chcon -t httpd_sys_script_exec_t /opt/php/5.5.15/bin/php-cgi