I used to Google on how to run Apache, MySQL and WordPress on Debian more than 10 years ago. Fast forward to today I was meddling with ChatGPT and was intrigue if it can give me instructions on how to install Nginx, MariaDB, WordPress and Let’s Encrypt and renew it on schedule via systemd.
Below is what I got from ChatGPT when i asked – How do I install nginx, mariadb, php and wordpress with https let’s encrypt certificate that will autorenew?
Note: My setup is different as I am making use of Cloudflare Tunnel for this site which will be covered in a different post on how to set it up maybe?
To install NGINX, MariaDB, PHP, and WordPress with Let’s Encrypt HTTPS (auto-renewing) on a Linux server (typically Ubuntu/Debian), follow this step-by-step guide.
✅ Step-by-Step Setup (LAMP → LEMP Stack)
🧰 Prerequisites
- A Linux server (Ubuntu 20.04/22.04 recommended)
- A domain name (pointed to your server’s IP)
- Root or sudo access
1. 🔧 Install NGINX
sudo apt update
sudo apt install nginx -y
Start and enable NGINX:
sudo systemctl start nginx
sudo systemctl enable nginx
2. 🗃️ Install MariaDB
sudo apt install mariadb-server mariadb-client -y
Secure the installation:
sudo mysql_secure_installation
During this:
- Set root password (if prompted)
- Remove anonymous users
- Disallow remote root login
- Remove test database
- Reload privileges
3. ⚙️ Install PHP
sudo apt install php-fpm php-mysql -y
Optional common extensions:
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip php-imagick -y
4. 📁 Create a Database for WordPress
Log into MariaDB:
sudo mysql -u root -p
In the MySQL shell:
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strong_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
5. ⬇️ Download WordPress
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo mv wordpress /var/www/wordpress
Set permissions:
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 750 {} \;
sudo find /var/www/wordpress -type f -exec chmod 640 {} \;
6. 📝 Configure NGINX
Create a new config:
sudo nano /etc/nginx/sites-available/wordpress
Paste:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /var/www/wordpress;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock; # check with `php-fpm -v` for correct sock
}
location ~ /\.ht {
deny all;
}
access_log /var/log/nginx/wordpress_access.log;
error_log /var/log/nginx/wordpress_error.log;
}
Enable the site:
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
7. 🔐 Install Let’s Encrypt SSL
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Obtain a certificate:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot automatically:
- Configures SSL
- Adds HTTPS redirection
- Schedules auto-renew
Test renewal:
sudo certbot renew --dry-run
8. 🌐 Final WordPress Setup
Go to http://yourdomain.com or https://yourdomain.com
Follow the on-screen installation:
- Select language
- DB name:
wordpress - DB user:
wpuser - DB password: (what you set)
✅ Summary
| Component | Installed via | Notes |
|---|---|---|
| NGINX | apt | Web server |
| MariaDB | apt | WordPress DB |
| PHP + FPM | apt | Required for WordPress |
| WordPress | Manual download | /var/www/wordpress |
| SSL (Let’s Encrypt) | certbot + nginx plugin | Auto-renew enabled via systemd timer |