Table of Contents | ||
---|---|---|
|
Overview
We recommend and support the use of the cPanel installer to install and provision cPanel & WHM. However, we understand that this is not the most efficient way for a VPS (Virtual Private Server) hosting company to provision a VPS, because this process requires extra time. This article explains how hosting companies and data centers can provision a VPS or VM (Virtual Machine) with cPanel & WHM already installed for their customer. The installation of cPanel & WHM from a templated environment reduces the customer's setup time so that they can create a VPS and work on their website rather than their server.
Create a Minimal VM for Templating
A minimal template VM uses 10 GB of space, but you can expand it later as the customer requires.
This document creates a small template that you will expand after you set it up on the customer's VPS. Create a new minimal VPS to prepare your template.
Pre-configuration
We provide extensive documentation that explains how to preconfigure cPanel & WHM. For more information, visit the Installation Guide documentation.
We recommend that you customize the following files:
Code Block | ||
---|---|---|
| ||
/etc/cpupdate.conf /etc/cpsources.conf /etc/wwwacct.conf /var/cpanel/cpanel.config |
Release tier
cPanel, Inc. offers the following release tiers:
- EDGE
- CURRENT
- RELEASE
- STABLE
cPanel & WHM automatically defaults to the RELEASE tier. But, before you install cPanel & WHM, you can configure the /etc/cpupdate.conf
file to select which release tier cPanel & WHM will use.
For example, if you wished to configure cPanel & WHM to use the CURRENT release tier, run the following commands:
Code Block | ||||
---|---|---|---|---|
| ||||
# touch /etc/cpupdate.conf # echo "CPANEL=current" >/etc/cpupdate.conf |
If you wished to use EDGE or STABLE tiers, replace the word current
with the desired release tier.
Note | ||
---|---|---|
| ||
|
Other files
Note | ||
---|---|---|
| ||
For more information on the |
Info | ||
---|---|---|
| ||
If you are a cPanel Partner with your own FastUpdate server, you can edit the
Read the Custom update mirrors documentation for more information. |
cPanel Installation
After you finish your pre-configuration, you can install cPanel & WHM. Follow the Best Practices for cPanel Virtualization Templates as you usually would to install cPanel.
Deploy your VPS
When you deploy the customer's VPS, you must automatically update some files. If you use the libguestfs virt-sysprep
command, you can achieve this via the "--firstboot
" or "--firstboot-command
" flags. If you do not use the libguestfs
command, consult your hypervisor's documentation for an alternative option to run scripts or commands upon first boot.
Warning | ||
---|---|---|
| ||
If you use a tool such as |
Before you deploy your VPS, complete the following steps:
- Automatically call the
/usr/local/cpanel/bin/set_hostname
script on the first boot of the image before any cPanel services start. You can either randomize the hostname or set the hostname based on your customer's choice. - Update
ADDR
within/etc/wwwacct.conf
to the main IP address for the VPS. - If you run a 1:1 NAT environment, run the
/scripts/build_cpnat
script to build your NAT file, and configure Apache accordingly. - Run the
/scripts/rebuildhttpdconf
script to rebuild your Apache configuration with the correct addresses.
The following bash script executes the steps above, but it does not update ADDR
:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/bin/bash readonly PROGNAME=$(basename $0) readonly PROGDIR=$(readlink -m $(dirname $0)) readonly ARGS="$@" readonly HOSTNAME=$(hostname --fqdn) readonly CPHULKPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') readonly MSECPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') readonly ESTATSPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') readonly LPROTPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') readonly RCUBEPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') readonly MYSQLPASS=$(/usr/local/cpanel/3rdparty/bin/perl -MCpanel::PasswdStrength::Generate -e 'print Cpanel::PasswdStrength::Generate::generate_password(14)') is_file() { local file=$1 [[ -f $file ]] } is_dir() { local dir=$1 [[ -d $dir ]] } main() { is_dir /usr/local/cpanel \ && /usr/local/cpanel/bin/set_hostname ${HOSTNAME} \ && /usr/local/cpanel/bin/checkallsslcerts --allow-retry \ && /scripts/build_cpnat \ && /scripts/rebuildhttpdconf \ && /scripts/mysqlpasswd root ${MYSQLPASS} \ is_file /var/cpanel/hulkd/password \ && /scripts/mysqlpasswd cphulkd ${CPHULKPASS} \ && echo -e "user=\"cphulkd\"\npass=\"${CPHULKPASS}\"">/var/cpanel/hulkd/password \ && /scripts/restartsrv_cphulkd is_file /var/cpanel/modsec_db_pass \ && /scripts/mysqlpasswd modsec ${MSECPASS} \ && echo ${MSECPASS} >/var/cpanel/modsec_db_pass is_file /var/cpanel/roundcubepass \ && /scripts/mysqlpasswd roundcube ${RCUBEPASS} \ && echo ${RCUBEPASS} >/var/cpanel/roundcubepass is_file /var/cpanel/eximstatspass \ && /scripts/mysqlpasswd eximstats ${ESTATSPASS} \ && echo ${ESTATSPASS} >/var/cpanel/eximstatspass \ && /scripts/restartsrv_eximstats is_file /var/cpanel/leechprotectpass \ && /scripts/mysqlpasswd leechprotect ${LPROTPASS} \ && echo ${LPROTPASS} >/var/cpanel/leechprotectpass } main |
Updating your Templates
As cPanel, Inc. releases updates, you will need to update your templates.
To avoid this situation, plan regular updates on all of your templates.
To update your template, run the following commands:
Code Block | ||||
---|---|---|---|---|
| ||||
# yum update -y # /scripts/upcp |
Before you shut down the VM to create the template, run the following commands to ensure that cPanel, Inc. does not lock your license:
Code Block | ||||
---|---|---|---|---|
| ||||
# /scripts/restartsrv_chkservd --stop # /scripts/restartsrv_cpsrvd --stop # rm -f /usr/local/cpanel/cpanel.lisc |
The following bash script runs the commands shown above:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/bin/bash readonly PROGNAME=$(basename $0) readonly PROGDIR=$(readlink -m $(dirname $0)) readonly ARGS="$@" is_file() { local file=$1 [[ -f $file ]] } is_dir() { local dir=$1 [[ -d $dir ]] } main() { is_dir /usr/local/cpanel \ && /scripts/restartsrv_cpsrvd --stop \ && /scripts/restartsrv_chkservd --stop is_file /usr/local/cpanel/cpanel.lisc \ && rm -f /usr/local/cpanel/cpanel.lisc is_file /etc/.whostmgrft \ && rm -f /etc/.whostmgrft echo "You should now shutdown this instance and template it up" } main |
Virtualization-specific Caveats
OpenVZ/Virtuozzo
Common Issues:
- The hostname on OpenVZ/Virtuozzo may not meet the requirement of a Fully Qualified Domain Name (FQDN) on CentOS 7. Virtuozzo controls the hostname via VPS configuration (the
--hostname
parameter of thevzctl
orprlctl
commands). If you set the hostname manually from inside the VPS, Virtuozzo will reset the hostname on the next reboot. Ensure that you set up the full hostname correctly after you provision the VM, because cPanel & WHM requires an FQDN. - OpenVZ/Virtuozzo requires that you enable second-level quotas, which can cause quota-initiation issues. For more information read our Enable Quotas on a Virtuozzo® VPS documentation, or Virtuozzo's Documentation.
- Jailshell requires specific steps to enable a full proc mount. For more information, read our Best Practices for cPanel Virtualization Templates documentation.
Related Documentation
Localtab Group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|