Each of the PHP installation comes with default settings that are generally fine for most websites. It’s very rare when the requirements of a website, make it essential for adjusting the PHP settings. In this case creating a php.ini (phprc) file is the solution for adjusting the PHP settings for your website.
In standard term, php.ini is used for a PHP configuration file.
A phprc file can be created using an FTP client, or by logging into the server via SSH, but it would be easy to create a phprc file using an FTP client. This article explains the steps to create this phprc file via SSH.
Steps to Add a phprc file using SSH
1. Using SSH, log into your server.
2. Type ‘pwd’ to confirm that you are in your users directory:
[server]$ pwd /home/example_username
3. Execute the below command:
[server]$ mkdir -p ~/.php/7.2
4. Run the below code to change your directory into these two new folders you just created:
[server]$ cd .php/7.2
- After running pwd, you will see the entire filepath you just created:
[server]$ pwd /home/example_username/.php/7.2
5. Create the phprc file without an extension, in this folder.
You can run a few programs for creating this file. In this example, a program called nano is used.
6. Execute the below code to create the phprc file:
[server]$ nano phprc
A text editor will pop up.
7. Next, edit the file with the help of your PHP customizations.
8. Close the file and go back to your shell.
How to Kill off running PHP processes?
After saving your changes, it is essential to kill off all running PHP processes. This helps your new settings to get updated.
How to Confirm Your Changes?
After editing the file and killing off all PHP processes, it is important to confirm if the values have updated. This can be done by creating a phpinfo.php file.
If your changes aren’t updated, try killing off your PHP processes again.
The phprc file is used for any domains under this specific username which also run the specific version of PHP you selected in step#3 while creating the directory.
For example, if the user has three domains from which two are running PHP 7.2 and the third is running PHP 7.1, only the first two domains that run 7.2 would be affected by the phprc file. You will need to create a separate phprc file for the PHP 7.1 site.