Difference between revisions of "Configuring php.ini"

From Hostek.com Wiki
Jump to: navigation, search
(cPanel)
 
Line 14: Line 14:
 
==Shared Hosting: Changing PHP settings for a site==
 
==Shared Hosting: Changing PHP settings for a site==
 
===cPanel===
 
===cPanel===
You can change common PHP settings for a site within the ''Select PHP Version'' section of your cPanel account.  
+
You can change your site's PHP settings in the '''Select PHP Version''' section of your cPanel.
 +
 
 +
#Login to cPanel
 +
#*Example: <nowiki>http://yourawesomedomain.com/cpanel</nowiki>
 +
#Click on '''Select PHP Version''' under the '''Software''' section.
 +
#Select PHP 5.X (which is different than "5.X '''Native'''")
 +
##Click on the '''Set as Current''' button
 +
#Tick the box next to the feature you wish to enable or disable.
 +
#Click '''Save''' on the bottom of the page.
  
#Log into your cPanel account
 
#Click the '''Select PHP Version''' icon underneath the ''Software'' heading toward the bottom of the page
 
#On the next page, click the '''Switch To PHP Options''' link in the upper-right portion of the page
 
#On the PHP Options page, click the value you wish to edit.
 
#Enter the new value for the setting you wish to adjust
 
#Click the '''Save''' button at the bottom of the page
 
 
===Windows===
 
===Windows===
 
On our Windows-based shared hosting plans, you can enable custom PHP settings within the ''PHP Settings'' icon in your MochaPanel account.
 
On our Windows-based shared hosting plans, you can enable custom PHP settings within the ''PHP Settings'' icon in your MochaPanel account.

Latest revision as of 16:59, 20 September 2016

Configuring server-wide php.ini settings

If you need to make adjustments to the php.ini file server-wide (affecting all sites on the VPS) then you could do this by logging into cPanel/WHM as root and clicking on the "PHP Configuration Editor".

Creating a custom php.ini file

Do not just create a blank php.ini file and add the settings you need. Doing this will ignore all of the other PHP configuration that was setup by the server such as extensions and modules. Be sure to copy the server's php.ini file and make the customizations in that file by following these steps.

If you need to make changes to php.ini for a specific site only follow these steps:

  1. SSH into the server
  2. Copy the server's php.ini file to the the site's public_html directory by running this command:
    cp /usr/local/lib/php.ini /home/username/public_html/
    *Replace username with the username of the site
  3. Edit the php.ini with your favorite text editor. For example:
    nano /home/username/public_html/php.ini
    and make the desired changes.
  4. Add the following to the /home/username/public_html/.htaccess file (create one if you don't have one):
     SetEnv PHPRC /home/username/public_html/php.ini
    *use the real path for your site

Shared Hosting: Changing PHP settings for a site

cPanel

You can change your site's PHP settings in the Select PHP Version section of your cPanel.

  1. Login to cPanel
    • Example: http://yourawesomedomain.com/cpanel
  2. Click on Select PHP Version under the Software section.
  3. Select PHP 5.X (which is different than "5.X Native")
    1. Click on the Set as Current button
  4. Tick the box next to the feature you wish to enable or disable.
  5. Click Save on the bottom of the page.

Windows

On our Windows-based shared hosting plans, you can enable custom PHP settings within the PHP Settings icon in your MochaPanel account.

  1. Log into your MochaPanel account
  2. Click the PHP Settings icon under the Website Settings heading
  3. Click the Configuration button next to the site/subdomain to receive the new PHP settings
  4. Check the box for Custom php.ini
  5. Click the Save button

This will place a file named php.ini in your site's web root. You may edit that file to adjust specific PHP settings. If you do not see the new settings take effect immediately, try recycling your site's application pool.