In this tutorial I will show you how to create a php.ini file via SSH.
You can create a phprc file using an FTP client, or by logging into the server via SSH, however creating a php.ini file is easier using an FTP client. This article is for more advanced users and explains how to create this php.ini file via SSH.
Adding a php.ini file using SSH
- Log into your server via SSH. Visit the following article for instructions on how to do this based on which operating system you’re using:
- Make sure you’re in your user’s directory by typing in ‘pwd’ to confirm:
[server]$ pwd /home/example_username
In this directory, you can run a single command to create the /.php folder as well as the /7.2 folder that goes inside of it. Remember to first check which version of PHP your site is using. In the following example, we’ll assume the site is using PHP 7.2. If your site is running PHP 7.3, the directory would be named 7.3 instead.
- Run the following command:
[server]$ mkdir -p ~/.php/7.2
- Change your directory into these two new folders you just created, by running the following:
[server]$ cd .php/7.2
- When you run pwd, you now see the entire filepath you just created:
[server]$ pwd /home/example_username/.php/7.2
- In this folder, create the phprc file without an extension.
There are a few programs you can run to create this file. This example uses a program called nano.
- Run the following to create the php.ini file.
[server]$ nano phprc
- The ‘nano’ text editor opens.
- Edit the file with all of your PHP customizations.
- Close the file and return to your shell.