Why You Should Update Your PHP Settings – Steps on How to Easily Do That

Dynamic websites are built on a PHP (or Hypertext Preprocessor) backbone that allows users to enjoy the comforts of the power such coding brings it. It is very flexible so that many users can utilize the code in order to create scripts that are powerful enough to give websites that unique flavor.

There are many settings available in PHP that allows users to develop scripts in to create that beautiful website they desire. Of course, like any other coding language, there are different revisions being made, and updates are consequently released.

Know Your PHP Settings

First things first, you should check out what your PHP settings currently are. What you should do is create a PHP page (you can do this using Notepad, just save it as phpinfo.php) and include the following code:

What you should see in your browser is a list of functions available for your current PHP setting. The PHP info function is useful for viewing the version of PHP you have along with other information that you can check out. Upload your file on to your dedicated server and you can check out the settings present for your PHP version. Next, consider what type of server your PHP runs on. You may either check out for CGI or Apache use by looking up “server API” in your PHP info page.

PHP continues to develop, and with some scripts requiring some settings to be used, you may want to take that step up and update your PHP settings. In that way, you can learn how to update your PHP settings in order for you to take advantage of the powerful PHP in your website.

CGI Updating

A local php.ini file is readily available for CGI-based PHP. This contains a comprehensive list of all the directives along with their values. This will provide you with easy settings update means just by modifying the code at hand. Taking the previous example, the magic_quotes_gpc value is seen in the php.ini file as the following (depending on your server settings):magic_quotes_gpc = TRUE

Should you wish to change magic_quotes_gpc from true to false, just change the values presented, save your file and refresh the page. You will notice the difference almost instantaneously.

No php.ini File?

CGI module servers loading PHP will contain this php.ini file. You can locate it in your public_html root. If you still don’t see it, you can contact your hosting provider for further support.

Apache Updating

The Apache module allows you to update your PHP settings by accessing a .htaccess file. This file’s purpose is to allow you to create and update many server settings, making it highly configurable. PHP settings are your primary goal, which you can easily modify via .htaccess. What you should be concerned with is the syntax that you should follow in your .htaccess: php_value Directive value

The php_value initiates the setting type you want to change, which in this case is the PHP settings value. The directive value is the specific setting you want modified.

For instance, if you want to change the magic_quotes_gpc from false to true, the following syntax must be followed: magic_quotes_gpc TRUE

Refreshing your PHP info page should reveal these changes. Make sure to double check for syntax, especially if you notice a 500 error appearing. This conveniently allows you to modify PHP settings from the convenience of .htaccess, which will secure you the proper provisions for your website development.

No .htaccess File?

Some servers don’t show the .htaccess automatically due to security reasons. In order to locate and modify your own, it is hidden from all files due to its nature to start by a dot (.) rather than a filename. cPanel’s File Manager conveniently provides you with a solution to show your hidden files. Just toggle the option to show hidden dot files, then reset all interface settings to view the .htaccess. If things still don’t turn out, you can create a new .htaccess quite conveniently. But, be warned that when you create one, it will overwrite the older one you have, which can compromise your code. If you’re unsure on locating your .htaccess file, contact your hosting provider in order to locate that one before creating a new one.

Making php.ini cross-directory

The nature of php.ini is that it works for the folder it is situated in. This is problematic for scripts that are run across folders, requiring the PHP settings updates to be made. A remedy for this comes in two options:

  1. You can copy your php.ini file to all the folders that require its use; or
  2. More conveniently, you can use .htaccess to force php.ini to work over all directories. The following code shall help you achieve this: suPHP_ConfigPath /home/username/public_html

Add this code at the very top of your .htaccess. Always remember that username is where you place your username that is associated with your website files. Make sure to apply the necessary measures in order to view your .htaccess file properly in order to establish this step.

Updating your PHP settings will help you obtain the goal you desire in making some PHP scripts compatible with your version of PHP. Some content management systems require PHP setting editing, so these techniques will help you out, depending on the type of PHP ran by your server. Always remember to follow the steps precisely and take note of the precautions in order to update your PHP settings conveniently for your dynamic website.

In order for a web developer to have his or her coding needs accommodated, updating the PHP settings through your Apache or CGI module can unlock the potentials for him or her to develop the website dynamically and effectively.

Brian Flores the author

Brian Flores is a SEO and copywriter for InMotion Hosting, one of the top dedicated server providers in the country. He works with a team of awesome writers to post useful tutorials on WebHostingHelpGuy. You can follow him on Twitter @WHHG_InMotion or @BrianAFlores.

Leave a Reply