Setting up a new server. Ubuntu 18.04

Setting up a new server. Ubuntu 18.04

I hate moving products from server to server.

Over the years I have documenting how to setup certain packages and tools on a case by case basis but I have never documented how I setup a completely new server.

I decided to move all my companies products over to EC2 (even though they annoyed me a lot) so figured I'd outline the things I had to do to get back up and running.

  • I moved all of my files over from the old server using rsync.

rsync -chavzP --stats root@45.33.40.75:/home/ /home

  • I enlarged the base partition on my new EC2 instance using a combination of the following (for information and execution):

resize2fs /dev/nvme0n1p1
du -sh
df -sh
resize2fs /dev/sda1

  • I installed nginx
  • I copied across my nginx config files:

rsync -chavzP --stats root@45.33.40.75:/etc/nginx/sites-available/ /etc/nginx/sites-available/

  • I installed mariadb
  • I restored my databases from a backup:

mysql -u root -p < full-backup-2019-01-27.sql

  • I installed the various packages that I needed

apt-get install php7.2 php7.2-curl php7.2-dev php7.2-mbstring php7.2-zip php7.2-mysql php7.2-phalcon

  • I restarted nginx, php-fpm and mysql numerous times

service mysql restart

service nginx restart

service php7.2-fpm restart

  • I updated my DNS settings at my domain name registrar so that the A records pointed to my new EC2 instances elastic IP.
  • I verified that my domains were responding

ping pubreviews.com

  • I set up some SSL certificates for some products using LetsEncrypt as outlined here.
  • I tried and failed to install v8js using pinepains ppas (like I had previously)
  • I compiled v8 and v8js respectively from source following the guidelines outlined here
  • I made sure the PHP extension files were in the appropriate places for both cli and fpm:

echo 'extension=v8js.so' >> /etc/php/7.2/cli/conf.d/20-v8js.ini

echo 'extension=v8js.so' >> /etc/php/7.2/fpm/conf.d/20-v8js.ini

Some useful resources


Thomas Clowes

Thomas Clowes

I am a 28 year old software engineer from the United Kingdom. During the day I build multi platform applications. In my spare time I eat food and run marathons. Sometimes I write angry tweets.