Custom PHP.ini

From DreamHost

Jump to: navigation, search

Contents

[edit] Disclaimer

The instructions provided in this article or section are considered advanced.

You are expected to be knowledgeable in the UNIX shell.

Support for these instructions is not available from DreamHost tech support.


[edit] Prepare your site file environment

x.com = domains web-root folder
$HOME = /home/username

[edit] Create a cgi-bin folder

mkdir $HOME/x.com/cgi-bin

[edit] Copy the cgi and .ini files

  • PHP5
  cp /dh/cgi-system/php5.cgi $HOME/x.com/cgi-bin/php.cgi
  cp /etc/php5/cgi/php.ini $HOME/x.com/cgi-bin/php.ini
  • PHP4
  cp /dh/cgi-system/php.cgi $HOME/x.com/cgi-bin/php.cgi
  cp /etc/php/cgi/php.ini $HOME/x.com/cgi-bin/php.ini

[edit] Set up the .htaccess file

The .htaccess file is located in your web-root at $HOME/x.com/.htaccess

Add this to run .php files with php cgi

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

[edit] Set up the cgi-bin/.htaccess file

This .htaccess file is located at $HOME/x.com/cgi-bin/.htaccess

Add this to $HOME/x.com/cgi-bin/.htaccess

Options +ExecCGI -Indexes +FollowSymLinks
<FilesMatch "php(.?)\.(cgi|ini)$">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
</FilesMatch>

[edit] Set the correct permissions

chmod 755 $HOME/x.com/cgi-bin
chmod 750 $HOME/x.com/cgi-bin/php.cgi
chmod 644 $HOME/x.com/.htaccess $HOME/x.com/cgi-bin/.htaccess $HOME/x.com/cgi-bin/php.ini

You can now modify $HOME/x.com/cgi-bin/php.ini to your heart's content!

[edit] Alternate Non-shell method

Basically just download the two files here and put them in the root of your domain:

http://dhspeedtest.com/custom_php/

It is very important that they are put in the root of your domain and not in a sub-directory. Once that is done go to:

http://domain.com/custom_php_ini.php

(be sure to change domain.com to your actual domain). When the link is visited there should be some output like this:

Usage: ./custom_php_ini.sh  

Arguments:
test: test to make sure things look good
php4: install custom php4
php5: install custom php5

Under this there should be a drop down box which has test/php4/php5 in it as well as a "Select" button.

It is suggested that the test mode is chosen first which will show which commands the script will run. If things look ok (mainly be sure that the top line is the correct path to your domain) then proceed to chose php4 or php5 for the custom install.

Once the script is done running (it should just show which files where copied) there will be an info.php on your domain:

http://domain.com/info.php

And for php4 the "Configuration File (php.ini) Path" should be to the cgi-bin directory on your domain and for PHP5 it should be the same but for "Loaded Configuration File"

Once that is done the php.ini in the cgi-bin directory in the domains folder can be edited to change the default values. Just download it via FTP and re-upload your edited version. The file can be edited with any text-editor such as wordpad/notepad. Also it is a good idea to delete both the custom_php_ini.php and .sh files from the domains directory once the custom install is completed.

Also, if you get this error message:

Warning: shell_exec() has been disabled for security reasons

Then it means the domain is using mod_php instead if cgi-based php. Either the addhandler entry in the .htaccess file needs to be manually removed (if it exists) or the domain needs to be changed to cgi-based PHP from the panel (if it is set to mod_php).

[edit] See also

[edit] External links

Personal tools