StarDomain

Changing PHP Version in DirectAdmin

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

  1. Create a file called info.php in your public_html directory with this content:
php
<?php phpinfo(); ?>
  1. Visit https://yourdomain.com/info.php in your browser
  2. The PHP version will be displayed at the top of the page
  3. Delete this file after checking — it exposes server information

Changing PHP Version via DirectAdmin

Method 1: PHP Version Selector (CloudLinux)

  1. Log in to DirectAdmin
  2. Navigate to Extra Features or Advanced Features
  3. Click Select PHP Version or PHP Selector
  4. From the dropdown, choose your desired PHP version (e.g., 7.4, 8.0, 8.1, 8.2, 8.3)
  5. 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:

  1. Go to Domain Setup in DirectAdmin
  2. Click on the domain you want to configure
  3. Look for the PHP Version option
  4. Select the desired version
  5. Save changes

Configuring PHP Settings

After selecting your PHP version, you can customize PHP settings:

  1. Go to Select PHP Version or PHP Selector
  2. Click Options or PHP Options
  3. Common settings to adjust:
SettingDefaultRecommendedDescription
memory_limit128M256MMaximum memory per script
upload_max_filesize2M64MMax file upload size
post_max_size8M128MMax POST data size
max_execution_time30300Max script runtime (seconds)
max_input_vars10005000Max number of input variables
  1. Click Save or Apply after making changes

Enabling/Disabling PHP Extensions

  1. Go to Select PHP Version
  2. Below the version dropdown, you will see a list of available extensions
  3. Check or uncheck extensions as needed:

- Common extensions: curl, gd, mbstring, mysqli, zip, xml, json

- WordPress requires: curl, gd, mbstring, mysqli, xml, zip

  1. Click Save

Using .htaccess to Set PHP Version

You can also set the PHP version via .htaccess:

apache
# Use PHP 8.2
AddHandler application/x-httpd-php82 .php

This 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 .htaccess file is overriding the setting

Extension Missing

  • Not all extensions are available for all PHP versions
  • Contact support if you need a specific extension enabled

Need help? Contact our support team at {{SUPPORT_EMAIL}} or open a ticket at {{SUPPORT_URL}}.