PHP is a popular programming language for dynamic site generation and integrating databases into web applications. Notable examples include the WordPress content management system (CMS), WHMCS billing system, PHP app hosting, and Nextcloud personal cloud storage solution.
This high popularity results in a frequent need to upgrade or simply change PHP versions. A new version of PHP is released more than annually to include security bug fixes and new features. However, which PHP version(s) you need in Control Web Panel (CWP) depends on the applications you need. Below we’ll cover how to change the primary PHP version and select a specific version for different user accounts.
Change PHP Version in CWP
Follow these steps to change the main PHP version in CWP. Generally, you should select the latest version. But if you have PHP applications installed, check the software documentation as you might be better off with the recommended version instead.
- Log into CWP as an administrator.
- On the left, search for and select PHP Version Switcher.
- Select a version from the drop-down menu.
- A list of available PHP modules will pop up below. The default options will suffice for most use cases. Unselected options you may need depending on software installed include ioncube (for WHMCS), mongodb, and redis.
- After customizing your PHP build, select Save & Build at the bottom.
The page will refresh with a progress bar while compiling PHP in the background. This may take over thirty (30) minutes depending on your CWP server’s performance capabilities. You can select View log to check the PHP installation process. You can also find the same info from the CWP terminal with the following command:
tail -f /var/log/php-rebuild.log
Install Multiple PHP Versions
Administrators with a CWPpro license can install different PHP versions within CWP.
- On the left, select PHP Selector.
- Major PHP versions will be listed. To the right of each major is a drop-down menu to specify a minor PHP version to install and links to modify PHP options (extensions). Make a selection in every drop-down menu for major PHP versions you wish to install.
- Select Start Compiler (build & install).
Non-CWPpro users needing multiple PHP versions can try installing them from CWP terminal, but you’ll also have to manage it there.
Set Multiple PHP versions with PHP Selector
CWPpro end users can change PHP versions per domain. The process is pretty straightforward.
- On the left, select CWP Settings > Php Selector.
- Choose a domain from the drop-down menu.
- Select from the available PHP versions.
- Select Update Version.
Manually Set Multiple PHP Versions
Users not on a CWPpro server will still be able to see the PHP Selector. However, you won’t be able to make changes and there will be an alert stating “You need a CWPPRO license to use this module. Contact your server administrator.”
We recommend Non-CWPpro users (on an Apache web server) ask your server administrator to install the PHP versions you need so that you can set multiple PHP versions in .htaccess. You can edit this file from File Management > File Manager. You can also do this in the command-line interface (CLI) if shell access is enabled for your user account.
Edit PHP.ini in CWP
Even with the correct PHP version you may need to make further changes for optimal PHP application performance. This section covers how to customize your PHP configuration file in CWP.
- On the left, select CWP Settings > Edit php.ini.
- Select a domain from the top if you have more than one under the account.
- Make changes as needed. The most commonly modified attributes are upload_max_filesize, memory_limit, and max_execution_time. Also, display_errors should be set to “Off,” unless you’re troubleshooting development issues.
- Once you’re finished making changes, select Update changes on the right.
- (Optional) To add more custom changes, select Advanced Editor to edit the raw php.ini file. Select Save on the right once you’re done.
Create a PHPInfo.php File
To ensure your configuration works, you can create a phpinfo.php file.
- From the user panel, select File Management > File Manager.
- Use the left-hand sidebar and navigate to the root directory for your website.
- At the top, select File, and type a PHP file name. “phpinfo.php” is a common name but it can be named anything with a “.php” extension.
- Click Save.
- Select the third (edit) button under the “Actions” column for the new PHP file.
- Add the following code block:
<? phpinfo(); ?>
- Click Save on the right.
- Visit the PHP info page in your browser.
Let us know if you have questions about configuring PHP on your CWP server.