Knowledgebase
Getting started with One-click LEMP stack (Nginx with PHP and MariaDB)
Introduction
SpectraIP's one-click LEMP application is an easy way to deploy web applications on Linux, Nginx, PHP and MariaDB (MySQL). The one-click application is based on Debian 11 minimal, a very light weight operating system.
Pre-installed software
- Nginx (webserver)
- PHP-FPM 8.1
- MariaDB 10.8 (SQL server)
- Certbot-nginx (Let's Encrypt SSL)
- Redis and Memcached
In this tutorial, we will be using 192.168.223.66 as example IP address. Please replace this IP address with your VPS's IP address.
- Your webserver is reachable via http: http://192.168.233.66
- PHP-info is available via http://192.168.223.66/info.php
- Nginx document root (web files): /var/www/html
- Command to enter MySQL CLI:
mysql -u root
MySQL
Our LEMP stack comes with modern and fast SQL server MariaDB 10.8. You can connect to the MySQL database server with:
mysql -u root
Create a database with the following command:
create database database1;
Create a database user with full permissions to 'database1' - once done, also flush the privileges:
grant all on database1.* to dbadmin@localhost identified by 'RlhDmPuYr7WIr4p4aUfC1RM';
flush privileges;
quit;Note: in this case, your database password is: RlhDmPuYr7WIr4p4aUfC1RM
Let's Encrypt SSL certificates
In order to request an SSL certificate via Let's Encrypt, you must meet the following requirements:
- A valid DNS record (or records) for your domain name(s).
- The domain names must be configured as 'server name' in nginx.
In this guide, we will use test.spectraip.io with document root /var/www/html. Please edit your nginx site configuration:
nano /etc/nginx/sites-available/default
In this case, you can find the following lines:
server_name _;
Change it to your preferred domain name:
server_name test.spectraip.io;
Once changed, you can test your nginx configuration for errors:
nginx -t
We here see no errors:
root@lemp-stack:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulOnce you confirmed there are no errors, you can reload nginx:
systemctl reload nginx
You can now request the SSL certificate via certbot:
certbot --nginx -d example.com -d www.example.com
Replace "example.com" with your own domain name(s) - in our case "test.spectraip.io"
Now follow certbot's short menu, after which your new SSL certificate is installed. We can now visit test.spectraip.io with https:
Note: Your website should automatically redirect to https (SSL).