Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(): Failed opening '/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24
Fastcgi and Custom php.ini – unethost無限空間虛擬主機 技術分享部落格

Fastcgi and Custom php.ini

如果主機的php是用fastcgi的方式來配置時,會發生一個現象,無法用.htaccess來修改php.ini裡的參數。這時候,就必須做一些特定的修改,才能辦到。

何時會需要修改php.ini的參數呢?一個很常見的例子,就是register_globals 。在php 4之前,這個常常是On的。但是為了安全性,php 5開始,及很多新的php套裝程式,都必須是Off才能安裝。

1) 將客製化的php.ini ( custom php.ini )移到 public_html/cgi-bin/這個資料夾下

2) 在 cgi-bin 這個資料下, 生成 php.fcgi 這個檔案,並寫入下方的內容
#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5

3) chmod +x php.fcgi

4) 上傳 .htaccess 到 public_html資料夾,並加入下方的內容
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi

5) 在php.conf中,加入path
在 /usr/local/apache/conf/php.conf 這個檔案中,加入下方的內容
Action php5-fastcgi /cgi-bin/php.fcgi
AddType application/x-httpd-php .php

6)萃取apache的conf檔,並且重新啟動之
/usr/local/cpanel/bin/apache_conf_distiller –update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart

後記:
經過我們實際上的實驗,(4)這個步驟修改.htaccess檔在某些情況下,必須省略。例如,要修改的網站,本身的空間裡有附加(attach) 子網域(subdomain) 的時候。