How do I create a php.ini file via SSH?

  • Post author:
  • Post category:Uncategorized
  • Post comments:0 Comments

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

  1. 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:
  2. 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.

  3. Run the following command:
    [server]$ mkdir -p ~/.php/7.2
  4. 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
  5. 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.

  6. Run the following to create the php.ini file.
    [server]$ nano phprc
    • The ‘nano’ text editor opens.
  7. Edit the file with all of your PHP customizations.
  8. Close the file and return to your shell.

Leave a Reply