How to Use SSH on Shared Hosting Plans to Change PHP Version

Updated on Oct 25, 2022

Secure Shell (SSH) is a protocol that provides secure command-line access to your hosting account. FastComet offers SSH access, enabled by default to all shared hosting plans. This guide is to explain how to connect your FastComet hosting account via SSH and how to update PHP to a different version.

Table of Contents:

How to Access Your Hosting Account via SSH

With SSH, you use a terminal (or Shell) client to connect to the server. There are many different types of SSH clients you can choose, depending on your operating system, but the process is similar.

Windows - Access SSH via PuTTY

If you are a Microsoft Windows user, you will need to connect to your server via 3rd party SSH client. Every Windows SSH client has its own way to be installed and launched, but once you've set it up, there is no difference in further operations.

  1. Download your SSH client such as WinSCP or PuTTY. FastComet recommends PuTTY, a free program that you can download here.
  2. Open your SSH client, Enter your IP address and the appropriate port number.
  3. For further instructions on how to proceed, follow our tutorial on How to Use PuTTY.

Note that as of April 2018, Windows 10 comes with a built-in Shell. You can use this as an SSH client using Windows Command Prompt or PowerShell.

macOS/Linux - Access SSH via Terminal

Both Mac OS X and Linux (which are UNIX based OS) include SSH clients, so there is no need to install any third-party clients. Simply start up a terminal to connect to your hosting account via SSH.

  • To open the terminal in Mac, go to ApplicationsUtilitiesTerminal. Otherwise, you can use the keyboard shortcut Command + (Space).

Locate Terminal on Mac

  • A window with a user$ sign and a blinking cursor will open. That's the basic command prompt. You can use it to establish an SSH connection to your hosting server.
  • To connect, execute the following command:

USER - input the user for whom you want to establish the SSH connection, which would be your cPanel username.

SERVER - hostname or IP of the server you need to establish connecting with.

PORT - connection port. As the standard port 22 can be an easy target for attackers, many web hosts change the SSH port to a custom port. At FastComet, the custom port for SSH access is 17177.

  • Your computer will now attempt to establish a connection with your hosting server. If that's the first time you're trying to connect to the server, you will see a message that's asking you to confirm your connection request. Type Yes and press Enter to proceed.
  • There will be a request to input your cPanel account password. Type it in and press Enter. Keep in mind that the cursor will not move while you are typing in your password.
  • If everything is okay, your line will now begin with [user@server ~]$. That will indicate a successfully established SSH connection to the hosting server. 

cPanel - Access SSH via Terminal

The cPanel Terminal interface offers access to an in-browser application for direct command-line (CLI) within a cPanel session. To access cPanel Terminal, do the following:

  • Open cPanelAdvancedTerminal:

Find SSH Terminal in cPanel

  • There might be a warning notice, which pops up if you are using the cPanel Terminal for the first time. Click on "I understand and want to proceed" The message should not appear for future sessions.
  • With cPanel Terminal, you will not have to input your username and password, because you are already inside your cPanel, and thus you are logged in. You can now run your SSH commands.

How to Run the Latest PHP Version via SSH at FastComet

Every website owner knows that the security of their website is of utmost importance. PHP gets better in terms of performance and security with each new version, and thus you would want your site to run on the latest PHP version. You can accomplish that via SSH, not only through the visual PHP selector in cPanel. 

So, you already know how to access your hosting account via SSH, let us now help you with the commands you need to run for running the latest PHP version. The default PHP version on the FastComet servers is PHP 7.2, but we currently offer PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1.

Assuming you have already logged in to your hosting account via SSH session, all you have to do now is open the .htaccess file and edit it. Here is the command you need:

nano public_html/.htaccess

Once you have opened the file you can customize the version of PHP that runs your PHP files by directly editing your .htaccess file. To do so add one of the following directives in the .htaccess file of your website:

Available PHP Handlers

To switch to PHP 8.1: 

AddHandler application/x-httpd-php81 .php .php5

To switch to PHP 8.0: 

AddHandler application/x-httpd-php80 .php .php5

To switch to PHP 7.4: 

AddHandler application/x-httpd-php74 .php .php5

To switch to PHP 7.3:

AddHandler application/x-httpd-php73 .php .php5 .php4 .php3

To switch to PHP 7.2:

AddHandler application/x-httpd-php72 .php .php5 .php4 .php3

To switch to PHP 7.1:

AddHandler application/x-httpd-php71 .php .php5 .php4 .php3

To switch to PHP 7.0:

AddHandler application/x-httpd-php70 .php .php5 .php4 .php3

To switch to PHP 5.6:

AddHandler application/x-httpd-php56 .php .php5 .php4 .php3

This will change the PHP version for that site and all of its subfolders. In case you'd like to have a different version of PHP in a subdirectory, create a new .htaccess file in it with the directive for the desired PHP version.

Note that this is for FastCloud and FastClout Plus users. If you are a FastCloud Extra user, you need to add few more lines instead of the one above. The following handlers can be copied and pasted directly into your .htaccess file:

To switch to PHP 8.1: 

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp81

To switch to PHP 8.0: 

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp80

To switch to PHP 7.4: 

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp74

To switch to PHP 7.3:

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp73

To switch to PHP 7.2:

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp72

To switch to PHP 7.1:

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp71

To switch to PHP 7.0:

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp70

To switch to PHP 5.6:

<FilesMatch ".(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp56

After you add the text to your .htaccess file, you have to press ^X (Ctrl+X) to exit the Terminal. When you are asked to confirm the changes - press Y (for Yes).

How to Check your PHP Version via SSH

Double-checking is always a good idea. If you're interested in implementing new features on your website or are trying to pinpoint a bug you want to check your PHP version while you are still in the Terminal. You can do that by using the following input:

php -v

You will see an output similar to the one in this sample: 

Terminal PHP Version Check Output


There are a lot of reasons why you should always update to the latest PHP version, but probably the most important ones are the increase in website security and performance. So, for both you and your visitors to be enjoying a faster and safer website, you should update your PHP version right away.

We hope you find this article useful. Discover more about FastCloud - the top-rated Hosting Solutions for personal and small business websites in four consecutive years by the HostAdvice Community!

SSD Cloud Hosting

  • Free Domain Transfer
  • 24/7 Technical Support
  • Fast SSD Storage
  • Hack-free Protection
  • Free Script Installation
  • Free Website Transfer
  • Free Cloudflare CDN
  • Immediate Activation
View More