HostOnNet Blog

How to Install, Configure and Securing a new cPanel Server

Looking for Linux Server Admin or WordPress Expert? We can help.

First Install cPanel on the new server

root@server [~]# mkdir /home/cpins
root@server [~]#cd /home/cpins
root@server [~]#wget http://layer1.cpanel.net/latest

after this give screen command

root@server [~]#screen

If it works then OK ,but if did’nt work use

root@server [~]#yum install screen (Install all the dependencies with it )

now give screen command

root@server [~]#screen

after that give ‘ll’ or ls and you will see the file as ‘latest’

root@server [~]# ls

latest

change permission to 755

root@server [~]#chmod 755 latest

and then after give this command

#sh latest

After Installation you need to configure your WHM by login to http://yourip:2086

Now Harden/Secure the server :-

Steps to Harden server :-

Install csf as almost 80 % of your server can be secured by installing csf :-

Steps to install csf :-

Download CSF script from

root@server [~]http://www.configserver.com/free/csf.tgz

Untar File

root@server [~]tar -xzxf csf.tar.gz

Install using following command

root@server [~]sh /csf/install.sh

That’s it! Wait for installation to finish.

Once you finish with the installation login to WHM by http://yourip:2086

WHM >> Plugins >>Config Server Security and Firewall >> Click on “Check Server Security” and from here you can increase the rating which will secure your server.

Further you can optimize your httpd and mysql by adding some manual entried in httpd.conf and my.cnf file respectively

Go to /etc/httpd/conf/httpd.conf file by your favorite editor but before that do take the backup of your files

root@server [~]# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf-bk

Now Go to /etc/httpd/conf/httpd.conf file

root@server [~]# nano /etc/httpd/conf/httpd.conf

and add the following entries :-

Timeout 90
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 5
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 1200
MaxClients 1200

Save and exit and restart apache service

root@server [~]# /etc/init.d/httpd restart

Now go to /etc/my.cnf but before that take a backup of it

root@server [~] cp /etc/my.cnf   /etc/my.cnf-bk
root@server [~] nano /etc/my.cnf

Add the following entries :-

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-locking
max_connections=500
query_cache_limit=1M
query_cache_size=16M
query_cache_type=1
max_user_connections=25
interactive_timeout=10
wait_timeout=10
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=1M
max_connect_errors=10
thread_concurrency=8
myisam_sort_buffer_size=32M
server-id=1
local-infile=0

[mysqld_safe]
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer=32M
sort_buffer=32M
read_buffer=16M
write_buffer=16M

[myisamchk]
key_buffer=32M
sort_buffer=32M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

Save and Exit and restart mysql service

root@server [~] # /etc/init.d/mysql restart

Thats it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.