
Prerequisites and Server Requirements
Your VPS needs specific requirements before starting this cPanel installation tutorial. You'll need a fresh CentOS, AlmaLinux, CloudLinux, or RHEL server with at least 1 GB RAM and 20 GB disk space.
Skip Ubuntu—cPanel doesn't officially support it.
Log into your server as root and verify these requirements:
cat /etc/redhat-release
free -h
df -h /
hostname -f
The hostname command should return a fully qualified domain name (FQDN). If it doesn't, set one:
hostnamectl set-hostname server.yourdomain.com
Add this hostname to your /etc/hosts file. This prevents DNS resolution issues during installation.
Download and Execute cPanel Installation Script
cPanel provides an automated installation script that handles dependencies and configuration. Download it directly:
cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest
sh latest
Installation takes 30-60 minutes depending on your server specs. The script downloads roughly 200 MB of packages.
It configures Apache, MySQL, PHP, and other essential services. Don't interrupt the installation—it needs to complete entirely for cPanel to function properly.
Initial WHM Configuration Walkthrough
Access Web Host Manager (WHM) at https://your-server-ip:2087 once installation completes. Use your root credentials to log in.
The setup wizard walks you through essential configuration:
- Accept the license agreement
- Enter your email address for notifications
- Configure nameservers (ns1.yourdomain.com, ns2.yourdomain.com)
- Choose networking setup (most users select "Configure networking automatically")
- Set resolver configuration to use your preferred DNS servers
Point ns1 and ns2 to your server's IP address in your domain registrar's DNS settings. This enables cPanel to manage DNS records for hosted domains.
SSL Certificate Configuration for WHM and cPanel
Secure your control panels with SSL certificates. Navigate to WHM → SSL/TLS → Manage Service SSL Certificates.
Install a commercial SSL certificate for production. For testing, generate a self-signed certificate:
cd /root
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
Upload the certificate and key through the WHM interface. cPanel automatically configures SSL for ports 2083 (cPanel) and 2087 (WHM).
Enable "Require SSL" in WHM → Tweak Settings → SSL. This forces encrypted connections.
Essential Security Hardening Steps
Default cPanel installations need security hardening. Start with these critical configurations:
Disable root login over SSH:
vim /etc/ssh/sshd_config
Change "PermitRootLogin yes" to "PermitRootLogin no" and restart SSH:
systemctl restart sshd
Configure CSF Firewall:
Install ConfigServer Security & Firewall for advanced protection:
cd /usr/src
rm -fv csf.tgz
wget https://download.configserver.com/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
Configure CSF through WHM → ConfigServer Security & Firewall. Enable standard ports: 21 (FTP), 22 (SSH), 25 (SMTP), 53 (DNS), 80 (HTTP), 110 (POP3), 143 (IMAP), 443 (HTTPS), 993 (IMAPS), 995 (POP3S).
Set up cPHulk Brute Force Protection:
Enable cPHulk in WHM → cPHulk Brute Force Protection. Configure it to block IP addresses after 5 failed login attempts within 5 minutes.
MySQL Database Server Configuration
cPanel installs MySQL or MariaDB automatically, but you need to secure it. Run the security script:
mysql_secure_installation
Answer yes to all prompts and set a strong root password. This removes test databases and anonymous users.
Optimize MySQL performance in WHM → SQL Services → MySQL Configuration Wizard. Select the configuration that matches your server's RAM:
- 1-2 GB RAM: Choose "Standard" configuration
- 4-8 GB RAM: Choose "Optimized" configuration
- 8+ GB RAM: Choose "Max Performance" configuration
The MySQL slow query log tutorial provides additional optimization guidance for database performance monitoring.
Creating Your First cPanel Account
Create hosting accounts through WHM → Create a New Account. Fill in the required information:
- Domain: client-domain.com
- Username: clientuser (8 characters max, alphanumeric only)
- Password: Generate a strong password
- Email: client contact email
- Package: Select appropriate hosting package
cPanel creates the account structure automatically. The /home/clientuser/public_html becomes the document root.
It also creates separate directories for logs, mail, and backups. Test the account by accessing https://client-domain.com/cpanel and logging in with the username and password.
Package and Resource Limit Configuration
Define hosting packages in WHM → Add a Package. Configure resource limits based on your hosting offerings:
| Resource | Shared Hosting | Business Hosting | VPS Reseller |
|---|---|---|---|
| Disk Quota | 5 GB | 25 GB | 100 GB |
| Bandwidth | 100 GB | 500 GB | 1000 GB |
| Email Accounts | 25 | 100 | Unlimited |
| Subdomains | 10 | 50 | Unlimited |
| MySQL Databases | 5 | 25 | Unlimited |
Set reasonable limits to prevent resource abuse. You can modify individual accounts later if needed.
Backup Configuration and Testing
Configure automated backups in WHM → Backup → Backup Configuration. Enable daily backups and retain them for 7 days minimum.
Set backup destinations:
- Local: /backup (ensure sufficient disk space)
- Remote: FTP, SCP, or cloud storage for offsite backups
Test backup restoration by creating a test account and adding some files. Then restore from backup to verify your backup system works before you need it.
The VPS disaster recovery plan tutorial covers comprehensive backup strategies for production environments.
DNS and Nameserver Management
Configure DNS zones in WHM → DNS Functions → DNS Zone Manager. For each domain, cPanel creates standard DNS records:
- A record: Points domain to server IP
- CNAME: www subdomain alias
- MX record: Mail server configuration
- NS records: Nameserver assignments
Verify DNS propagation using dig or nslookup:
dig @8.8.8.8 yourdomain.com A
dig @8.8.8.8 yourdomain.com MX
DNS changes typically propagate within 24-48 hours globally.
Email Service Configuration
cPanel includes a complete email server with Exim and Dovecot. Configure mail settings in WHM → Service Configuration → Exim Configuration Manager.
Essential email configurations:
- Enable SpamAssassin for spam filtering
- Configure DKIM authentication for better deliverability
- Set up SPF records in DNS
- Enable MailScanner for additional security
Test email functionality by sending a message from a cPanel account to an external email address. Check headers to verify DKIM signing and SPF validation.
For comprehensive email server configuration, reference the Linux VPS mail server setup tutorial for advanced email security implementations.
PHP Version and Module Management
cPanel supports multiple PHP versions simultaneously. Configure PHP in WHM → Software → EasyApache 4.
Install commonly needed PHP versions:
- PHP 8.1 (stable, wide compatibility)
- PHP 8.2 (current stable)
- PHP 8.3 (latest features)
Enable essential PHP modules for each version:
- php-mysql (database connectivity)
- php-curl (HTTP requests)
- php-gd (image processing)
- php-mbstring (multibyte strings)
- php-xml (XML parsing)
- php-zip (archive handling)
Users can select PHP versions per domain in their cPanel → PHP Selector interface.
Performance Optimization Settings
Optimize cPanel performance with these configurations:
Apache MPM Configuration:
In WHM → Service Configuration → Apache Configuration, adjust worker settings based on your server resources:
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
Enable Caching:
Install and configure caching modules:
- mod_cache for static content caching
- mod_expires for browser cache headers
- LiteSpeed Cache (if using LiteSpeed)
Resource Limits:
Set CloudLinux limits if available. You can also configure resource limits in WHM → Account Functions → Limit Bandwidth Usage.
Ready to deploy your own cPanel server? HostMyCode managed VPS hosting provides pre-configured Linux servers perfect for cPanel installations. Our support team can assist with the entire setup process, from initial server configuration to SSL certificate installation.
Common Installation Issues and Solutions
Installation Fails with Memory Error:
If installation fails due to insufficient memory, create swap space:
dd if=/dev/zero of=/swapfile bs=1024 count=2097152
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Add to /etc/fstab for persistence:
/swapfile swap swap defaults 0 0
HTTP Error 500 After Installation:
Check Apache error logs:
tail -f /usr/local/apache/logs/error_log
Common causes include incorrect file permissions or PHP module conflicts. Fix permissions:
/usr/local/cpanel/scripts/fixeverything
MySQL Won't Start:
Check MySQL error log:
tail -f /var/lib/mysql/`hostname`.err
Usually caused by insufficient disk space or corrupt InnoDB files. Clean up disk space and restart MySQL:
systemctl restart mysql
Monitoring and Maintenance Tasks
Establish regular maintenance routines to keep your cPanel server healthy:
Weekly Tasks:
- Review backup completion status
- Check disk space usage
- Monitor email queue size
- Review security logs for suspicious activity
Monthly Tasks:
- Update cPanel to latest stable version
- Review and optimize MySQL performance
- Clean up temporary files and logs
- Test backup restoration procedures
Monitor Key Metrics:
- CPU and memory usage
- Disk space consumption
- Apache connection count
- MySQL query performance
Use WHM → System Health to monitor these metrics. You can also implement external monitoring with tools covered in the Linux VPS monitoring with Netdata tutorial.
Next Steps and Advanced Configuration
With cPanel successfully installed, consider these advanced configurations:
- Set up CSF clustering for multi-server management
- Configure WHMCS for automated billing integration
- Implement advanced backup solutions with JetBackup
- Set up CloudFlare integration for CDN and security
- Configure LiteSpeed Enterprise for improved performance
Regular updates keep your installation secure. Enable automatic updates in WHM → cPanel Updates, but test on staging servers first.
This tutorial provides the foundation for reliable web hosting infrastructure. Combined with proper security hardening and monitoring, you'll have a solid hosting platform capable of serving multiple clients efficiently.