Archive for December, 2016

Plesk is not accessible. The error below is shown:

ERROR: PleskFatalException
Unable to connect to database: Unknown database 'psa'

0: common_func.php3:150
    psaerror(string 'Unable to connect to database: Unknown database 'psa'')
1: auth.php3:111


The psa database does not exist.


  1. Log in to MySQL and check if the psa database exists:
    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin
    mysql> show databases like 'psa';
    Empty set (0.00 sec)

    So, at this point, you need to restore the database from the latest available backup on the server.

  2. Check if backups exist in the dump directory:
    ~# grep dump /etc/psa/psa.conf
    DUMP_D /var/lib/psa/dumps
    ~# ls -la  # ls -lt /var/lib/psa/dumps/mysql.daily.dump*
    -rw------- 1 root root 239658 Dec 10 03:37 /var/lib/psa/dumps/mysql.daily.dump.0.gz
    -rw------- 1 root root 241242 Dec  9 03:37 /var/lib/psa/dumps/mysql.daily.dump.1.gz
    -rw------- 1 root root 241376 Dec  8 03:37 /var/lib/psa/dumps/mysql.daily.dump.2.gz
    -rw------- 1 root root 241887 Dec  7 03:38 /var/lib/psa/dumps/mysql.daily.dump.3.gz
    -rw------- 1 root root 237143 Dec  6 03:38 /var/lib/psa/dumps/mysql.daily.dump.4.gz
    -rw------- 1 root root 233966 Dec  5 03:36 /var/lib/psa/dumps/mysql.daily.dump.5.gz
    -rw------- 1 root root 233495 Dec  4 03:38 /var/lib/psa/dumps/mysql.daily.dump.6.gz
    -rw------- 1 root root 232856 Dec  3 03:36 /var/lib/psa/dumps/mysql.daily.dump.7.gz
    -rw------- 1 root root 232710 Dec  2 03:36 /var/lib/psa/dumps/mysql.daily.dump.8.gz
  3. Restore the latest daily dump (from Dec. 10 in this case) using the commands below:
    # gunzip /var/lib/psa/dumps/mysql.daily.dump.0.gz 
    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin  -e "create database psa"
    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa < /var/lib/psa/dumps/mysql.daily.dump.0

Custom php.ini file with FastCGI

Posted: December 15, 2016 in other

  1. Login to your server via SSH.
  2. Make a backup copy of your cPanel PHP wrapper script with the following command:

    cp -frp /usr/local/cpanel/cgi-sys/php5 /usr/local/cpanel/cgi-sys/php5-BACKUP

  3. Now edit the cPanel PHP wrapper script with your favorite text editor:

    vi /usr/local/cpanel/cgi-sys/php5

    By default this script should look like:


    # If you customize the contents of this wrapper script, place
    # a copy at /var/cpanel/conf/apache/wrappers/php5
    # so that it will be reinstalled when Apache is updated or the
    # PHP handler configuration is changed

    exec /usr/bin/php

  4. Above the line exec /usr/bin/php add the following code:

    [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini

    Now the cPanel PHP wrapper script should look like:


    # If you customize the contents of this wrapper script, place
    # a copy at /var/cpanel/conf/apache/wrappers/php5
    # so that it will be reinstalled when Apache is updated or the
    # PHP handler configuration is changed

    [[ -f ~/public_html/php.ini ]] && exec /usr/bin/php -c ~/public_html/php.ini
    exec /usr/bin/php

    What this does is uses the Bash syntax for seeing if a file exists [[ -f ]] and in this case we’re looking for the file ~/public_html/php.ini. The ~ symbol would represent the current user calling the script, so this would be the same as entering in either /home/user1/public_html/php.ini or /home/user2/public_html/php.ini as the full path.

    The rest of the code simply executes the PHP binary at /usr/bin/php with the -c flag which sets the location where you’d like to load a php.ini from from. In this case we are telling the server we’d like to use the php.ini file inside the user’s /public_html/ directory if one exists, instead of /usr/local/lib/php.ini which would be the server’s default.

  5. Now you’ll want to copy the cPanel PHP wrapper script to a more permanent location, so that your settings are saved if you ever recompile Apache down the road. This can be done using the following command:

    mkdir -p /var/cpanel/conf/apache/wrappers
    cp -frp /usr/local/cpanel/cgi-sys/php5 /var/cpanel/conf/apache/wrappers/php5

  6. Now restart Apache for the settings to become active:

    service httpd restart

  7. In order to verify your settings have been applied you’ll want to create a PHP info script, the simplest way of doing this is simply copying any of your files to a file such as info.php, and then overwriting it with the phpinfo(); function:

    echo ‘<?php phpinfo(); ?>’ > ~user1/public_html/info.php

    Now when you visit your website and access the newly crated info.php script, you should see your custom php.ini being loaded next to the Loaded Configuration File section

Common paths in cPanel and WHM

Posted: December 9, 2016 in Cpanel

For those users who use cPanel/WHM on their virtual or dedicated servers the following article describes common system paths and utilities.

Paths of Base Modules



/usr/local/bin/convert or /usr/bin/convert




Ruby Gems




FLV Tool

User Directories
Document Root

WWW Directory

CGI Directory

cPanel / WHM Core Directories and Files
Houses only scripts and binaries which provide installation and configuration of many cPanel services.

Houses proprietary configuration data for cPanel, including:

Primary cPanel configuration
User configurations
Reseller configurations
Accounting, conversion, and update logs
Bandwidth data
Customized service templates

The primary cPanel configuration file. Each variable within influences the way cPanel behaves, variables are line delimited, with variables separated by an equal sign. If this file does not exist cPanel falls back to defaults.

Lists each reseller with a comma-delimited list of WHM resources that reseller has access to.

Contains a list of accounting functions performed through WHM, including account removal and creation.

Files contain a list of bandwidth history for each account, each named after their respective user. History files are stored in human-readable format, while actual bandwidth data are stored in round robin databases.

File name is inherited from the feature list name. Contains a line delimited list of feature variables and a zero or one value. Variables control what cPanel resources are available to users.

Contains a list of packages named after the packages they represent. If a package belongs to reseller file name is prefixed with reseller username. Each of these values determines the value created in cPanel user file.

Contains a list of cPanel user configuration files named after the user they pertain to. Variables define account resources, themes, domains, etc.

Other /var/cpanel Directories
This directory contains logs from account copies/transfers.

Contains the output of each cPanel update executed on the server.

Named after the respective reseller users they represent, each contains only the IP address which should be used as resellers main shared IP.

Contains customized DNS zone templates created in WHM.

This directory houses a large number of scripts which serve as building blocks for many cPanel/WHM features.
These scripts can be used to:

Update cPanel and many of its services
Customize account creation routines
Perform backups of cPanel accounts
Install and update cPanel managed services

cPanel Maintenance Scripts
By default cPanel applies nightly updates at 2:13AM server time via the root crontab.
/scripts/upcp dispatches these updates using the following key components:

/scripts/updatenow – synchronizes /scripts directory
/scripts/sysup – updates cPanel managed rpms
/scripts/rpmup – updates all other system updates
Updates are logged to timestamped files in /var/cpanel/updatelogs. Update configuration is stored in /etc/cpupdate.conf

Account Management Scripts
/scripts/wwwacct (account creation)
/scripts/killacct (account termination)
/scripts/suspendacct (account suspension)
/scripts/unsuspendacct (account resuming)
/scripts/addpop (create pop account)
Updates the user:owner and user:domain tables stored in:
These tables are used to enumerate and keep track of accounts and their owners.

Package Management
Takes argument list of rpms, which are then passed to the underlying package manager.

The equivalent of ensurerpm for FreeBSD. Updates specified packages from ports.

Takes argument list of perl modules to install via CPAN. Each of the aforementioned scripts can accept an argument of ‘–force’ to force package installations.

Can be called to apply MySQL updates independent of upcp.

Will clean up the default MySQL privilege tables, by installing a more restrictive privilege schema.

Will verify that mysql is accessible with password stored in /root/.my.cnf and force a reset with a random 16 character string if inaccessible.

Can be called to apply exim updates independent of upcp.

Will rebuild exim.conf, and merge local, distribution, and cPanel configurations.

Rebuild named.conf based on existing zone files

Download, extract, and execute apache build script

Rebuilds httpd.conf based on DNS entries found in each cPanel user configuration

Other cPanel Scripts
The majority of cPanel managed service can be scripts named appropriately.

Will rebuild the PHP interpreter used internally by cpsrvd.

Will scan for and install any Perl modules required by cPanel.

Updates horde and resets the horde mysql user password.

Will attempt to rebuild quota database per information stored in /etc/quota.conf