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 sudouserusermod -aG sudo sudouserpasswd -l rootsu - sudouser
Set your locales
sudo apt-get install language-pack-en-basesudo locale-gensudo dpkg-reconfigure locales- exit and log back in
The following might also help:
- edit
/etc/default/localeand add:LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_TYPE=en_US.UTF-8
Enable swap
sudo swapon --showsudo fallocate -l 4G /swapfilels -lh /swapfilesudo chmod 600 /swapfilels -lh /swapfilesudo mkswap /swapfilesudo swapon /swapfilesudo swapon --show
Make swap permanent
sudo nano /etc/fstab
and add at the end:/swapfile none swap sw 0 0
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-devsudo nano /etc/profile.d/nvm.shand add:#!/bin/bash if [ ! -f ~/.nvm/nvm.sh ]; then # May need to be updated with the latest nvm release wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash fi source ~/.nvm/nvm.shsudo chmod +x /etc/profile.d/nvm.sh- For each of the users who will run it do:
source /etc/profile.d/nvm.sh
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-zshsudo cp /etc/oh-my-zsh/templates/zshrc.zsh-template /etc/skel/.zshrcsudo mkdir -p /etc/skel/.oh-my-zsh/cachesudo nano /etc/skel/.zshrc
Replace:export ZSH=$HOME/.oh-my-zsh
With:export ZSH=/etc/oh-my-zsh export ZSH_CACHE_DIR=~/.oh-my-zsh/cache
- In the same file, at
ZSH_THEMEyou can change your theme. My personal preference isbira; sudo nano /etc/default/useraddand setSHELL=/bin/zshcp /etc/skel/.zshrc ~/.zshrcandchsh -s $(which zsh)
for each of the existing userssudo reboot
Add zsh-autosuggestions to your files
sudo git clone https://github.com/zsh-users/zsh-autosuggestions /etc/oh-my-zsh/plugins/zsh-autosuggestionssudo nano /etc/skel/.zshrc
and append:source /etc/oh-my-zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
Add zsh-syntax-highlighting to your files
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /etc/oh-my-zsh/plugins/zsh-syntax-highlightingsudo nano /etc/skel/.zshrc
and append:source /etc/oh-my-zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Add Composer
sudo apt-get updatesudo apt-get install curl php-cli php-mbstring git unzipcd ~curl -sS https://getcomposer.org/installer -o composer-setup.phpsudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Add Sqlite
sudo apt-get install sqlite3 libsqlite3-dev
Install Virtualmin
sudo apt-get updatesudo apt-get upgrade -ywget https://software.virtualmin.com/gpl/scripts/install.shsudo /bin/sh ./install.sh --minimal --force
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
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.pharchmod +x wp-cli.pharsudo mv wp-cli.phar /usr/local/bin/wp
Sources
- https://draghici.net/2018/03/03/setting-new-droplet-digitalocean-webmin-lamp-ssl/
- https://stackoverflow.com/questions/31624649/system-wide-oh-my-zsh-configuration
- https://askubuntu.com/questions/131823/cant-make-zsh-the-default-shell
- https://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users
- https://askubuntu.com/questions/438150/scripts-in-etc-profile-d-being-ignored
- https://www.virtualmin.com/node/53753
- https://www.virtualmin.com/node/57208
- https://23systems.net/2016/01/installing-php-5-6-x-7-0-x-ubuntu-14-04-virtualmin-5-0gpl-using-ppa/
- https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
- https://vpsfix.com/7091/multiple-php-versions-virtualmin-nginx/
- https://www.virtualmin.com/documentation/web/multiplephp
- https://wp-cli.org/#installing

