Changing PHP Version in DirectAdmin
Different applications and CMS platforms require specific PHP versions. DirectAdmin with CloudLinux allows you to switch PHP versions per domain without affecting other sites on your account.
Checking Your Current PHP Version
- Create a file called
info.phpin yourpublic_htmldirectory with this content:
<?php phpinfo(); ?>- Visit
https://yourdomain.com/info.phpin your browser - The PHP version will be displayed at the top of the page
- Delete this file after checking — it exposes server information
Changing PHP Version via DirectAdmin
Method 1: PHP Version Selector (CloudLinux)
- Log in to DirectAdmin
- Navigate to Extra Features or Advanced Features
- Click Select PHP Version or PHP Selector
- From the dropdown, choose your desired PHP version (e.g., 7.4, 8.0, 8.1, 8.2, 8.3)
- Click Set as current or Apply
Tip: PHP 8.1 or 8.2 is recommended for most modern applications. Check your application documentation for the minimum required version.
Method 2: Per-Domain PHP Version
If your account hosts multiple domains:
- Go to Domain Setup in DirectAdmin
- Click on the domain you want to configure
- Look for the PHP Version option
- Select the desired version
- Save changes
Configuring PHP Settings
After selecting your PHP version, you can customize PHP settings:
- Go to Select PHP Version or PHP Selector
- Click Options or PHP Options
- Common settings to adjust:
| Setting | Default | Recommended | Description |
|---|---|---|---|
| memory_limit | 128M | 256M | Maximum memory per script |
| upload_max_filesize | 2M | 64M | Max file upload size |
| post_max_size | 8M | 128M | Max POST data size |
| max_execution_time | 30 | 300 | Max script runtime (seconds) |
| max_input_vars | 1000 | 5000 | Max number of input variables |
- Click Save or Apply after making changes
Enabling/Disabling PHP Extensions
- Go to Select PHP Version
- Below the version dropdown, you will see a list of available extensions
- Check or uncheck extensions as needed:
- Common extensions: curl, gd, mbstring, mysqli, zip, xml, json
- WordPress requires: curl, gd, mbstring, mysqli, xml, zip
- Click Save
Using .htaccess to Set PHP Version
You can also set the PHP version via .htaccess:
# Use PHP 8.2
AddHandler application/x-httpd-php82 .phpThis is useful for setting different PHP versions for specific subdirectories.
Troubleshooting
Website Breaks After Changing PHP Version
- Check your application's compatibility with the new PHP version
- Look for deprecated functions in your error logs
- Temporarily switch back to the previous version while you update your code
PHP Changes Not Taking Effect
- Clear your browser cache
- Wait 2-3 minutes for the changes to propagate
- Check if a
.htaccessfile is overriding the setting
Extension Missing
- Not all extensions are available for all PHP versions
- Contact support if you need a specific extension enabled
Related Articles
Need help? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.