When I started my freelancer career a decade ago, AppServ was my development environment. It is essentially an one-click setup WAMP. I run WordPress, xtCommerce, MediaWiki, and lots of other popular packages. Time flies, people changed, things changed. And the time to upgrade my old server has come.
sudo do-release-upgrade
and called it a day. But that would be uninteresting. And boring. Since I work in a company that runs hundreds of websites and serves billions of users everyday, it would be disappointing if I didn’t have something fancier than the old setup.
TL;DR:
#!/bin/bash
# Prepend mirror to source.list
sudo echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial main restricted universe multiversen$(cat /etc/apt/sources.list)" > /etc/apt/sources.list
sudo echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-updates main restricted universe multiversen$(cat /etc/apt/sources.list)" > /etc/apt/sources.list
sudo echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-backports main restricted universe multiversen$(cat /etc/apt/sources.list)" > /etc/apt/sources.list
sudo echo -e "deb mirror://mirrors.ubuntu.com/mirrors.txt xenial-security main restricted universe multiversen$(cat /etc/apt/sources.list)" > /etc/apt/sources.list
# Add HHVM: taken from HHVM official install guide
# https://docs.hhvm.com/hhvm/installation/linux#ubuntu-16.04-xenial
apt-get update -y
apt-get install -y software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"
# Let's encrypt certbot.
add-apt-repository -y ppa:certbot/certbot
# Node.js - please uncomment whichever version you prefer
# v7
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
# v6
# curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
# update
apt-get update -y
# useful tools, optional
# build-essential is for native addons from npm, optional
# certbot https://certbot.eff.org/#ubuntuxenial-nginx
apt-get install -y screen tmux htop iftop iotop build-essential certbot python-certbot-nginx
# nginx / MariaDB / HHVM / Node
apt-get install -y nginx mariadb-client mariadb-server hhvm
# configure nginx with HHVM
/usr/share/hhvm/install_fastcgi.sh
# HHVM start when system starts
update-rc.d hhvm defaults
# enable hhvm as php-cli
/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
# reload nginx
service nginx reload
echo "All Done. Please configure the following items:"
echo "Setup MariaDB:"
echo " mysql_secure_installation"
echo "Enable PHP on nginx by adding index.php in index in:"
echo " vim /etc/nginx/sites-available/default"
And voila!
Now, what’s better than a freshly baked LAMP alternative, self-contained, LNMaH server?
That would be a HTTP2, fully secured, A+, HTTPS LNMaH server.