The fix-web-vhost-configuration Script

Valid for versions 82 through the latest version

Version:

82

Last modified: November 29, 2022


Overview

You can use the /usr/local/cpanel/scripts/fix-web-vhost-configuration script to iterate through each user’s web virtual host configuration files and remove excess alias names. Certain historical errors in cPanel & WHM make it possible for discrepancies to exist between what the system expects and the actual configuration.

Note:
  • You must run this script as the root user.

  • The system automatically runs the /usr/local/cpanel/scripts/fix-web-vhost-configuration script when you upgrade major versions of cPanel & WHM.

This script performs the following actions:

Note:
If you pass the --dry-run argument, the script will not delete or add any domains form the web virtual host configuration files.
  1. Identify any unrecognized alias domains.

  2. Delete the following unrecognized alias domains from the web virtual host configuration files:

    • Active service subdomains - cpanel.example.com

    • www subdomains of active service subdomains - www.cpanel.example.com

    • www subdomains of any expected alias - www.mail.example.com

      Note:
      This will ignore other unrecognized alias domains

  3. Identify and add any missing alias domains.

Run the script

To run this script on the command line, use the following format:

/usr/local/cpanel/scripts/fix-web-vhost-configuration [arguments]

Options

Use the following options with this script:

Options Description Example
--user Required - Update the web virtual host configuration files of the user that you specify.
Note:
You must pass either the user flag or the all-users flag, but not both.
--user=username
--all-users Required - Update the web virtual host configuration files for all users.
Note:
You must pass either the user flag or the all-users flag, but not both.
--all-users
--dry-run Identify, but do not delete or add any alias domains in the user’s web virtual host configuration files. --dry-run
--help Display a help message. --help

Example

For example, the following command removes the excess alias name from the username cPanel user’s web virtual host configuration files:

/usr/local/cpanel/scripts/fix-web-vhost-configuration --user=username

Output

This script’s output could resemble the following example:

1
2
3
4
5
6
7
8
----- Checking username 
--- Virtual host: example.com
 Unrecognized: cpanel.example.com
 Pending deletion: cpanel.example.com
Fixed!
- Non-SSL configuration 

Done!

Additional Documentation