Browsing Tag

php.ini

Wordpress Developer

Change PHP configuration options without editing php.ini

January 2, 2018

PHP options is usually already configured at the server of your website. In many cases, the PHP configurations is set up with limited numbers that will not fit and meet your needs. For example, you can change the upload max size to increase the file size that you want to upload or the max execution time to run a script.

Normally, all of PHP settings are located in php.ini file of PHP directory on your server. However, in most cases if you are on shared host, you will not be able to find and edit this php.ini file.

Changing PHP configurations is necessary to extend that limit. And to change the PHP configuration, the easiest way is to contact the hosting service provider for support. In addition, you also can change the PHP configuration by one of three ways below.

1. Edit Theme Functions file

Some cases will be solved easily by using ini_set function to set PHP configuration from theme function file by this syntax.

@ini_set( '{option_name}' , '{value_to_set}' );

For example, if you want to change the upload_max_filesize to 64M, the completed syntax would be like this

@ini_set( 'upload_max_size' , '64M' );

Note : Not all the available options can be changed using ini_set(). There is a list of all available options in the appendix.

2. Edit htaccess file

In the root directory, you can find .htaccess file easily. And you can use this syntax to change the PHP configuration options.

php_value {option_name} {value_to_set}

For example, if you want to change the upload_max_filesize to 64M, the completed syntax would be like this

php_value upload_max_filesize 64M

And please note that these tricks may not work in some cases which hosting provider doesn’t allow to override the PHP configuration options. Then you need to contact your web hosting providers to get these changes.