Apache change configuration file (php ini path)

Imagine you are given a server and you are asked to change its PHP settings. Also, assume that several different versions of PHP are installed on this server. What do you think is the best way to find a PHP configuration file? You will find the answer to this question below.

Method 1 (phpinfo file): #

One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php

<?php
phpinfo();
?>

Load this file in your browser, press CTRL + F and search for “Loaded Configuration File”. You should see something like.

Apache change configuration file (php ini path)

This will tell you the exact location of the php.ini file you want to edit.

Method 2 (PHP.ini & grep command) #

In Linux, run this command to locate the PHP.ini configuration file.

 $ php -i | grep "Loaded Configuration File" 

Or better way:

 $ php -i | grep ini 

Or in Windows Command Line:

 $ php -i | findstr /c:"Loaded Configuration File"

The result should be something like this.

 $ Loaded Configuration File =&gt; /etc/php/7.4/cli/php.ini

Method 3 (locate command) #

Using the locate command in Linux. If it’s not already installed, run sudo apt install mlocate [On Debian/Ubuntu] and sudo yum install mlocate [On CentOS/RHEL]

 $ locate php.ini

You should see a list of php.ini files here.

How install PHP extension (like Zip) on Cantos / Ubuntu / Linux

Overview

For Shared Hosting, the .user.ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. This file is located on your server in the /public_html folder. The following article will provide instruction on how you can locate and edit this file. Before making any changes, it's a good idea to copy the original settings, both for reference and to easily restore the original if necessary.

STATEMENT OF SUPPORT:
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support. Before making any changes, it's a good idea to copy the original settings, both for reference and to easily restore the original if necessary.

Before Starting

This guide will be using cPanel's File Manager to edit the .user.ini file. In order to complete this guide, you will want to update your File Manager settings to Show Hidden Files on your Shared Hosting server.

  1. Log into your Media Temple account.
  2. Click the blue ADMIN button associated to your Shared Hosting server.
    Apache change configuration file (php ini path)
  3. While in the dashboard, click File Manager.
    Apache change configuration file (php ini path)
  4. You should be automatically warped to the public_html folder.
  5. If you have not yet created a .user.ini file, you can do so at this time by clicking
    Apache change configuration file (php ini path)
    .
  6. Select the .user.ini file. Then click the Edit icon.
    Apache change configuration file (php ini path)
  7. Add your desired php changes, then click Save Changes.
    Apache change configuration file (php ini path)

READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support. Before making any changes, it's a good idea to copy the original settings, both for reference and to easily restore the original if necessary.

.user.ini

On the WordPress Hosting service, php directives would need to be adjusted within the .user.ini file. Note, this is different from the typical php.ini file seen in most of (mt) Media Temple servers. If this is the first time you are trying to modify these limits, you will need to create a file named ".user.ini" within the document rootdocument root or ".../html" directory using the File Manager, FTP or SSH.

PHP directives

Once the .user.ini file is created within ".../html" you may input your desired php directives. We recommend checking out our additional articles on php limits before saving any changes:

  • How do I increase the PHP upload limits?
  • CGI and PHP resource limits

Overview

The php.ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits.

The most common parameters changed in the php.ini file are:


safe_mode
register_globals
upload_max_filesize
post_max_size
max_execution_time

Additional directives can be found here.

If you're experiencing difficulty with your web application, you can edit the sample "php.ini.sample"php.ini or create a new text file. For example, you're unable to install a WordPress theme or plugin through your WP Dashboard.

Before making any changes, it's a good idea to copy the original settings, both for reference and to easily restore the original if necessary.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support.

Via AccountCenter

As a Grid user, your easiest option would be to use the File Manager to make the changes. Here's how:

  • Log into the AccountCenter
  • Click the Admin button to the right of your primary domain
  • Select File Manager
  • Click on the /etc folder

Inside the /etc folder, you'll see the php.ini.sample file. When you click on the Edit button, you'll see the below window. Just rename the filename to php.ini and add whatever parameters you need.

Apache change configuration file (php ini path)

After you make your edits, click SAVE CHANGES. Your changes will be saved and should take effect right away.

Via SSH

An alternate way to edit your php.ini file would be to connect via SSH as the Server Administrator.

Change directory to the etc folder using this command:

cd ~/../../etc

Use the following command to start editing:

vi php.ini

Via FTP

You can download the file locally and edit. This requires familiarity with Using FTP and SFTP and a plain text editor.

FAQs

Do I need to restart my service for the changes to take effect?

No, in fact there is no way or need for customers to restart services on the Grid. Any changes you make within your php.ini will be effective within a few moments.

Is there any way to use a different php.ini in each domain/folder on the Grid?

Not with a php.ini. The php.ini is designed to set global settings for your account. You can make changes on a per domain basis via a .htaccess file. More info on this can be found at http://www.askapache.com/htaccess/php-htaccess-tips-and-tricks.html.

Overview

The php.ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits.

The most common parameters changed in the php.ini file are:


safe_mode
register_globals
upload_max_filesize
post_max_size
max_execution_time

Additional directives can be found here.

If you're experiencing difficulty with your web application, you can edit the sample "php.ini.sample"php.ini or create a new text file. For example, you're unable to install a WordPress theme or plugin through your WP Dashboard.

Before making any changes, it's a good idea to copy the original settings, both for reference and to easily restore the original if necessary.

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is unsupported by (mt) Media Temple. Please take a moment to review the Statement of Support.

Requirements

Before you start, you'll need:

  • Root access enabled.
  • To know how to connect to your DV via SSH.

Plesk

Global php.ini

Use the following command at the command prompt to start editing the global php.ini file:

vi /etc/php.ini

When you are finished editing your php.ini, you will need to restart your Apache server. Run the following command:

/etc/init.d/httpd restart

Domain-specific php.ini

Plesk 11.0 and later features a domain-specific php.ini file. This domain-level version of php.ini overrides the global php.ini settings. There are two main ways to edit this file.

via Plesk

You can edit the domain-level php.ini file through the Plesk Control Panel.

1. Select the Domains tab.

   

Apache change configuration file (php ini path)

2. Expand the advanced options by clicking the SHOW MORE tab, as shown below:

 

Apache change configuration file (php ini path)

3. Select PHP Settings from the menu.

Apache change configuration file (php ini path)

 

4. Most common PHP directives are in this page and ready for you to modify. You can select common options from the drop-down menus, or create your own by using the "Custom Variable" option. For directives that are not listed, raw text can be input in the box at the bottom of this screen.

5. Click "OK" at the bottom to save.

Important Note
If you choose to use the Plesk "PHP Settings" menu to edit php.ini, it will overwrite any manual changes you have made to /var/www/vhosts/DOMAIN/etc/php.ini via SSH or FTP.

via SSH

You'll first need to log in via SSH.

Use the following command to start editing the domain-level php.ini:

vim /var/www/vhosts/DOMAIN/etc/php.ini

Be sure to replace DOMAIN with the domain name you want to edit.

cPanel (WHM)

Via WHM 

WHM allows you to configure your php.ini file using the PHP Configuration Editor. To access this tool and edit your php.ini file using WHM, follow the steps below.

1. Start by logging into WHM as the root user. From the Home page, select the Service Configuration button.
   

Apache change configuration file (php ini path)

2. Then, click on PHP Configuration Editor.

Apache change configuration file (php ini path)

3. Once you click on PHP Configuration Editor, you will be presented with a number of different parameters that you may edit the configurations for. If you don't see the parameter that you wish to edit in Basic Mode, you may click on Advanced Mode for a longer list of editable parameters. If you need more flexibility, you can also edit your php.ini using SSH.

Apache change configuration file (php ini path)

4. Once you have made your changes, click "Save" at the bottom.

Via SSH

Use the following command at the command prompt to start editing the global php.ini file:

vi /usr/local/lib/php.ini

When you are finished editing your php.ini, you will need to restart your Apache server. Run the following command:

/etc/init.d/httpd restart

Tip:

If you need to apply settings to a single site without making a global change that will affect all sites on your server, you may create a php.ini file in that site's document root (normally public_html). This will apply the settings in that file to that site only.

How do I change the PHP configuration in Apache?

Running PHP as an Apache module When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. httpd.conf) and.htaccess files. You will need "AllowOverride Options" or "AllowOverride All" privileges to do so.

Where can I find the PHP

The php that run on the webserver and the CLI version is not using the same php.ini file. If I do a command php --ini, it show this Configuration File (php.ini) Path: C:\Windows Loaded Configuration File: C:\wamp\bin\php\php5.3.8\php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)

Where do I find PHP config file?

Configuration File (php.ini) Path: C:\Windows Loaded Configuration File: C:\wamp\bin\php\php5.3.8\php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) while my web version uses the php.ini in C:\wamp\bin\apache\Apache2.2.21\bin\php.ini. This is probably very common for people using wamp.

How to update PHP settings with Apache or CGI module?

Generally speaking, to update the PHP settings with Apache module, you can use .htaccess file, but if PHP is running as a CGI module, then you can change the PHP settings using php.ini file. As stated above, when PHP is running as Apache module, .htaccess file is needed to change the PHP settings.

How do I change the location of my PHP ini file?

I also found that I had to do a full restart for php to pick up the new variable..
On Windows, find the path to your php.ini file and modify and run the following command in a command window: setx PHPRC "C:\YourPathto\PHP7\php.ini" You should see SUCCESS: Specified value was saved..
Then restart your computer (really)..

How do I change PHP ini settings?

Modifying the PHP..
Login to the cPanel..
Find the File Manager in File section of the cPanel. ... .
Navigate to the directory where you will either save or edit the PHP. ... .
Edit the section of the PHP. ... .
Click on SAVE CHANGES in the top right hand corner in order to save your modifications or additions to the file..

Where is PHP ini file in apache2?

The default location for the php. ini file is: Ubuntu 16.04: /etc/php/7.0/apache2. CentOS 7: /etc/php.

How configure Apache module in PHP?

Apache Configuration for PHP.
Timeout. This value sets the default number of seconds before any HTTP request will time out. ... .
DocumentRoot. DocumentRoot designates the root directory for all HTTP processes on that server. ... .
AddType. The PHP MIME type needs to be set here for PHP files to be parsed. ... .
Action. ... .
AddModule..