SiteGround supports multiple PHP versions starting from 7.3 to the latest 8.2. Earlier days, it was easy to setup custom PHP versions from cPanel for different folders (subdirectories or subdomains). However, it is a difficult and lengthy task with Site Tools interface. If you wonder how to change PHP version of specific folder in SiteGround, here is how you can do that.
Different PHP Versions within a Domain
It is a common thing to install applications on a subdomain or subdirectory. For example, you can use WordPress on primary domain and use a PHP script on a subdirectory. Whether it is a subdomain or subdirectory, that is a folder where you can store the content. However, the process of changing PHP version for subdomain and subdirectory is different as subdirectories can’t be selected independently.
Here are the steps involved in the process:
1. Changing Ultrafast to Standard PHP Setup
SiteGround offers two types of PHP setup. Ultrafast is customized for SiteGround setup while standard version is normal PHP used on any other hosting company. The problem with the Ultrafast setup is that all folders (subdomains and subdirectories) will inherit the PHP version from primary domain. So, it is not possible to apply different PHP version only for a specific folder with this option. While the Standard PHP also applies PHP for all sections of the domain, you can manually set a different PHP version for a folder with this setup. By default, your domain will use Ultrafast setup in SiteGround and the first step is to switch that to Standard PHP mode.
- Login to your SiteGround account and go to “Websites” tab.
- Under “Websites” tab, click “Site Tools” option for the domain you want to change the PHP version.
- When you are in Site Tools section, go to “Devs > PHP Manager” section.
- Click the pencil icon showing in “PHP Setup” box.
- Switch the mode to Standard PHP and confirm your action.
This will be applied to your domain level.
2. Select Manual PHP Version for Domain
Regardless of whether you use Ultrafast or Standard PHP, SiteGround will automatically update your PHP version to next version when stable version is available. Next step is to change the automatic PHP update and manually select the PHP version you want to apply for the domain level. You can skip to next step, if you only want to change the version for subdomain / subdirectory and leave the current version for main domain as it is.
- Check under “Manage PHP Settings for your domain” section.
- Make sure you are in “PHP Version” tab and click the pencil icon showing against the current version of the PHP for your domain.
- Select your preferred PHP version and click “Confirm” button.
3. Apply Different PHP Version for Subdomain
Click “Select Domain” dropdown under “PHP Setup > Live Sites” section. As mentioned, you will only see the subdomain here and select the subdomain. Now, click the pencil icon under “PHP Version” section and select your preferred version for that subdomain.
You can change the PHP version for each subdomain from the list to apply different versions.
4. Apply Different PHP Version for Subdirectory
As mentioned, you will not see subdirectories from in “Select Domain” dropdown list. In this case, you need to follow the manual process.
- Go to “Site > File Manager” section and locate your subdirectory folder.
- Expand that folder and locate .htaccess file.
- Click the pencil icon to edit the file and copy paste the following directive at the start of the file. This is for applying PHP 7.4 and make sure to change the 74 to your required version. For example, you should use 80 for PHP version 8.0.
AddHandler application/x-httpd-php74 .php .php5 .php4 .php3
- Save and close your file.
5. Testing PHP Versions are Different
The testing process depends upon the application you use on your domain and subdomain/subdirectory. There are some Chrome browser extensions available to check the PHP version used on a webpage. If you are using WordPress, go to “Tools > Site Health” section in your WordPress admin dashboard. Go to “Info” tab and check under “Server” section.
You can use the following manual method for any app setup.
- Open a Notepad (Windows) or TextEdit (Mac) file.
- Paste the following content and save the file with the name as info.php.
<?php phpinfo(); ?>
- Go to “Site > File Manager” section in your SiteGround account.
- Navigate to the root of your domain or subdomain/subdirectory for which you want to check the PHP version.
- Click the “Upload” icon and upload your info.php file in the root location.
- Now, open the complete URL like yoursite.com/info.php or yoursite.com/folder/info.php or folder.yoursite.com/info.php in a browser.
- It should show the current PHP version on top of the page along with other server configuration details.
- After verification, go to File Manager, right-click on the info.php file and select “Delete” option.
- Confirm the pop-up to permanently delete the info.php file. Make sure to delete this file to avoid anyone viewing your server configuration from browser.
Sometimes I wonder why designers do not think about end users when designing a new interface. Changing PHP version of a folder is super simple process in cPanel setup. Now that the custom Site Tools setup only supports subdomains. For subdirectories, you should manually need to edit .htaccess file and add directive which is not a user-friendly way.