Home Technical Articles How do I setup custom php.ini settings

How do I setup custom php.ini settings

by SupportPRO Admin

Most of the shared hosting servers will be running php 5 with phpSuExec enabled.And so users are not able to have php flags in their .htaccess file. Inserting php flags in .htaccess files is a common cause of internal server errors on servers with phpSuExec enabled. One way around this is to create a custom php.ini file with the php values you need.

The custom php.ini file we are creating should have the following permissions.

permission: 644

ownership: cpanelusername:cpanelusername

We can simply create a blank php.ini file and can add values that need to override. But there are security concerns with this method. PHP will revert to an absolute base configuration, which means some applications may throw a fit because certain extensions aren’t enabled. We can avoid this by copying the system php.ini. After copying the php.ini file we can enter the php configuration values that need to override on the server like upload_tmp_dir, display_errors, session.save_path, etc…

Generally when we create custom php.ini the changes will only have an effect on the scripts in the same directory. This can be changed by making the php.ini apply recursively. This is accomplished by entering the following code into a .htaccess file:

SetEnv PHPRC /home/USERNAME/public_html/php.ini

Where USERNAME is replaced with your cPanel username. This line of code would make the php configuration values in your public_html/php.ini file apply to all sub directories of where you place the .htaccess file.

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Comment