Virtualmin Update Error – [Errno 14] PYCURL

If you haven't updated your version of Virtualmin/Webmin for a while and you encountered this error when 
you tried to update - e.g. from version 4.12 to the current version 4.17:

[Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" Trying other mirror.
See the screenshot below:
Virtualmin-Update-Error-Pycurl-Err-22

It usually means the yum cache-files are stale, i.e. the location of the required files for the update
has changed. To fix this, run:

# yum clean all
# yum check-update 

That will refresh the yum cache. Once that is done, you can run update again from the Virtualmin interface
or simply run the update command from the commandline:

# yum update



Running Virtualmin on a different port

The default port Webmin & Virtualmin listen to is port 10000. Many security professionals believe that changing the default ports of well-known services (e.g. SSH at port 22) to a different port does nothing to make the server more secure.

In a way, they are correct, but nevertheless, there are many benefits of changing the default ports of the well-known “admin” services – such as Webmin/Virtualmin and sshd. The most important benefit is that it discourages automated scanners – usually run by script kiddies looking for systems to exploit. These automated scripts will usually “move on” to another target if the known-ports are closed, e.g. if port 10000 is closed (i.e. Virtualmin listening at a different port, say, 10101), the automated script will then go on to another target in the list.

This saves resources on your server because usually, these automated scripts will follow up with a password cracker/brute-force attack to try to guess the passwords if it finds the port 10000 open (i.e. Webmin/Virtualmin is running on that port). This cause un-necessary stress on the server. Furthermore, if the administrator’s password is weak, there is a high probability that the brute-force password attack may work.

So, for those reasons, I would say, take a couple of minutes to change the default port of your Webmin/Virtualmin server.

AWStats Error – Missing Headers

Recently, I installed the RPMForge repo to setup “mod_fastcgi” on my Virtualmin server. In the “yum update” process, it inadvertently upgraded the AWStats package from the default Virtualmin package awstats-7.0-3.el6.noarch to Repoforge’s awstats-7.1-1.el6.rf.noarch.  This caused the dreaded Error – Missing Headers in AWStats!

Running the “recheck configuration” in Virtualmin showed this error message:

“The AWstats command /usr/share/awstats/wwwroot/cgi-bin/awstats.pl was not found on your system.”

Searching further, it seems that Virtualmin do not recommend using 3rd party repositories as they can cause conflicts to existing packages, as in this case. I have 2 options – disable RepoForge’s repository, remove AWStats and then re-install AWStats from Virtualmin’s repo again. The risk with this method is that I might lose my existing traffic data.

So, the other more long winded method is to find out where does Virtualmin store the configuration for AWStats software and see if I can change the settings – fortunately, it is relatively easy to do so.

Goto Virtualmin –> System Settings –> Features and Plugins.

Click on the “Configure” link:

AWStats Configuratin in VirtualminOn the following page, you will see:

AWStats path in Virtualmin

Change the following Path:

Full  path to AWstats program:  /var/www/awstats/awstats.pl

Full path to AWstats icons directory: /var/www/awstats/icons

Full path to AWstats lang directory: /var/www/awstats/

Full path to AWstats lib directory: /var/www/awstats/

Full path to AWstats plugin directory: /var/www/awstats.

Click “Save” and AWStats should be working fine again.

Here’s the final screenshot after the change.

AWstat Missing Header Error Fixed

 

 

Error Upgrading PHP 5.3 to 5.4

CentOS 6.5 ships with the default PHP 5.3.3 (although support for PHP 5.3 officially ended on 14th August 2014). Naturally, the CentOS team has backported all the security issues discovered in PHP5.3, and it is a stable and matured version. However, the PHP team at php.net recommends upgrading to PHP 5.4 to fully benefit from all the recent enhancements, bug-fixes and security patches in PHP.

This tutorial will guide you through the steps needed to upgrade PHP 5.3 to the latest PHP 5.4 without breaking any of existing websites in Virtualmin.

php-5.4

The first step is to install the “REMI” software repository (this software repo is maintained by French guy, Remi Collet) and it (usually) has the latest stable version of the software used by RedHat/CentOS and the EPEL repo. In fact, it requires the EPEL repo to be installed on your server before you can install the REMI repo.

Note the latest version of these software, visit:

EPEL Repo: http://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

REMI Repo:  http://blog.famillecollet.com/pages/Config-en

For the purpose of this tutorial, we’ll be using the repositories for CentOS 6.5.

Step 1: Download EPEL and REMI and install the repository

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Step 2: Update EPEL repository

yum update -y

Step 3: Enable the REMI repo and Upgrade software

yum –enablerepo=remi upgrade mysql

The command above may seemed a bit odd, why “upgrade mysql” when we want to actually upgrade PHP 5.3 to PHP 5.4? The reason is that the yum software utility will install/upgrade all dependencies to ensure that all the software pieces work together.

The default Virtualmin installation has setup “php-mysql” – and when we issue the command ‘upgrade mysql’ – the yum utility will also upgrade all the related PHP packages (e.g. php-gd, php-devel, php-mbstring, php-cli, etc) from version 5.3 to 5.4

Once the installation/upgrade process has completed, you need to run the ‘mysql_upgrade’ command to update some of the essential tables in MySQL 5.5.

mysql_upgrade -uroot

Enter the mysql root password when prompted. Once done, you can verify you have the latest version of PHP 5.4 and also MySQL 5.5

php54-mysql55

Step 4: Edit /etc/httpd/conf.d/php.conf

This is the final step before you restart Apache.  In the /etc/httpd/conf.d/ directory, you will find the following *.conf files – e.g.

  • fcgid.conf
  • php.conf
  • awstats.conf
  • webalizer.conf
  • mailman.conf
  • etc.

These are the additional directives that Apache will run each time it starts (or restarts). When we upgrade PHP 5.3 to PHP 5.4, the configuration file “php.conf” was updated to include the following lines of code:

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

You need to either delete  those 3 lines or comment them out. And in their place, insert:

AddHandler php5-script .php

This will prevent your PHP powered websites from breaking when you restart Apache.

Now, go ahead and issue the command to restart Apache and enjoy the latest version of PHP 5.4.34 (as of Oct 2014) on your Virtualmin server.

 

Sub-server vs Addon Domains

Virtualmin uses different terms which you may find confusing – especially if you’re coming from the Cpanel/WHM background. For example, a “hosting account” in Cpanel is known as a “Virtual Server” in Virtualmin.

Virtual Servers vs Hosting Accounts

In the Cpanel/WHM, one would click on the “Create Account” link to create a new hosting account, and select the appropriate hosting packages.

Create Hosting Account in Cpanel

In Virtualmin, one would click on the “Create Virtual Server” link and select the appropriate

  • Server Template  (there is no Cpanel equivalent for “Server Templates”)
  • Account Plan  (equivalent to CPanel “Packages”)

Create Virtual Server in Virtualmin

Take note of the “New virtual server type“:

The default is “Top level server” – which means, you’ll be creating another separate hosting account (i.e. different user/login ID).

If you click on the “Sub-server” link – you can either create an “addon” domain (in Cpanel lingo) or a subdomain of the parent domain in this Virtual server.  (Refer to the “Sub-servers Vs Addon Domains” section in this article).

I want to highlight the “Server Configuration Template” – from the screenshot above, you can see that it is showing “Server-X1″ as the template to create this new virtual server.

A Virtualmin’s “Server Template” is a powerful feature that enables the system administrator to custom-tailor what features to enable or disable for the virtual servers.

For example, you can create a Server Template #1 that enables the “Mailman” mailing service and the MySQL database, and create another Server Template #2 that does NOT have “Mailman” and runs the PostgresSQL database instead of MySQL. This allows you to create 2 different type of Virtual Servers  (hosting accounts) – one that uses the MySQL database and has the Mailman mailing service enabled, and another type that uses the PostgresSQL database and does not have access to Mailman service.

You can  create as many Server Templates as you want, each with different settings and functionalities.

There is no “Server Template” equivalent in Cpanel/WHM – each hosting account has the same features and functions enabled. You can only specify the limits to the resources allocated, e.g. how many mailboxes, how many databases, the monthly bandwidth quota, etc.  in the “Package type”

Sub Servers vs Addon Domains

This is another source of great confusion – especially if you are familiar with Cpanel.

In Cpanel, your main hosting account is associated with the primary (main) domain, let’s say “Foo.com”.  You can also create additional domains such as “Bar.com”  or “MyFoo.com” under your main hosting account – these domains are known as “Addon” domains in Cpanel.

If you create “recipes.foo.com” in Cpanel, it is known as a “subdomain”.

But in Virtualmin, the main/parent domain “Foo.com” is known as the parent “Virtual Server”, and if you want to create additional domains such as “Bar.com” or “MyFoo.com” – these are known as “Sub-server” in Virtualmin (not “addon” domains).

What about “recipes.foo.com”?  In Virtualmin, it is also known as a “Sub-Server” – yes, I know, it’s confusing. But this is the naming convention chosen by the developers of Virtualmin. After a while, you’ll get used to it and it won’t be as confusing as before.

 

Summary of Terminologies used in Virtualmin

A “Virtual Server” (in Virtualmin) is known as a “Hosting Account” (In Cpanel)
A “Sub-Server” (in Virtualmin) is known as “Addon Domain” (in Cpanel)
A “Self/Own Sub-Server” (in Virtualmin) is known as “Subdomain” (in Cpanel)

How to install the latest Nginx in Virtualmin

nginx

This short tutorial is based on this original article at Virtualmin wiki with a few tweaks to enable us to run the latest stable version of Nginx software in Virtualmin.

Over the short few years since Nginx was first introduced, it has grown by leaps and bounds in popularity and it is currently being used by 40% of the world’s busiest websites. It is fast, stable and uses less resources compared to the Apache webserver. But we will not go into the Apache vs Nginx here …

But before you install Nginx, please be aware of the following:

  • If you currently have a Virtual Server running on Apache, you can’t install Nginx because Virtualmin will only allow you to run either Apache or Nginx. You can’t run both on port 80.
  • Once you’ve installed Nginx, you will need to disable Apache from the Virtualmin’s Plugin & Features page.
  • Virtualmin (at this point in time) does not support Nginx as Reverse-Proxy. If you are interested in this topic (running Nginx as reverse proxy to Apache), let me know and I’ll put up a tutorial on it later.

You can install Nginx from Virtualmin’s software repository which provides an older version of the Nginx software (version 1.0.9 as of this writing – 23 Oct 2014). Most software repositories such as the CentOS repo, EPEL, Ubuntu, etc do not carry the latest version. But if you want to install the latest stable version, you need to go to the source directly and install the Nginx repository.

Goto: http://nginx.org/en/linux_packages.html#stable and download the version for your Operating System.

In our case, we will base this tutorial on CentOS 6.5.

Step 1: Download the Nginx repo and install it. Then run the ‘yum’ command to install Nginx

wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm

rpm -ivh nginx-release-rhel6*

yum install nginx -y

Step 2: Shutdown the Apache webserver & start the Nginx webserver

/sbin/service httpd stop && chkconfig httpd off

/sbin/service nginx start

Step 3: Install the Virtualmin’s Nginx plugin

yum install wbm-virtualmin-nginx wbm-virtualmin-nginx-ssl

Step 4: Login to Virtualmin and go to “System Setings” –> “Plugin & Features”

Disable the following:

  • Apache Webserver
  • SSL Website
  • DAV login
  • Webalizer Reporting
  • AWstats Reporting
  • Mailman
  • Protected Directories
  • Subversion repositories

Enable the following:

  • Nginx Website
  • Nginx SSL website

See the screenshot of the Virtualmin’s “Plugin and Features” page:

ilovevirtualmin-slider3

Once you’ve done this, Nginx support has been enabled in Virtualmin and you should be able to create Virtual Servers as normal.

However, do take note that when using Nginx instead of the Apache webserver, there are some limitations to consider:

  • Nginx does not support CGI, so any applications or Virtualmin scripts that use CGI will not work.
  • PHP can only be executed via FastCGI, and all PHP scripts run with domain owner permissions.  Virtualmin will setup a PHP FastCGI server process that communicates with Nginx for each virtual server. mod_php is not supported.
  • Only one PHP version (usually the highest) will be used by Nginx.
  • You can only install one SSL certificate per IP address on your virtual server – even if you have a wildcard or UCC certificate. To install additional certificates, you would need to have additional IP addresses.