Install virtualmin / webmin on centos – complete server setup.

Install Virtualmin:

Virtualmin is free control panel for server. It helps to manage multiple host / websites by managing Apache, Nginx, PHP, DNS, MYSql, FTP, SSH and many more. It is recommended to install virtualmin in fresh server rather ran existing server to prevent conflicts.

This tutorial will help you to setup complete virtualmin server with everything you need to run websites on your VPS or dedicated servers.

Step 1:
Update Yum and install perl and wget which is required for virtualmin.

$ yum update
$ yum install wget
$ yum install perl

Step 2:
Setup Hostname for server:

More details on hostname can be read here.
Let setup hostname as ( this is just a example you can setup any hostname you like but make sure you have that domain name with you. )

$ hostname

Step 3:
Set timezone:

Please refer to this article for timezone setup (click here)

Step 4:
Add more swap memory:

Please refer to this article for swap memory (click here)

Step 5:
Temp folder management.

we need to delete tmp folder time to time otherwise it will run out of space. To do that lets intsall tmpwatch and set the corn job to run it daily to auto clean up.

$ yum install tmpwatch -y

#update corntab and add following line
0 4 * * * /usr/sbin/tmpwatch -am 12 /tmp

Step 6:
Install virtualmin:

$ wget
$ chmod +x
$ ./

Once virtualmin installed, you can login to virtualmin admin by ip address
https:<your server ip>:10000

Step 7:

a) Change port number for virtualmin.

Login to your server https:<your server ip>:10000 with root and system password .

go to webmin > webmin configuration > port and addresss  and change default port 10000 to any port you like .

B) Fix DNS  open resolver attack :

Open DNS will allow anyone to use your dns server and send attack to other servers. So to prevent this we need to allow only our ip ( IP of server). Please refer to this article to fix this problem. ( click here)
Before we work on virtualmin, lets install additional modules for the server.


We can install any open source firewall but my personal choice is CSF firewall. Setup is very simple.  Please read document to install it and also option to add interface to webmin.

Installation is quite straightforward:

cd /usr/src
rm -fv csf.tgz
tar -xzf csf.tgz
cd csf

To install or upgrade the csf webmin module:

Install csf as above
Install the csf webmin module in:
  Webmin > Webmin Configuration > Webmin Modules >
  From local file > /usr/local/csf/csfwebmin.tgz > Install Module

CSF Firewall comes will lots of options. But to start with , make sure your newly added port for virtualmin / webmin is listed in port list.

a) go to Webmin > System > ConfigServer Security & Firewall > Firewall Configuration 
make sure your port ( for webmin ) is there in  TCP_IN, TCP_OUT. If not please add it. 

b) You can also click on check server security to check if there are any loop holes. 
c) Once you happy you can change it from testing mode to live. 

d) SSH only login

Its better to have SSH only login to prevent brute force attacks. Please refer to this article for setup instruction. ( click here)


Aditional Setups:

So far you are now ready to host domains / website in your site but you may also consider to install following for more security.

a) Php_suhosin
Php Suhosin will prevent any illegal activity in php code to execute.

b) mod Security:
Its a proxy to prevent cross browsers attacks, injection attacks, brute force e.t.c

c) Nginx

light weight server for web application. ( click here for how to )



How to create cron Job in Virtualmin

How to create cron jobs in virtualmin / webmin

Steps 1: Login to your virualmin account.

Step 2:  Go to Webmin >> System >> Scheduled Cron Jobs 

In the tab section click on Create a new scheduled cron job.

In from fill the data as follows:

a ) Execute cron job as : < give the username > If cron job is related to selected domain then give the username for that domain or use root.

b) Command: If you want to run the command like ps ( to few running process ) then just type the command. If you need to run file then give full path of the file.

c) Input to command: This you can skip, you only need to give input value if your command needs input while its running.

d) When to execute: Default is Hourly, but you can select your required time frame to run it

Step 3: Click on create to create cron job.