Okay, you have a Linux (CentOS) server…. now what? Well there are lots of things you can do with a Linux server but in this blog we are only going to cover one, Web hosting with cPanel/WHM as the control panel. If you are wondering if you need a control panel to do web hosting, the short answer is no you don’t but it makes things a bit easier. There are many control panels available for Linux servers but the most popular is cPanel. We at TechRabble normally recommend cPanel to most users as it simplifies most things even an experienced sysadmin would want to do on a Linux server. In this blog post we will dive into the install and configuration of cPanel/WHM.
cPanel Install Requirements
Here is a quick list of the requirements for cPanel. We will go over each one and show how to check if your server meets the requirements.
- CPU : 266 Mhz
- RAM : 512MB (1GB recommended)
- DISK : 10GB
- OS : Red Hat Enterprise Linux/CentOS 5.x and 6.x or CloudLinux 5.x
- PERL : Installed from Repository
- MISC : Miscellaneous system configurations
1 – CPU
The cPanel install requires at least 266Mhz of CPU power. In today’s day and age this isn’t much, and even if you are running on a VPS you are fine. You can check this by running the command `cat /proc/cpuinfo |grep MHz` from your SSH client (such as PuTTy).
2 – RAM
cPanel needs at least 512MB of ram but realistically you want to be running at least 1GB if you want to host more than a handful of sites, and at least 2GB if you have any sort of moderate database traffic. You can check this by running the command `free -m -o` from your SSH client.
You will want to look at the line that says “Mem:” and ignore the “Swap:” line if you have one. As long as the number in the total column is above 256 you meet the minimum, but we really do suggest 2GB for most servers.
3 – DISK
Disk space is tricky to count because some CentOS installs have partitioned the disk in such a way where its only used for one function, like databases. Realistically you want at least 10GB for your root ( / ) partition for the cPanel install to not have issues. You can check this by running the command `df -h` from your SSH client.
You will want to look at the line where the “Mounted on” column is “/” (it’s normally the top one). If your available is close to 10GB you meet the minimum requirements. One thing we suggest is that you have the home partition ( /home ) separate from the root partition ( / ). If you don’t have two partitions and want separation you will need to reinstall CentOS before running the cPanel Install. If you don’t have access to reinstall your provider can help you with this.
4 – OS
cPanel/WHM is only supported on a few OS’s. As the title of this blog suggests we are using CentOS which is a community supported version of Red Hat Enterprise Linux. You can check your CentOS or Red Hat EL versions by running the command `cat /etc/redhat-release` from your SSH client.
Cloud Linux is also supported and is a modified version of CentOS. The command above should work for Cloud Linux as well, however we will cover Cloud Linux in a later blog. As long as you are running version 5.X or 6.X you are fine, and its time to move to the actual cPanel install.
5 – Perl
Most of cPanel runs in PERL. You most likely have this installed as PERL is the duct-tape of all Linux servers and installed by default almost always. You can confirm you have perl installed by running `perl -v` from your SSH client. If you get an error “command not found” then you can install PERL by running `yum install perl` on CentOS or `up2date -i perl` on Red Hat EL.
6 – MISC
There are some default settings that we should change before running the cPanel Install. These are pretty straight forward changes.
- SELinux : Disable SELinux by editing the “/etc/selinux/config” file. Set the “SELINUX=enforcing” to “SELINUX=disabled”
- Firewall : Disable default firewall by running the commands `chkconfig iptables off` and `service iptables stop`
- Screen : Install the Screen package, which lets you launch a command, and come back to its output later `yum install screen`
- Update System : Update your system by running the command `yum update`
Okay those are all done! Lets do a cPanel Install!
Compared to all the cPanel install requirements the actual install is really simple. A cake walk even. Use the commands below to run the cPanel install.
wget -N http://httpupdate.cpanel.net/latest
That is all there is too it. First we change to the root user home directory, then we download the cPanel install script, and then we run it using bash (sh). Go grab a cup of coffee or dinner, this could take a while to run. If you get disconnected from your server you can use the command `screen -r` once logged in as root to check the scripts status.
Post cPanel Install Configuration
Once the cPanel install is done you need to login to WHM and set the basic settings for your server. You access WHM by going to https://SERVER.IP:2087 (Replace SERVER.IP with your server’s IP address) and using your root user and password to login. There are 6 steps to completing this, and they are all pretty straight forward.
- Contact and Networking
- IP Addresses
1 – License
Self explanatory; read the agreement and click accept.
2 – Contact and Networking
The first few options in this section are for your contact information. Not all of it is required, at a minimum we suggest using a proper email address and subscribing to the cPanel Releases mailing list. We also generally enable SMS alerts on our servers.
The networking options are some of the most important steps to getting a properly running cPanel install. Enter the hostname you want your server to use, remember it has to be a fully qualified domain name (server.yourdomain.com for example) and it should be a domain you have access to the DNS records or you will host on this server. If you are not hosting the domain on this server remember to add a DNS record for your new server wherever the domain is hosted. The resolvers options are so your server can look up other domain names and you should have gotten these from your provider. If you want to use public resolvers CircleID did a decent write up of the available ones a few years ago, you can find it here. Next select your main internet connection from the list. You may only have one Ethernet device listed, but if you have multiple make sure to select the right one. You can see which Ethernet device has your main server IP on it by running the command `ifconfig -a` from your SSH client.
3 – IP Addresses
On this page you can add your other IP addresses that your provider has given you. We recommend having at least 3 IP’s total per server. Your main IP for shared web hosting, then two IP’s for Nameservers. You would add those IP addresses on this screen.
4 – Nameservers
What’s in a Name[server]? Well, everything… You can read about the different name servers, and benefits and such and pick the one you want to use. BIND is the industry standard name server and is tried and true so it is recommended for most uses. After you pick the software you will need to enter the domain you want to use for name servers. This is the domain that the sites you host on this server will set up in their registrar so the internet knows your server is hosting that site. Standard naming convention is ns1.yourdomain.com and ns2.yourdomain.com. Once you fill these in click the check box to Add “A entries” for all Nameservers and fill in the extra IP’s we added in the last step, one for each name server. If the hostname you setup is going to be hosted on this server click the check box to Add “A entries” for Hostname and fill in the main IP of your server.
5 – Services
On this page you can read about the different FTP and E-Mail servers. Sticking with the defaults is recommended for most uses, however it is your choice. There is enough support on the cPanel forums if something breaks with any of the options available. You should however always use cPHulk to help prevent your server from being hacked. The only downside to cPHulk is it will lock you out of your server if you enter the wrong password too many times. Your provider will be able to unlock your IP if that happens, or you can log in from a different IP address (run to Starbucks and hop on the WiFi) and you can unlock yourself.
6 – Quota
The last section for the initial setup is Quotas. If you are running a public host you will want to enable the quotas. If you are running this server for you and your network of friends, family and colleagues then you shouldn’t have to worry about quotas. They do add a bit of overhead to the server so if you trust your users to not be hogs then you should leave them off. Make your choice and hit Finish, see that wasn’t so bad now was it?
Create your first account/site on your new cPanel Install
Okay, we have made it this far and are in good shape. The only thing left to do is to create the first account and site on your new server. On the left sidebar menu type in “New Account” in the find box. This should remove all the options on the side bar that have nothing to do with adding a new account. Find the “Create a New Account” link and click it to open the new account page. Enter the domain name from above (yourdomain.com) and pick a username for that domain. Usernames have a max length of 8 characters (letters or numbers) and must start with a letter. Fill out both password fields and the email field.
Since this is the first account we will need to create a default package. From the next section click the “Select Options Manually” and build the defaults you want to you for accounts on your server. For definitions of the options here consult the cPanel documentation for Packages. Once you have things the way you like it click the save check box and name your package.
For the first account you should leave the rest of the check boxes unchecked. You probably do not have any Dedicated IP’s setup (which will be needed for SSL/HTTPS hosting) and most sites do not have a need for Cgi access anymore. You may want to enable Shell Access if you want to be able to login to the new account with Putty instead of logging in as root. The DNS settings are best left unchecked as well as they are generally used for more complex account creations. Check over all the options one last time and click Create. You will see some script output which should match the information provided and now you have a fully functional cPanel Install!
Please feel free to leave any comments or questions you might have in the comments section of this blog. If you have a more general question then the topic of this blog please Ask Rabble and one of the writers, editors or fellow Rabblers can help you out!