Nginx
About
Nginx (pronounced engine-x) is web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. It's also a modern alternative to something like Apache, IIS, or Caddy.
Prerequisites
An nginx installation should be pretty accessible regardless of your OS. This guide is specifically written for Ubuntu Server 18.04 LTS, but should work on any other type of Unix operating system.
- nginx/1.14.0 (Ubuntu)
- PHP 7.2.10-0ubuntu0.18.04.1 (cli)
- MySQL v14.14 Distribution 5.7.24
If you've just installed a new operating system, you'll want to update your local package index by running sudo apt-get update
, and then add the Universe repository by running sudo apt-add-repository universe
.
Installing nginx
To start, you're going to want to install nginx using the aptitude package manager. You can do this by running sudo apt-get install nginx
. Once you run that, you'll want to go through the configuration prompt that appears.
After nginx and its subsequent dependencies have finished installing, you'll want to let it through the firewall by running sudo ufw allow 'Nginx HTTP'
. Check what your current IP is by running ifconfig
, and then look for whatever interface looks correct. In this instance, the proper interface is eth0
.
-
After running the command, the first indented line should say inet and then an IP address afterwards. Verify functionality of nginx by going to your web browser and typing http://{ip}/
where {ip}
is what follows after inet.
If the default nginx page displays, continue to the next section.
Installing MySQL
The process of installing MySQL is fairly similar to installing nginx, although MySQL does require a little bit of configuration before it will function properly. Start off by running sudo apt-get install mysql-server
, and then once it finishes run the setup script by typing sudo mysql_secure_installation
.
The first thing that the installations script will ask you is if you'd like to enable the VALIDATE PASSWORD PLUGIN
, but don't. If you don't care about why, then skip to the next paragraph, but if you do, keep reading. Essentially, the plugin throws errors if passwords don't meet specific criteria. This causes issues if you either a.) use weak passwords, or b.) install a package that automatically compiles and creates a default account with basic credentials. It is always good practice to use strong passwords for everything, and database credentials are no exception.
Say yes to the rest of the questions and use good judgement if it asks something that requires anything other than a Y/N input.