Custom php.ini in dreamhost

简单的说,我想安装一个东西,需要打开URL open.
我又不想就为了这个重新编译,Dreamhost的PHP.虽然以前编译过,那叫一个累,整个过程耗费1,2个小时,还一不小心就出错得四处查原因.

就Cusom php.ini吧

我想通过在.htaccess里面添加下面代码实现:

allow_url_fopen = On

但我在Dreamhost帮助系统里找到这段话

Such methods of overriding php settings will not work on Dreamhost, as it is running PHP as CGI. You *can* however, compile your own version of PHP, or use a customized php.ini file with Dreamhost’s installed PHP. Both procedures are explained in the DH wiki.

OK,那就自定义php.ini

Dreamhost Wiki 里有详细帮助文档,照葫芦画瓢就可以了.

登陆Shell,进入你想要自定义php.ini的域名目录

mkdir cgi-bin
cd cgi-bin

复制相关文件.

cp /dh/cgi-system/php5.cgi php.cgi
cp /etc/php5/cgi/php.ini php.ini

在.htaccess里面加上下面内容:

AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

最后设置权限 (必须设置,否则出错)

chmod 644 ../.htaccess
chmod 755 ../cgi-bin
chmod 750 php.cgi
chmod 644 php.ini

编辑php.ini

vim php.ini

进入vim编辑器后,按 “/ ” 然后输入 “allow_url_fopen” (均不含引号) ,回车,则自动定位到相关设置处,按” i “进入编辑模式,把’allow_url_fopen = Off” 修改为 “allow_url_fopen = On” 即可.

你也可以编辑其它php.ini选项.

现在用phpinfo() 看看效果吧 ^_^

Nite: 所有.htaccess ,php.ini的编辑过程都建议用 Shell在线编辑,不建议本地编辑后FTP上传,否则容易出错

1 Response to “Custom php.ini in dreamhost”


Comments are currently closed.