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:
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.
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.
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.
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.
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.ssh USER@SERVER -pPORT
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.
[user@server ~]$
. That will indicate a successfully established SSH connection to the hosting server. 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:
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:
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 </FilesMatch>
To switch to PHP 7.3:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp73 </FilesMatch>
To switch to PHP 7.2:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp72 </FilesMatch>
To switch to PHP 7.1:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp71 </FilesMatch>
To switch to PHP 7.0:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp70 </FilesMatch>
To switch to PHP 5.6:
<FilesMatch ".(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-lsphp56 </FilesMatch>
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).
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:
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!