How to change php configuration on public shared server?

Posted: November 1, 2007 in PHP How to?, PHP Stuff
Tags: , ,

Many times we face problem that our application require some PHP configuration changes to run application properly. Suppose if your application requires global_registers flag off, now what to do?

On local server we are free to modify PHP configuration file (php.ini) to make necessary changes. But problem arise when we are on public shared severs. Because hosting company will not change php settings for you, because on shared server these changed will be reflected on all sites hosted on that server. They can’t change it for your individual domain. No worries here are two options to change settings of PHP on shared servers.

1. Using PHP.ini file – Simply create a new PHP.ini file with new configuration values and place it in root of your server, it will overwrite PHP settings for your domain. Eg. If you want to disable register_globals flag off then write this code in a text file named PHP.ini :

“register_globals = off”

2. Using .htaccess file – Another way is to use .htaccess file.

  • If want to change any flag attribute use this syntax :

php_flag [variable_name] [value]

eg. php_flag register_globals off

  • b. if want to change any value attribute use this syntax:

php_value [variable_name] [value]

eg. If you want to change include path – php_value include_path “.:/usr/local/lib/php:/your_include/path”

Make changes in .htaccess file and upload it on root of your server. You can cross check settings using phpinfo() function.

1) Please, note that not all PHP options can be changed using .htaccess. A list of options that can be changed using .htaccess file can be found at:

2) Option values that can be changed with .htaccess are marked with: PHP_INI_PERDIR or PHP_INI_ALL. Options marked as PHP_INI_SYSTEM cannot be changed via .htaccess files.

  1. Shaik says:

    Hi sir,

    This is Shaik, I have a problem regarding with php.ini can we chance
    ;extension=php_zip.dll to extension=php_zip.dll

  2. selectall says:

    Hello Shaik,

    Yes if you want to enable Zip File Function in your PHP installation, then you can uncomment above line,

    in php.ini and restart your webserver. Now you can use phpinfo() to check that php_zip is enabled or not.

    Hope it helped you, let me know your reply.

  3. Its great its working fine for my project …

    thanks for you help …

  4. […] After spending some more time looking into this, I discovered another WordPresser with a pretty neat solution that is a little more flexible than my original post below. Check out this link […]

  5. AHHP says:

    I created a php.ini file contents lines below:
    and put it in “/” directory. is file location right? i also put it in www directory.

    i have “/php/ext” folder on my shared server. i uploaded the php_pdo.dll and php_pdo_mysql.php from my PC to this folder BUT i have not PDO extension yet 😦

    My hosting deos not install this extension. Do you have any idea to use it?

    Thanks for great article.

  6. Endy says:

    Great post.. thanks for sharing 😀

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s