Server Install: CentOS 5.3 and cPanel------------------------------------------------------------
* Your server’s IP address must be authorized to install cPanel. This can be done when purchasing your license.
* This post does not cover the CentOS installation. I hope to write on this in the future.
* Important: I’m assuming you have a fresh/clean install of CentOS 5.3. cPanel requires that you have no other software installed. If you have installed other software, there is a good chance the install may fail.
* There are many ways to configure a server. This is how I do it. I offer no guarantees that this will work for you.
Let’s begin.
Login As Root
Log into your machine using SSH. Use the ’su’ command to become the root user. You will be prompted for a password.
su
Password: [enter password]
Set Hostname
Open the file /etc/sysconfig/network and change the HOSTNAME= value to mach your Fully Qualified Domain Name (FQDN) host name.
nano /etc/sysconfig/network
HOSTNAME=hostname.domain.com
Change the host associated with your main private IP address in your /etc/hosts file.
nano /etc/hosts
127.0.0.1 localhost
192.168.x.x hostname.domain.com hostname
Finally, run the hostname command, replacing hostname.domain.com with your FQDN.
hostname hostname.domain.com
Update Yum Repositories
Let’s update our YUM packages.
yum update
Press ‘y’ to continue.
Install Perl
Perl needs to be installed. Let’s install that now.
yum install perl
Download cPanel Installation Files
cd ~
wget http://layer1.cpanel.net/latest
Begin cPanel Installation
Let’s now start the installation. This may take several hours to complete. Maybe a good time to see that movie at the theater you’ve been itching to.
sh latest
Logging In
Once completed, you should see:
cPanel Layer 2 Install Complete
Now you can login to your cPanel.
Visiting http://[your_ip_address]:2086 or https://[your_ip_address]:2087 should bring up a login prompt.
Enter root for the user ID and your root password.
Complete cPanel Installation
You should see the cPanel interface now. Go through these steps. Basic networking knowledge is needed to complete this.
Once you’re finished, you have successfully installed cPanel on CentOS Server! Congrats! The last thing is to secure your machine. We will use the iptables firewall in CentOS for this.
Securing CentOS
There are many many ways to secure your server. The important thing is to secure it using something. This is the configuration I used. You may want to add or remove entries as needed. These commands will setup a firewall using iptables and will allow basic service ports to be accessed. I suggest you read up on iptables to gain a better understanding first.
Let’s make sure iptables is installed:
yum install iptables
Enter the commands below to build your firewall:
/sbin/iptables -A INPUT -i lo -j ACCEPT
/sbin/iptables -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 443 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 110 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 25 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2082 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2083 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2086 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2087 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2089 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2095 -j ACCEPT
/sbin/iptables -A INPUT -p tcp –dport 2096 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -m state –state NEW –dport 22 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -m icmp –icmp-type 8 -j ACCEPT
/sbin/iptables -A INPUT -j REJECT
/sbin/iptables -A FORWARD -j REJECT
What did we just do?
You restricted all incoming traffic to the following ports/services:
* Port 80 – HTTP
* Port 443 – HTTPS
* Port 110 – POP3
* Port 25 – SMTP
* Port 2082 – cPanel
* Port 2083 – cPanel
* Port 2086 – cPanel
* Port 2087 – cPanel
* Port 2089 – cPanel Licensing
* Port 2095 – Webmail
* Port 2096 – Webmail (Secure)
* Port 22 – SSH
* ICMP – Ability to ping server
You can read more on the ports that cPanel uses at http://www.cpanel.net/2007/06/getting-the-most-out-of-your-systems-firewall.html.
If you need to start over, use this command to remove the current iptables:
/sbin/iptables -F
After you are done, save your iptables. If you do not, you will lose your firewall settings on reboot:
/sbin/service iptables save
You’re Done
Admittedly, I am no cPanel expert; however, if you run into difficulty, let me know. I will do my best to help. As always, I would love to hear feedback. Happy installing everyone