How to change PHP settings

You can customize PHP settings via the local configuration file .htaccess (.user.ini for Plesk). This file should be placed in a site’s root directory.

Please do not forget to save the original file before you make changes. It might help you to immediately restore the file if something went wrong.

How to edit the .htaccess file

A shared hosting service doesn’t imply changes to the system files, so you can set PHP_INI_ALL, PHP_INI_PERDIR, and PHP_INI_USER directives. You can find the full list on this page.

Before a directive name, it is required to use php_flag or php_value according to the data type a directive uses: boolean (TRUE/FALSE, 0/1, ON/OFF, etc.) or string (common text), respectively.

For example, if you’re in need to increase PHP-scripts execution time to 60 minutes, you should add the directive as follows:

php_value max_execution_time 3600

The PHP errors logging directive uses boolean data, thereby:

php_flag log_errors on

In order to make changes to .htaccess  do  as follows:

DirectAdmin

  1. Go to your client area to the “Services – My Services” section and click the “Open DirectAdmin” button;
  2. The DirectAdmin panel will be opened. Go to the “System Info & Files” section and click the “File Manager” button;
  3. Go to the “domains” folder and click the domain you want to change PHP settings for, then proceed to its public_html directory;
  4. Find the .htaccess file, move your cursor over its name, and click “Edit File” in the appeared menu;
    • If there is no .htaccess file in your domain’s public_html directory, you can create it by clicking the “Create File” button in the left menu bar. Please note that file’s name must start with a period – .htaccess
  5. Add the settings you need into the file
  6. After the needed settings are specified, click the “Save” button. Done.

How to change PHP settings

cPanel

  1. Go to your client area to the “Services – My Services” section and click the “Open cPanel” button;
  2. cPanel will be opened. Go to the “Files” section and click the “File Manager” button;
  3. Go to your site’s root directory (if it is the primary domain, go to /public_html);
  4. Right-click to .htaccess, then “Edit” > “Edit”;
    • If you can’t see .htaccess, it seems to be that you need to enable the display of hidden files. To do that, go to the “File Manager”, then click “Settings” in the upper right corner, make sure you switch on “Show Hidden Files (dotfiles)” > “Save”. If there is still no .htaccess, just create it by clicking “+File” in a site’s directory and then add the directives you need into the file. Please note that the file’s name must start with a period – ‘.htaccess’
  5. Add directives you need into the file
  6. After the needed settings are specified, click the “Save Changes” button. Done.

How to change PHP settings

ISPmanager

  1. Go to your client area to the “Services – My Services” section and click the “Open ISPmanager” button;
  2. The ISPmanager panel will be opened. Go to the “WWW-domains” menu in the left menu block, left-click a domain and then click “Directory”;
  3. Left-click to .htaccess, then “Edit”;
    • If there is no .htaccess file, you can create it yourself by clicking “Add” in a site’s directory and then add the directives you need. Please note that the file’s name must start with a period – ‘.htaccess’
  4. Add directives you need into the file (example);
  5. After the needed settings are specified, click the “OK” button. Done.

How to change PHP settings

How to check if changes have been applied

To make sure that the new values have been correctly accepted by the web server, you may create a file with .php extension (e.g. info.php) in your site’s root directory with the following data:

<?php
phpinfo();
?>

After saving the file, you need to access it with your browser through the link like your.domain/info.php and find the name of the changed directive using the search on the page (for the most popular browser, the hotkey is Ctrl+F for Windows and Cmd+F for Mac OS). In the first column in the front of a directive name, you can find the value that is set for your site. After checking is done, the PHP-file should be removed.

Rate this article
Share this article
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
In this article