InMotion Hosting Support Center

In this tutorial:

When you are running a PHP file from command line, there may be times when you need to make changes to the PHP settings. In this guide we will show you how to specify the php.ini file, and change a PHP setting in command line. If you are not working in command line, you can change your PHP settings in cPanel.

Specify the php.ini File in Command Line

  1. Connect to your server using SSH.
  2. You can specify the php.ini file in command line by using the following syntax:

    php -c [Path to php.ini file] [Path to .php file]

    For example:

    php -c /home/userna5/public_html/php.ini /home/userna5/public_html/example.php

    Now the example.php file will run, with the limitations set in the php.ini file located here: /home/userna5/public_html

Change PHP settings

  1. Connect to your server using SSH.
  2. You can specify php.ini settings in command line with this syntax:

    php -c [Path to php.ini file] [Path to .php file] -d [PHP setting]

    For example:

    php -c /home/userna5/public_html/php.ini /home/userna5/public_html/example.php -d memory_limit=256M

    In this example, you can see I am setting the memory limit to 256 Megabytes. Here are some other PHP settings that are often modified:
    max_execution_time
    max_input_time
    upload_max_filesize

Congratulations, now you know how to set the php.ini file, and change your PHP settings from command line!

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

Social Media Login

   
Social Login Joomla

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
n/a Points
2016-01-28 1:27 pm

thanks for this, however how do i just change the php.ini settings from command line and not worry about defining  "[Path to .php file]"

Staff
29,997 Points
2016-01-28 1:32 pm
Hello kp,

Thank you for contacting us. You must specify the path to the .php file, or the command will not know what to run.

Thank you,
John-Paul
n/a Points
2017-09-11 3:38 pm

Is there a way to comment out a line in the php.ini file from the command prompt?

Staff
337 Points
2017-09-11 3:43 pm
Hello,

You can comment out a line in the php.ini from the command prompt by using a text editor such as nano or vim. I have included a link to a guide on how to use nano below.

http://www.inmotionhosting.com/support/website/ssh/how-to-edit-files-using-nano

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

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

4 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

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: support@InMotionHosting.com
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!