Category: Web Server

Virtualmin: Default IPv4 Address of 127.0.0.2

If you’ve installed Virtualmin on your fresh VPS, ran through its initial checks, and then try to add a new Virtual Server only to find that it keeps detecting and setting 127.0.0.2 as the default IPv4 address, here’s how to fix this problem.

For reference, you can determine the proper network interface to use by going to Webmin -> Networking -> Network Configuration -> Network Intefaces, which will bring you to the screen you see here.

Webmin - Network InterfacesThe line that has the red marker blocking out the IP would be the one of importance. This should be where your actual external IPv4 address is shown. Due to the fact that this seems to be an issue mainly for OpenVZ VPS servers, it’s likely that the interface will be the same for you as it is in my example: venet0:0.

To fix the issue, head over to Virtualmin -> System Settings -> Virtualmin Configuration, and then in the drop-down menu at the top of the page select Network settings. There’s a chance that the value for Network interface for virtual addresses will be defined rather than being set to Detect automatically. If so, it will likely be venet0. Either way, the setting needs to be changed. This is what the configuration page looks like in my situation.

Virtualmin - Network Configuration (Original)It needs to be changed to whatever interface was configured with your real external IPv4 address from the Network Interfaces section in Webmin – which is likely venet0:0, as already mentioned. Whatever the case, manually set the interface to whatever it is for your situation and click Save.

Virtualmin - Network Configuration (Changed)As soon as the change is applied and the page reloads, Virtualmin should display an alert informing you that the primary address has changed and virtual servers using the incorrect address may be unreachable or serving the wrong material. Simply click the button Update Incorrect IP Addresses to have Virtualmin bring you to the configuration page where you can correct the address for all Virtual Servers you have configured simultaneously.

Virtualmin - Update Incorrect IP AddressesThe Change IP Addresses configuration page should have all necessary changes automatically populated for you. You should only have to hit the Change Now button to apply the changes and complete the process.

Virtualmin - Change IP AddressesI hope this helps.

phpMyAdmin: Missing Mcrypt Extension

If you’ve set up a web server recently that included PHP, you likely installed PHP’s Mcrypt extension. However, a lot of explanations on setting up a LAMP web server mention installing the extension, but not enabling it. If you’ve installed phpMyAdmin, you have likely seen the The mcrypt extension is missing. Please check your PHP configuration. error message at the bottom of the initial page after logging in.

Fixing this issue is as simple as two commands, at least in Ubuntu/Debian.

sudo php5enmod mcrypt
sudo service apache2 reload

You’ll have to log back into phpMyAdmin once you’ve reloaded Apache’s configuration, but you’ll see the error message is now gone.

If you didn’t actually install the Mcrypt extension when you installed PHP, you can do that before entering the above commands by first entering:

sudo apt-get install php5-mcrypt

If you’re unsure if Mcrypt has been installed, you can check for it by entering:

apt-cache policy php5-mcrypt

The output of the apt-cache policy php5-mcrypt command on a system where the package is not installed will look something like:

php5-mcrypt:
  Installed: (none)
  Candidate: 5.4.6-0ubuntu5
  Version table:
     5.4.6-0ubuntu5 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

If it is installed, it would look something like:

php5-mcrypt:
  Installed: 5.4.6-0ubuntu5
  Candidate: 5.4.6-0ubuntu5
  Version table:
 *** 5.4.6-0ubuntu5 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

Some information would vary, depending on the OS and the repositories your server uses, but the output of the command would be roughly the same (on Debian/Ubuntu), and will tell you if the package is installed and what version. You can also use this command to see what version any particular package is on the repositories your Ubuntu/Debian installation pulls from.

XAMPP with Ubuntu

If you want a nicely compiled web server to use for testing, nothing beats XAMPP. And if you use Windows, it’s even nicer with XAMPP Lite. It’s so convenient, you can even run the server from a USB thumb drive.

However, I’ve learned recently that Linux doesn’t have quite as many convenient options. If you wish to set up a web server on Linux, there are countless tutorials across the net on doing it. For me, I just wanted something that I could run and test some things when I needed to without having to upload it to a production web server. Not to mention, it’s faster when everything is on a local machine. I was hoping that a XAMPP Lite setup had been released for Linux, but I was unfortunately wrong. Unlike Windows, Linux would require XAMPP to be installed in the /opt/ directory, which is owned by root. This means my system user wouldn’t be able to access the directory and directly alter files/folders, at least not without steps that extend beyond the directions given on the XAMPP website.

First off, I followed the directions for installing XAMPP exactly as described on the website. At first glance, everything looks fine. However, once I tried to access FTP using the default nobody user, I realized something was wrong. It gave me a 550 permissions error. Initial searching online seemed to indicate that the error wasn’t typical with others, so I figured something must have gone wrong with the installation. I had also installed the most recent beta version. I decided to uninstall, download the latest non-beta version and install it. Everything, again, went as expected with no errors. Again, I logged in via FTP and found that I could not create directories or alter files due to insufficient permissions. Doing a little more troubleshooting, I found that the lampp/htdocs folder was actually solely owned by root, instead of being owned by the user nobody and the root group. The nobody user had no ownership of the directory or its contained files/folders and therefore no permissions to affect it. I logged into root via terminal and changed ownership of the lampp/htdocs to nobody and from there everything worked fine accessing the directory via FTP.

A different approach would have been to change ownership of the directory to my own system user, this way I could directly alter the files/folders through nautilus without even having to run the proFTPD server. Since I am using the web server for testing locally anyway, this would have been the way to go.

For reference, here are the terminal commands used.

For listing ownership of files within a directory:

ls -l <path>

If you are already within the directory for which you want to list ownership of subsequent files and folders, you can leave the <path> value empty.

For changing ownership of the htdocs directory:

chown -R <username>:<usergroup> /opt/lampp/htdocs

Using your username for both the <username>  and <usergroup>  values will be fine.

The reason I recommend XAMPP over other Linux web server packages for using as a test server is that it is the easiest to uninstall that I have seen. Deleting the /opt/lampp directory is all that has to be done for complete removal.