Running the right PHP version is very important for both performance and application compatibility. Some scripts or CMS platforms may only support older PHP versions, while others require the latest stable version.
With YesDomain Hosting, you can configure different PHP versions for each domain, subdomain, or even a specific folder within your account. For example:
- Your main website can run on PHP 8.1 for speed and security.
- A legacy web app inside a subfolder can still use PHP 7.4.
Although the YesDomain control panel provides a global PHP selector, you can set a custom PHP version per directory by adding a few rules inside the .htaccess
file.
Why Set Custom PHP Versions?
- Compatibility: Run older apps that don’t support the latest PHP.
- Testing: Safely test your website on a new PHP version without affecting the entire account.
- Flexibility: Assign different PHP versions for different addon domains or projects.
Steps to Configure a Custom PHP Version in a Directory
Step 1: Access File Manager
- Log in to your YesDomain Control Panel.
- Open the File Manager.
- Navigate to the folder or domain directory where you want to set a custom PHP version.
Step 2: Create or Edit .htaccess
- Look for an existing
.htaccess
file in that directory. - If it does not exist, create a new file named
.htaccess
.
Step 3: Add PHP Version Handler
Example: Set PHP 5.6 for a Specific Folder
# YesDomain Custom PHP Version 5.6
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp56
</FilesMatch>
# Custom PHP Version Code Ends
Example: Set PHP 7.0 for a Specific Folder
# YesDomain Custom PHP Version 7.0
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-lsphp70
</FilesMatch>
# Custom PHP Version Code Ends
⚠️ Note: Replace
lsphp56
orlsphp70
with the version handler you want (e.g.,lsphp74
,lsphp80
,lsphp81
).
Step 4: Save and Test
- Save changes to the
.htaccess
file. - Open the website or subdirectory in a browser.
- To verify, create a
phpinfo.php
file inside that directory with this code:
<?php phpinfo(); ?>
- Open
yourdomain.com/phpinfo.php
and check the PHP version running.
Troubleshooting
- 500 Internal Server Error → This usually happens if you entered an incorrect PHP handler. Double-check the handler name.
- Changes not applying → Ensure the
.htaccess
file is inside the correct folder. - Conflicts → If you already have custom
.htaccess
rules, place the PHP handler code at the top.
FAQs
Q1. Can I set PHP 8.2 only for a subdomain?
Yes. Just edit the .htaccess
file inside the subdomain’s public_html
folder.
Q2. Will this affect my main domain?
No. These rules only apply to the specific folder where the .htaccess
file is placed.
Q3. What if my script stops working after changing PHP?
Switch back to the previous version by editing .htaccess
again, or update your script to support newer PHP versions.
Related Articles
- How to Change PHP Version Globally in YesDomain Hosting
- How to Edit the .htaccess File in YesDomain Hosting
- How to Enable PHP Extensions in YesDomain Control Panel
Next Steps
Now you know how to run multiple PHP versions on a single YesDomain account. This gives you maximum flexibility for managing different apps and websites.
Need more help? Contact the YesDomain Support Team anytime.