FAQ Categories

Ask A Question

Question to be answered.
Longer question text.

WWW Resources

Hosted by WestHost

Where is my php.ini file in WH 4.0?

By default we do not have access to php.ini in our 4.0 accounts at WestHost.  You can place a copy of the default php.ini file in a directory and it'll be used instead but that is not recursive. In other words it only works for that directory itself and not for any other directories including ones above it. For some that may be enough but for others they want a setup more like what we had in WH 3.0 where you could edit a single php.ini and have it affect all your public web directories. WestHost forum user skimber actually came up with a way to make the copied php.ini file recursive and I'll share that information with you here.

NOTE: I have changed location of files for my examples from those of skimber's in his post.  This is a personal prefrence of mine.  I prefer that my files for this reside in my home directory outside or below the public root.

The default file is located at /usr/local/lib/php.ini but as I mentioned we don't have access/permissions to edit the file.  We can copy it though. If you are familiar with the program Putty and want to log in via SSH to your account then you can simply issue the following command to copy the file to your home directory.

cp -i /usr/local/lib/php.ini $HOME/

The next thing we need is a .htaccess file that well tell the server where to look for the php.ini file.  You can create this file on your local computer if you like in a plain text editor like EditPlus and then upload it to /home/[username]/ or you can use the following command in SSH.

echo >> $HOME/.htaccess && sed -i -e 's/^\s*SetEnv PHPRC/#SetEnv PHPRC/i' -e "1i # WestHost 4.0 Custom php.ini\nSetEnv PHPRC $HOME/php.ini\n" $HOME/.htaccess

The above code creates the file /home/[username]/.htaccess with the following content, in case you want to create it locally and upload it.

# WestHost 4.0 Custom php.ini
SetEnv PHPRC $HOME/php.ini

You can actually combine the above two commands into one if you want and run them on a single line. Below are the commands combined into a single command on one line.

cp -i /usr/local/lib/php.ini $HOME/ && echo >>  $HOME/.htaccess && sed -i -e 's/^\s*SetEnv PHPRC/#SetEnv PHPRC/i' -e "1i # WestHost 4.0 Custom php.ini\nSetEnv PHPRC $HOME/php.ini\n" $HOME/.htaccess

That is all there is to it!  You now have your own personal php.ini file that effects only your account.  You can edit it like you did on WH 3.0 account and the changes well effect all php files located below where you initiated this. If you check out skimber's original post he actually gives you an example of the most common settings in php.ini that folks are looking to change.

Powered by Drupal, an open source content management system