
The Linux, Nginx (pronounced as Engine X), MySQL, and PHP (LEMP) stack is a collection of software installed to serve dynamic web applications on a server. Nginx works as the web server application, MySQL as the database server, and PHP as the dynamic scripting language that supports multiple frameworks for web applications. In this article, you'll install LEMP on Rocky Linux 8.
Install Nginx.
Enable Nginx to start at boot time.
Start Nginx.
Allow HTTP access through the firewall.
Reload Firewall rules.
Test your Nginx installation by visiting your server IP.
Install MariaDB.
Enable MariaDB to start at boot time.
Start the MariaDB server.
Install PHP and PHP-FPM.
Install common PHP extensions required by most web applications.
Enable PHP-FPM to start at boot time.
Start PHP-FPM.
Initialize MariaDB and set the root password.
Press enter when prompted for the root user password, reply with yes `y' to set a new root password, remove anonymous users, disallow remote root login, and remove the test database.
Log in to the MySQL console as root.
Create a sample database.
Create a sample database user assigned with a strong password.
Grant the user full privileges to the sample database.
Refresh MySQL privileges.
Exit the console.
Test your MySQL login as the sample user.
Show available databases.
Exit the console.
Create a new web files directory for your application.
Using a text editor, create a simple HTML file in the directory.
Add the following contents to the file.
Save and exit the editor.
Grant Nginx read and write permissions to the directory.
Create a new Nginx configuration file.
Add the following configurations to the file.
Save and exit the editor.
Test Nginx for configuration errors.
Restart Nginx to save changes.
Nginx serves web applications through HTTP and HTTPS Ports. Allow them through the firewall.
Allow HTTP connections.
Allow HTTPS connections.
Reload Firewall rules to save changes.
Install the Extra Packages for Enterprise Linux (EPEL) repository.
Enable the PowerTools repository.
Install the snap library.
Enable the snap socket and enable classic snap support.
Close your SSH connection and Login again to complete snap integration.
Install the Certbot agent
Request a free SSL certificate from Let's Encrypt.
Replace example.com with your actual domain.
Restart Nginx to load changes.
Through a web browser, visit your configured domain.
Your HTML application should output Hello World headings.
To test database communication, set up a new dbtest.php file in your domain's webroot directory.
Add the following contents to the file. Enter your database information created earlier.
Save and exit the editor.
Visit your domain and load dbtest.php.
A connection successful message should display together with your server PHP information.
You have successfully installed LEMP on a Rocky Linux 8 server, and tested communication between applications. With a working stack, you can perform extra steps to get your web applications up and running securely without errors.
Depending on your use case, you can install multiple applications on your server and set up extra features, visit the following articles for more information.
0 Comments
Be the first to comment and share your perspective with the community.