InMotion Hosting Support Center

In this article we'll discuss how you can set a custom php.ini file per user when using FastCGI on your server. FastCGI is a PHP handler that is good for reducing CPU usage on a server, you might be interested in choosing the best PHP handler for your specific server needs if FastCGI isn't working well for you.

These instructions will allow you to have separate PHP configurations per user, so for instance you can set different memory limits or use opcode caching only on certain users. Please note that making these changes yourself would require root access to your server.

  1. Login to your server via SSH.
  2. Make a backup copy of your cPanel PHP wrapper script with the following command:

    cp -frp /usr/local/cpanel/cgi-sys/php5 /usr/local/cpanel/cgi-sys/php5-BACKUP

  3. Now edit the cPanel PHP wrapper script with your favorite text editor:

    vi /usr/local/cpanel/cgi-sys/php5

    By default this script should look like:


    # If you customize the contents of this wrapper script, place
    # a copy at /var/cpanel/conf/apache/wrappers/php5
    # so that it will be reinstalled when Apache is updated or the
    # PHP handler configuration is changed

    exec /usr/bin/php

  4. Above the line exec /usr/bin/php add the following code:

    [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini

    Now the cPanel PHP wrapper script should look like:


    # If you customize the contents of this wrapper script, place
    # a copy at /var/cpanel/conf/apache/wrappers/php5
    # so that it will be reinstalled when Apache is updated or the
    # PHP handler configuration is changed

    [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini
    exec /usr/bin/php

    What this does is uses the Bash syntax for seeing if a file exists [[ -f ]] and in this case we're looking for the file ~/public_html/php.ini. The ~ symbol would represent the current user calling the script, so this would be the same as entering in either /home/user1/public_html/php.ini or /home/user2/public_html/php.ini as the full path.

    The rest of the code simply executes the PHP binary at /usr/bin/php with the -c flag which sets the location where you'd like to load a php.ini from from. In this case we are telling the server we'd like to use the php.ini file inside the user's /public_html/ directory if one exists, instead of /usr/local/lib/php.ini which would be the server's default.

  5. Now you'll want to copy the cPanel PHP wrapper script to a more permanent location, so that your settings are saved if you ever recompile Apache down the road. This can be done using the following command:

    mkdir -p /var/cpanel/conf/apache/wrappers
    cp -frp /usr/local/cpanel/cgi-sys/php5 /var/cpanel/conf/apache/wrappers/php5

  6. Now restart Apache for the settings to become active:

    service httpd restart

  7. In order to verify your settings have been applied you'll want to create a PHP info script, the simplest way of doing this is simply copying any of your files to a file such as info.php, and then overwriting it with the phpinfo(); function:

    echo '<?php phpinfo(); ?>' > ~user1/public_html/info.php

    Now when you visit your website and access the newly crated info.php script, you should see your custom php.ini being loaded next to the Loaded Configuration File section

You should now know how to use custom php.ini files for your individual users when you're using FastCGI as your PHP handler.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

n/a Points
2015-11-17 1:42 am


Please create a domain via backend and create an addondomain and subdomain and park to Then change the php handler and create a custom php.ini to Kinldy attach the steps to dao that.


10,077 Points
2015-11-17 9:49 am
Hello Nithin,

If you have a hosting plan then you should already have your primary domain which I am assuming is You would follow this guide on how to add addon domains in cPanel. Here is how you add subdomains to your account, and here is how you add parked domains. If you are on anything above a shared server you can modify your PHP handler via root access. And this guide goes over creating a custom php.ini file.

Best Regards,
TJ Edens
2012-10-31 2:58 pm
Hi Jacob, I look forward to checking out the article on setting up FastCGI. I am not sure how to access EasyApache, so it's likely I've overlooked something.
9,968 Points
2012-10-30 8:48 am
Hello 3abnwebmaster,

Glad you were able to get things figured out, I'll try to update this article to more correctly reflect what things would look like on a default setup with suPHP being the PHP handler. Because you're correct, even though a phpinfo() script will show the PHP handler as CGI, you need to be sure in WHM that your handler is in fact set to FastCGI which also requires running EasyApache to be sure that FastCGI has been compiled in with Apache.

This article was intended for if you already had FastCGI up and running as your PHP handler, but it doesn't look like we have an article on getting FastCGI itself setup, so I'll work on one of those.

- Jacob
n/a Points
2015-07-10 7:40 pm



I am new to cpanel and trying to store one library. My program need one library. So I am trying to give include path for jpgraph in php.ini file, but my system is not recognizing my php.ini file. I tried to put the line you mentioned in .htaccess fie. still it is not changing.


Any help is appreciated.




31,539 Points
2015-07-13 1:18 pm
Hello Rashmi,

Thank you for contacting us. Were you able to complete Step 7above, in order to verify your settings have been applied?

Thank you,
2012-10-29 5:31 pm
I figured it out ... even though PhpInfo was reporting the PHP handler as "CGI/FastCGI", the PHP handler in WHM was set to "suphp". Once I changed that, the php5 file appeared in the location as you noted, and I was able to finish all the configuration steps.
2012-10-29 11:25 am
Hi, I am trying to follow the steps above, but am getting lost at step 1. PhpInfo reports that "Server API" is set to "CGI/FastCGI", so I think these are the steps to follow. But when I go to /usr/local/cpanel/cgi-sys, and "ls", I don't see any php5 file; the file list shows movingpage.cgi followed by randhtml.cgi -- no php file names in between. Would I want to create a php5 file there, with the contents indicated? And would it have the root/wheel ownership of all the other files listed there?

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

8 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!