Monthly Archives: March 2020

Change default PHP version in WHM

With the cPanel MultiPHP Manager utility you can have multiple PHP versions installed on your web hosting server. In this article, we will show to change the default PHP version in WHM.

WHM MultiPHP Manager

To change the default PHP version in WHM:

1. Log in with root credentials to WHM

2. Navigate to Software-> MultiPHP Manager

3. In the System PHP Version section, click the Edit link

4. From the drop-down list that will appear, select the default version you wish to use. Click the Apply button.
You will see a confirmation message. In our case:

Success: The system default PHP version has been set to “PHP 7.3 (ea-php73)”.

Notice that the change will apply only to domains that inherit the PHP version. The domains where the PHP version was manually set will keep the specified versions.

Related articles:
How to change PHP version in cPanel

Cloudflare Errors – Web server is down/Connection timed out

The two most common Cloudflare errors are 521 – Web server is down and 522 – Connection timed out. You can read more about this error by following the links from the References section. In many cases, these errors are caused by the firewall blocking the Cloudflare request. The first step in troubleshooting the issue is to whitelist the Cloudflare IPs.

Cloudflare error

At the time of writing the Cloudflare IPs are:

#cloudflare start IPv4
#cloudflare end

Cloudflare IPv4 IPs

#cloudflare start IPv6
#cloudflare end

Cloudflare IPv6 IPs

You should whitelist these two sets of IPs on your server. As many web hosting servers are using CSF, you should add these IPs to the file /etc/csf.allow. Don’t forget to restart it.

Cloudflare error 521
Cloudflare error 522

Redirect HTML extension to PHP

It’s very easy to redirect requests to .html pages to .php pages. You will need to add some lines to the .htaccess file. If this file doesn’t exist in your directory then you must create it.

The two lines are:

RewriteEngine On
RewriteRule ^(.*).html$ /$1.php [L,R]

Now, html files will be redirected to php file. E.g. will be redirected to

Redirect *.html to *.php

cPanel reporting incorrect /mail/ directory size

Many times, cPanel is reporting an incorrect value in cPanel->Disk Usage interface. In our test case the value from the shell is 308MB:

root@web [/home/mmtest]# du -sh mail
308M    mail
root@web [/home/mmtest]#

But the value reported in cPanel is 462.99MB as shown in the image below:

mail directory size 1

This is caused by the dovecot server not updating correctly the disk usage. to fix this situation, run the commands:

# /scripts/generate_maildirsize –confirm –allaccounts –verbose $username

root@web [/home/mmtest]# /scripts/generate_maildirsize --confirm --allaccounts --verbose mmtest
Rebuilding the maildirsize files for: mmtest
Rebuilding the maildirsize files for:
Checking user mmtest
Calculating diskusage and diskcount from reading files
Writing /home/mmtest/mail/maildirsize for user merches
Checking user
Calculating diskusage and diskcount from reading files
Writing /home/mmtest/mail/ for user john
root@web [/home/mmtest]#

Now the disk usage is reported correctly in cPanel:

mail directory size 2

To run the command for all the accounts use
# /scripts/generate_maildirsize –confirm –allaccounts –verbose

More information on this cPanel script can be found by running
# /scripts/generate_maildirsize –help

Redirect site to another URL except for a specific directory

You are moving your site to another domain. You want to redirect users to the new domain. But you have a script on a directory that you still want to access on the old domain.

The necessary lines that must be added to your .hatccess file are:

RewriteEngine on
RewriteRule !^(script_directory){REQUEST_URI} [R=301,L]

If you want to redirect two directories, separate them with | :

RewriteEngine on
RewriteRule !^(directory1|directory2){REQUEST_URI} [R=301,L]

The code will keep the path – for example will be redirected to

RewriteRule Directive

Page 1 of 2
1 2