A script you want to use requires a different setting then we have set?  No problem, you can change the setting via .htaccess -- php.ini would be used in a different setup and you can take the same directives that you would need to change and apply them to the .htaccess.

To change PHP settings via .htaccess, please do the following:

  1. Edit or create a .htaccess file via file manager or a text editor (basic text editor such as notepad) -- this is a simple text file with no special requirements
  2. There are two different directive types you need to use for different setting types
    1. php_value -- Used for strings (text) and integers (numbers)
    2. php_flag -- Used for boolean settings -- true, false, on, off, 1, 0
  3. Find the value you need to use at the php.ini directive list and find what type it is.
  4. Put the setting directive in to the .htaccess with the following syntax:
    • php_value/flag setting_name value
  5. Save the .htaccess file to the directory that the script is in or one of the parent directories.  If you want this file to be global throughout all your domains and subdomains, put the .htaccess file within your home directory -- the directory that holds all your domain directories.
  6. Test your script for the new settings and you're done.

NOTE: Not all php.ini directives can be changed via .htaccess.

This article covers how to edit the php.ini.

Getting the correct php.ini file:

Log in to WHM.
Go to List Accounts.

Find the user "USER" with the domain: YOURDOMAIN.com.
Click on the cPanel icon to open the cPanel.

Go to File Manager.

Choose Web Root.

Download the file called "php.ini" onto your computer that is easily accessibly (i.e Desktop).

Uploading the php.ini file to all your accounts.

In WHM, go to List Accounts.

Type in the domain you need to enable [ EDIT ] (i.e. allow_url_fopen, memory, etc.).

Click on the cPanel icon.

Go to File Manager.

Choose Web Root.

Click on "Upload" at the top.

Choose the php.ini file you downloaded previously.

Make sure the permissions are 644.
Go back to File Manager.
Find the file ".htaccess".
Click on it and click on "Edit" at the top.

Make sure that you add these lines (USER is the user for the domain you are adding this to).

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/USER/public_html

How to Change PHP Settings in Server API - Apache Module: 

If your server is running the PHP as an "Apache Module", you can change the local PHP settings via the .htaccess file. A .htaccess file is a configuration file that you can create and use to change a lot of server settings, including local PHP settings. If you are using WordPress then you don't need to create one, as your master .htaccess file is already created by WordPress in the root directory.

[If you are not able to find .htaccess file then follow our guide How to Fix the .htaccess File Missing Problem in WordPress?]

The basic syntax you can use to change PHP settings through the .htaccess file is as follows:

php_value directive value

For example, if you wanted to change the max_execution_time from 20 seconds to 30 seconds, add the following code to your .htaccess file:

php_value max_execution_time 30

[Caution: Be sure to take a backup of your .htaccess file before making any change. .htaccess file is very critical for WordPress and any unauthorized change can break your site completely]

After editing the .htaccess and saving it, refresh your PHP info page, and you would see that the local value of that PHP settings has changed. Refer to the below image: