Tip: Start typing to get instant search results.
How to Change PHP Version Only for Selected Domains and Subdomains in DirectAdmin
It is often desirable to have different PHP versions for different domains or subdomains of your DirectAdmin account.
The PHP version change from the “Select PHP version” option is applied at the account level in DirectAdmin, meaning it affects all websites (domains and subdomains) that belong to the same user.
Below we present brief instructions on how you can set different PHP versions only for a specific domain or subdomain.
Instructions for Selecting a Secondary PHP Version (different version for a subdomain)
1. Log in to DirectAdmin
Type domainname.tld:2222 in your browser (replace domainname.tld with your own domain) and log in using your username and password.

2. Access File Manager
From the “System Info & Files” menu, select “File Manager”.

3. Navigate to the desired folder
Navigate to the folder of the domain or subdomain for which you want to change the PHP version (e.g., the public_html of a subdomain).

4. Create or edit the .htaccess file
If there is no .htaccess file in the folder:
- Click the “New File” button
- Create a new file named
.htaccess - Click the “CREATE” button to create the file
- Double-click on the file to edit it
- Add the following content, for example, for PHP 8.1 (you can add it at the top of the .htaccess file if you already have an .htaccess with existing content)
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp81
</FilesMatch>Above we have selected PHP 8.1 version (lsphp81). The number following lsphp in the second line of the above code indicates the PHP version that will be used in this specific folder. You can similarly select any other PHP version you wish, such as:
- PHP 5.6:
application/x-lsphp56 - PHP 7.4:
application/x-lsphp74 - PHP 8.0:
application/x-lsphp80 - PHP 8.1:
application/x-lsphp81 - PHP 8.2:
application/x-lsphp82 - PHP 8.3:
application/x-lsphp83 - PHP 8.4:
application/x-lsphp84
- PHP 5.6:
- Also, in addition to selecting the PHP version, we can define important settings for the selected PHP version, for example:
php_value memory_limit 1024M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_input_vars 40000
5. Save the file
Save the file and the change takes effect immediately.

This domain (or subdomain) will now run with the selected PHP version.
