Virtualmin Hosting | Webmin – Centos7

Virtualmin is a web hosting control panel for Linux and BSD systems like cPanel or Plesk. Virtualmin is the cost-effective and comprehensive solution to virtual web hosting management because two versions of Virtualmin exist, under separate licenses.

Virtualmin GPL

This is the absolutely free  version, licensed under the GPL. It is under active development, but does not contain all of the features of the Pro version.

Virtualmin Pro

This is the commercial version that you have to pay for. It includes numerous features not in the GPL version.

More details about can be found from below link

https://www.virtualmin.com/buy/virtualmin

Today we are going to install free virtualmin version on Centos7 and proceeding with hosting a website through Virtualmin Panel.

Download the desired Virtualmin installer.

wget http://software.virtualmin.com/gpl/scripts/install.sh

Now before proceeding with executing the install script, make sure packages like postfix, mariadb, mysql, httpd, dovecot, courier are not installed in the server. If its already installed, remove those.

Now just need to execute the installation script and that’s it.

sh install.sh

Noticed below error message in the installation screen

Installing dependencies and system packages ./slib.sh: line 206: 9170 Segmentation fault tput rc
 ./slib.sh: line 206: 9171 Segmentation fault tput cnorm

Now access the Virtualmin using url like ” https://SERVERIP:10000 “.  Replace SERVERIP with your real server IP address and complete the Post-Installation Wizard. The logins used for Virtualmin panel is server root login details.

The post installation wizard  is necessary to configure packages and elements of the Virtualmin. So click “Next”  to continue to post installation wizard.

Continue to click “Next” button until post installation wizard window  for “MySQL Password ” appears.

Put a desired MySQL password in the wizard and click “Next” and I got below error in next window.

DBI connect failed : Access denied for user 'root'@'localhost' (using password: NO)

over SSH I can see the mariadb service is running fine. So I rerun the post-installation wizard from beginning by going to

System Settings >> "Re-run install Wizard"  option from Virtualmin panel itself.

At this time We Haven’t got any error and click “Next” button and set primary, secondary name servers as you desired. Its better to tick “skip check for resolvability ” if name servers are not registered at registrar end.

Complete  rest of the steps by just clicking Next button.

We can check for Configuration errors by clicking "Recheck Configuration" option Under "System Settings"

Now by default for email accounts created through virtualmin has a format of  "username.domain". It means 
if we create and email account "[email protected]", the login username will be "info.example.com".  For using 
the regular practice like [email protected], please follow below steps before creating an email account.
Log in to the Virtualmin Panel  >> switch to  virtualmin tab >> System Settings  >>  Server Template  >> 
Default  Settings >> Choose "mail for Domain" from " Edit template section" drop down menu >> 
and change "Format for usernames that include domain" to "[email protected]". >> click "save" button.

Install Multiple PHP versions -Virtualmin

If we have multiple PHP versions installed, Virtualmin allows us to choose which version to use for a  domain, or even per-directory.

Installing PHP 5.6 and PHP 7.0 on Centos 7

yum install centos-release-scl
yum install rh-php56 rh-php56-php-mysqlnd
yum install rh-php70 rh-php70-php-mysqlnd
After  the yum installation log in to the  Virtualmin   and clicking System Settings -> Re-Check Config. 
we should see something like below.
The following PHP versions are available : 5.4.16 (/bin/php-cgi), 5.6.25 (/opt/rh/rh-php56/root/usr/bin/php-cgi)
, 7.0.10 (/opt/rh/rh-php70/root/usr/bin/php-cgi), 5.4 (mod_php)
Now we can configure which one is the default PHP version used on new Virtual Servers. The default is to use 
the Highest available. You can change that default in System Settings -> Server Templates -> Default  Settings->
 PHP Options, and on that screen you can set the default PHP version to use in the field Default PHP version.

Now follow below steps for creating a Virtual Server ( Hosting a Website)  through Virutalmin Control panel.

Log in to the Voirtualmin panel as root user >> Switch to Virtualmin Tab >> Click "Create Virtual Server" 
>> In the "Domain name" and " " Administration password " field gave website name and password accordingly >> 
Leave rest of the settings as is >> Click "Create Server" button.

Install Let’s Encrypt SSL Certificate Automatically in Virtualmin / Webmin

The built-in Let’s Encrypt feature in Webmin and Virtualmin makes it very easy to request, authenticate the domain ownership, create, generate, install, apply and renew SSL certificates and private keys for various virtual servers (domains and websites).

Follow below steps for configure and set up Virtualmin and Webmin to handle and manage everything about Let’s Encrypt SSL certificates.

Issue below command for installing Let’s Encrypt Client.

yum install epel-release
yum install letsencrypt
Login to Webmin / Virtualmin as root user.
Go to Webmin tab.
Go to Webmin -> Webmin Configuration.
Click or tap on Module Config link or button on the top left corner.
In the text box for Full path to Let’s Encrypt client command, enter the full path to the Let’s Encrypt 
  client executable (usr/bin/letsencrypt). Click or tap Save when done.

Request and install Let’s Encrypt SSL Certificate for Virtual domains.

Go to Virtualmin tab.

Select the virtual server / domain which you want to enable SSL protocol with SSL certificate from
Let’s Encrypt from the drop-down list.

Select Edit Virtual Server.

Go to Enabled Features.

Check the Apache SSL website enabled?. Hit Save Virtual server when done.

Now go to server Configuration -> Manage SSL Certificate.

Go to Let’s Encrypt tab.

leave settings as is and Hit Request Certificate.

Now we can use the same SSL certificate for securing Webmin, Usermin, Postfix, Dovecot and ProFTPD of the domain name itself.  

let’s say if we secure Webmin, the  virtualmin can access using domain name without having any SSL warning.

To do so, go to Server Configuration -> Manage SSL Certificate. In Current Certificate tab, 
click or tap Copy to Webmin,Copy to Usermin, Copy to Dovecot, Copy to Postfix, and/or 
Copy to ProFTPD for each application you want to use the Let’s Encrypt certificate.

Now How to Setup/Change Hostname through Virtualmin/Webmin

Log in to Virtualmin Panel
 Click on the Webmin section
 Select the Networking option
 Click the Network Configuration module
 Select the Hostname and DNS Client module
 In the hostname filed put appropriate name and hit save button.


Now issue SSL for server hostname and access webmin/virtualmin using hostname without having SSL warning.

Go to Webmin -> Webmin -> Webmin Configuration -> SSL Encryption. Then go to Let’s Encrypt tab.

In Hostnames for certificate filed put serverhostname

Choose Website root directory for validation file and
select the main domain virtualhost.

Choose yes for Copy new key and certificate to Webmin?

Click “Request Certificate” button.

For installing Roundcube and PhpMyAdmin in Virtualmin, follow below steps.

Login to Virtulamin  >> Click install scripts >> Click "Available scripts" tab >> Chose "PhpMyAdmin >> 
Click "Show install options " >> Leave settings as is and click "Install Now" button.
Repeat same step for Roundcube install too.

By default PhpMyAdmin and Roundcube installed through virtualmin can be accessed using below url. Replace example.com with the real domain name of yours.

http://example.com/roundcube/

http://example.com/phpmyadmin/

How to create an email account

Log in to the Virtualmin Panel

Choose the domain you would like to add the email account to. You can do that by selecting the domain name
from the drop-down box on the top-left.

Click Edit Users.

Click Add a user to this server.

You can now enter the email address, full name, and password to use for this email account. Leave other
settings as is.

Click Create, and Virtualmin will add the email account to your server.

How to create an FTP account

Log in to the Virtualmin Panel

Choose the domain you would like to add the FTP account to. You can do that by selecting the domain
name from the drop-down box on the top-left.

Click Edit Users.

Click Add a website FTP access user (on the far-right).

In the Email Address, enter the name for the new FTP account.

Enter the FTP user’s name in the Real Name field.

You can enter a password in the Password field if you wish to override Virtualmin’s random password that
it puts there by default.

Leave other settings as is

Click Create.

How to change PHP script execution mode  like run domain php scripts as Apache mod_php, cgi, fcgid or FPM

Log in to the Virtualmin panel
Choose domain name from Virtualmin section >> Click "Server Configuration " >> Click Website options >>  
Select appropriate PHP script execution mode and hot "save" button.

How to edit PHP.INI Virtualmin

Log in to the Virtualmin panel

Choose the domain name from Virtualmin Section

Click “Services ” >> Choose desired PHP version >> Click Resource Limits option.

Here we we can set php limit like memory_limit etc.

Instead of clicking “Resource limits” if we click “Edit Configuration Manually”, we are able to
set all php parameters directly through php.ini file.

How to create MySQL database and associate a user in Virtualmin

Log in to the Virtualmin panel

Choose desired domain  >> Click Edit Database option >> Click Create new Database option

Gave Desired Database name and Click Create button.

How to create New database user in virtualmin

Log in to the virtualmin panel

Switch to  Webmin  >>  Click “Servers” >> Click “MySQL Database Server” >> Click “User Permissions”

Click “Create new user” under the table listing current users
Enter a user name and password
Select permissions (these are global privileges – you can set privileges for individual databases in
another section). Means leave as is.

Type Host as “localhost”
Click “Create”

To change permissions for specific databases, follow these steps

From the MySQL Database Server page, click “Database Permissions”

Click the name of the database you want to manage
For “Username” toggle the box to the right of the anonymous box and enter the user you want to have
permissions for this database
Select the permissions you want to grant. To select multiple permissions, hold the Control key and
click them Click “Save”.

By default the domains document root are like cPanel and its under /home directory. For example like “/home/domainusername/public_html“.  Replace domainusername with real domain user name of yours.

Also the default Apache virtual host for domains are created in the file /etc/httpd/conf/httpd.conf.

Additionally a Sample Apache Virtualhost entry for domain will look like below.

< VirtualHost 98.143.148.190:443 >
SuexecUserGroup “#1000” “#1000”
ServerName rosetestvpn.tk
ServerAlias www.rosetestvpn.tk
ServerAlias webmail.rosetestvpn.tk
ServerAlias admin.rosetestvpn.tk
DocumentRoot /home/rosetestvpn/public_html
ErrorLog /var/log/virtualmin/rosetestvpn.tk_error_log
CustomLog /var/log/virtualmin/rosetestvpn.tk_access_log combined
ScriptAlias /cgi-bin/ /home/rosetestvpn/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
< Directory /home/rosetestvpn/public_html >
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
FCGIWrapper /home/rosetestvpn/fcgi-bin/php7.0.fcgi .php
FCGIWrapper /home/rosetestvpn/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/rosetestvpn/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/rosetestvpn/fcgi-bin/php7.0.fcgi .php7.0
< /Directory >
< Directory /home/rosetestvpn/cgi-bin >
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
< /Directory >
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.rosetestvpn.tk
RewriteRule ^(.*) https://rosetestvpn.tk:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.rosetestvpn.tk
RewriteRule ^(.*) https://rosetestvpn.tk:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.6
RemoveHandler .php7.0
php_admin_value engine Off
FcgidMaxRequestLen 1073741824
Alias /dav /home/rosetestvpn/public_html
< Location /dav >
DAV on
AuthType Basic
AuthName “rosetestvpn.tk”
AuthUserFile /home/rosetestvpn/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.6
RemoveHandler .php7.0
RewriteEngine off
< /Location >
SSLEngine on
SSLCertificateFile /home/rosetestvpn/ssl.cert
SSLCertificateKeyFile /home/rosetestvpn/ssl.key
SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
SSLCACertificateFile /home/rosetestvpn/ssl.ca
php_value memory_limit 32M
php_value suhosin.session.encrypt Off
IPCCommTimeout 41
< /VirtualHost >

< VirtualHost 98.143.148.190:80 >
SuexecUserGroup “#1000” “#1000”
ServerName rosetestvpn.tk
ServerAlias www.rosetestvpn.tk
ServerAlias webmail.rosetestvpn.tk
ServerAlias admin.rosetestvpn.tk
DocumentRoot /home/rosetestvpn/public_html
ErrorLog /var/log/virtualmin/rosetestvpn.tk_error_log
CustomLog /var/log/virtualmin/rosetestvpn.tk_access_log combined
ScriptAlias /cgi-bin/ /home/rosetestvpn/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
< Directory /home/rosetestvpn/public_html >
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
FCGIWrapper /home/rosetestvpn/fcgi-bin/php7.0.fcgi .php
FCGIWrapper /home/rosetestvpn/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/rosetestvpn/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/rosetestvpn/fcgi-bin/php7.0.fcgi .php7.0
< /Directory >
< Directory /home/rosetestvpn/cgi-bin >
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
< /Directory >
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.rosetestvpn.tk
RewriteRule ^(.*) https://rosetestvpn.tk:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.rosetestvpn.tk
RewriteRule ^(.*) https://rosetestvpn.tk:10000/
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.6
RemoveHandler .php7.0
php_admin_value engine Off
FcgidMaxRequestLen 1073741824
Alias /dav /home/rosetestvpn/public_html
< Location /dav >
DAV on
AuthType Basic
AuthName “rosetestvpn.tk”
AuthUserFile /home/rosetestvpn/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.6
RemoveHandler .php7.0
RewriteEngine off
< /Location >
php_value memory_limit 32M
php_value suhosin.session.encrypt Off
IPCCommTimeout 41
< /VirtualHost >

From the above virtualhost entry we can see the the php handler for each domains are kept under domains home directory itself. Like in the folder “/home/domainuser/fcgi-bin“. Replace domainuser with your real domain username. If we delete anything from “fcgi-bin” folder, the php scripts won’t run under website.

By |2018-01-27T11:54:28+00:00January 27th, 2018|Linux, Virtualmin, Webmin|