A LEMP software stack is a collection of open-source software that allows a server to host websites and applications. LEMP stands for Linux, ENginx, MySQL (using MariaDB), and PHP.
This guide explains how to install a LEMP stack on a Fedora 32 server, including phpMyAdmin, Redis, Opcache, and Let’s Encrypt SSL.
Prerequisites
- A server running Fedora 32.
- A non-root user with sudo privileges.
Update the system:
$ sudo dnf upgrade
Install necessary packages:
$ sudo dnf install wget curl nano -y
Some of these packages may already be installed on your system. Disable SELinux:
$ sudo setenforce 0
Configure Firewall
Configure the firewall that comes pre-installed with Fedora.
Check the firewall’s status:
$ sudo firewall-cmd --state
Expected output: running
Set the default zone to public:
$ sudo firewall-cmd --set-default-zone=public
Allow HTTP and HTTPS services:
$ sudo firewall-cmd --zone=public --permanent --add-service=http
$ sudo firewall-cmd --zone=public --permanent --add-service=https
Check the allowed services:
$ sudo firewall-cmd --zone=public --permanent --list-services
Expected output: dhcpv6-client http https mdns ssh
Reload the firewall:
$ sudo systemctl reload firewalld
Install PHP
Fedora 32 ships with PHP 7.4. Enable the REMI repository for PHP:
$ sudo dnf -y install https://rpms.remirepo.net/fedora/remi-release-32.rpm
Enable the necessary repositories and install PHP:
$ sudo dnf config-manager --set-enabled remi
$ sudo dnf config-manager --set-disabled remi-modular
$ sudo dnf install -y php-cli php-fpm php-mysqlnd
Verify PHP installation:
$ php --version
Expected output: PHP 7.4.6 details
Install MariaDB
MariaDB is a MySQL replacement, and Fedora 32 ships with MariaDB 10.4:
$ sudo dnf install mariadb-server -y
Verify the installation:
$ mysql --version
Expected output: MariaDB version details
Enable and start MariaDB service:
$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb
Secure MariaDB:
$ sudo mysql_secure_installation
Follow the prompts to enhance security.
FAQ
What is a LEMP stack?
A LEMP stack is a set of open-source software that allows websites and applications to be hosted on a server. It includes Linux, Nginx, MariaDB, and PHP.
Why disable SELinux?
Disabling SELinux can simplify configuration during setup. However, consider enabling it with proper configuration for production environments to enhance security.
How do I verify my Nginx configuration?
You can verify your Nginx configuration using the command sudo nginx -t
. It will confirm if your configuration is correct.
How can I ensure my SSL certificates are up-to-date?
Add a cron job to automatically renew SSL certificates with Certbot. This ensures your certificates are always up-to-date without manual intervention.
What should I do if I encounter phpMyAdmin login issues?
Ensure you have created a MySQL user with proper privileges as unix_authentication does not provide a root user login through phpMyAdmin.
Feel free to reach out if you have more questions or need further assistance with your LEMP stack setup.