Setting SSH and LEMP on a bare-bones Debian server
So you got yourself access to a Debian server (or virtual private server) and have logged into it by one way or the other. In this tutorial, we will learn how to set up such a bare-bones server so you can access it remotely via SSH and run a LEMP stack (Linux, Nginx, MariaDB, PHP) on it.
NOTE: This tutorial was tested on Debian 10 (buster).
NOTE: Unless explicitly specified, all commands need to be executed as root (i.e., administrator user on a Unix based system – but if you don’t know this then you would be better off learning about it before continuing).
NOTE: Always keep your server up-to-date with the latest security patches by following apt update/upgrade routine.
1. Setting up the SSH server
Let’s start by installing the SSH server
1 2 |
$ apt install openssh-server $ systemctl enable ssh |
Now you can read this excellent description of all the relevant options to configure your SSH server to your liking. I consider following to be sane defaults:
1 2 3 4 5 6 7 8 9 |
PermitRootLogin no StrictModes yes HostbasedAuthentication no PermitEmptyPasswords no AllowTcpForwarding no GatewayPorts no X11Forwarding no PrintLastLog yes PermitTunnel no |
2. Setting up MariaDB
MariaDB is a community-developed, commercially supported fork of the MySQL. It is a drop-in replacement for MySQL if you want to install WordPress, for example.
Let us install both the server and client for MariaDB. The client is important because we would like to configure the MariaDB server before it can be used by an application such as WordPress.
1 2 3 |
$ apt install mariadb-server mariadb-client $ mysql_secure_installation $ mysql -u root |
Simple!
2. Installing NGINX and PHP
Following three commands are all you need to install NGINX and PHP for support for it.
1 2 3 |
$ apt install nginx-light $ apt install php-fpm $ apt-install php-mysql |
Congratulations! Now you can proceed to write the conf file for your server.