15 Sep, 2018

Virtualmin hosting on Ubuntu 16.04 x64

The following commands and ideas are useful in creating an Ubuntu hosting server using Virtualmin as a main administration interface.

As obvious, Ubuntu is one of the most popular Linux distributions. And lately Virtualmin has done some big steps towards looking great – and sometimes this is an important criteria in picking your hosting helper interface.

This installation – with small modifications – should soon apply to Ubuntu 18.04. Due to some changes in the new version, Virtualmin still needs to receive some updates and patches until it’ll work as expected.

Prerequisites and notes

  • A clean Ubuntu 16.04 x64 install;

Conventions

  • In the following commands, your sudo user will be sudouser
  • The address of your server is example.com

The Setup

Ideas on what to put in your server and commands for how to get them in:

Setup the main sudoer

The following commands will add a new user, give sudo priviledges, disable the root account and switch to the newly added user:

  • adduser sudouser
  • usermod -aG sudo sudouser
  • passwd -l root
  • su - sudouser

Set your locales

  • sudo apt-get install language-pack-en-base
  • sudo locale-gen
  • sudo dpkg-reconfigure locales
  • exit and log back in

The following might also help:

  • edit /etc/default/locale and add:

Enable swap

  • sudo swapon --show
  • sudo fallocate -l 4G /swapfile
  • ls -lh /swapfile
  • sudo chmod 600 /swapfile
  • ls -lh /swapfile
  • sudo mkswap /swapfile
  • sudo swapon /swapfile
  • sudo swapon --show

Add nvm for all users

Node.js and npm are pretty popular nowadays. Therefore, it would be nice for all users to have access to their own version and to the npm command.

  • sudo apt-get install build-essential libssl-dev
  • sudo nano /etc/profile.d/nvm.sh and add:
  • sudo chmod +x /etc/profile.d/nvm.sh
  • For each of the users who will run it do:

The above is a method that seems (almost) clean and works. However, I think it could get some improvements in the future, as this is a programmer’s solution to getting some useful tools. ?

Add oh-my-zsh to your shell

This is not a mandatory step. However, oh-my-zsh provides a nicer interface to your shell together with some useful features (e.g. better command history and autocomplete)

  • sudo apt install zsh
    You might also need to install git.
  • sudo git clone https://github.com/robbyrussell/oh-my-zsh.git /etc/oh-my-zsh
  • sudo cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrc
  • sudo mkdir -p /etc/skel/.oh-my-zsh/cache
  • sudo nano /etc/skel/.zshrc
    Replace: export ZSH=$HOME/.oh-my-zsh
    With:
  • In the same file, at ZSH_THEME you can change your theme. My personal preference is bira;
  • sudo nano /etc/default/useradd and set SHELL=/bin/zsh
  • cp /etc/skel/.zshrc ~/.zshrc and chsh -s $(which zsh)
    for each of the existing users
  • sudo reboot

Add zsh-autosuggestions to your files

Add zsh-syntax-highlighting to your files

Add Composer

  • sudo apt-get update
  • sudo apt-get install curl php-cli php-mbstring git unzip
  • cd ~
  • curl -sS https://getcomposer.org/installer -o composer-setup.php
  • sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Add Sqlite

  • sudo apt-get install sqlite3 libsqlite3-dev

Install Virtualmin

At the end of the install script, you will get a link to the Virtualmin interface. Do access it as soon as possible and fix the settings in there towards more security (e.g. change the access port).

One idea could be installing multiple php versions.

Another could be switching the default Mysql database to MariaDB or something more “funky”.

wp-cli

Sources