国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Prerequisites
Step 1: Install Nginx on Rocky Linux
Step 2: Install MariaDB on Rocky Linux
Step 3: Install PHP on Rocky Linux
Step 3: Configure Nginx Server Block in Rocky Linux
Step 1: Create a Website Directory
Step 3: Create a Demo Site
Step 4: Create a Nginx Server Block for Website
Step 5: Enable Nginx Server Block
Step 6: Test Nginx Website
Home System Tutorial LINUX How to Install LEMP Stack on Rocky Linux 8

How to Install LEMP Stack on Rocky Linux 8

Jul 13, 2025 am 09:22 AM

LEMP is a popular stack that comprises open-source software that is collectively used to host and serve web applications, whether in production or any stage along the development cycle.

The terminology LEMP is an acronym for Linux, Nginx (pronounced as Engine X, hence the E) which is a web browser, MariaDB or MySQL – database, and PHP for processing dynamic content). LEMP stack is popularly used for hosting high-traffic and highly scalable web applications and websites.

In this guide, you will learn how to install the LEMP stack on Rocky Linux 8.4.

Prerequisites

Before setting out to install the LEMP stack, ensure that you have the following requirements in place.

  • An Instance of Rocky Linux 8 with a sudo user configured.
  • SSH access to the Rocky Linux instance.

Let’s get started…

Step 1: Install Nginx on Rocky Linux

The first step is to install the first component of the LEMP stack which is the Nginx web server. First, upgrade the packages.

$ sudo dnf update -y

After the update is complete, install Nginx by running the following command. This installs Nginx alongside other dependencies required by the webserver.

$ sudo dnf install nginx 

How to Install LEMP Stack on Rocky Linux 8

Once Nginx is in place, enable it to start on boot time and start the Nginx daemon.

$ sudo systemctl enable nginx 
$ sudo systemctl start nginx 

To confirm that the web server is running, execute the command:

$ sudo systemctl status nginx

From the output, we can conclude that the webserver is up and running.

How to Install LEMP Stack on Rocky Linux 8

If you are curious enough, you can check the version of Nginx as follows. The output indicates we are running Nginx 1.14.1.

$ nginx -v

<strong>nginx version: nginx/1.14.1</strong>

Additionally, you can confirm that the browser is working by browsing the URL shown. This will display the default Nginx Welcome page indicating that all is well.

http://server-ip or domain name

How to Install LEMP Stack on Rocky Linux 8

If you are having issues viewing the page, consider opening port 80 or allowing the HTTP traffic on the firewall.

$ sudo firewall-cmd --zone=public --add-service=http --permanent 

Then reload the firewall and reload the page.

$ sudo firewall-cmd --reload

Step 2: Install MariaDB on Rocky Linux

For this guide, we will install the MariaDB database. This is due to the optimized performance and wealth of storage engines it provides which makes it far more superior to MySQL.

To install the MariaDB database server, run the command:

$ sudo dnf install mariadb-server mariadb

How to Install LEMP Stack on Rocky Linux 8

Once done, enable and start MariaDB as shown.

$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

Then verify its status.

$ sudo systemctl status mariadb

How to Install LEMP Stack on Rocky Linux 8

The default settings for MariaDB are not secure enough and your database can easily be breached. As a precaution to deter intruders at the most basic level, run the script below.

$ sudo mysql_secure_installation

Be sure to set up the Root password.

How to Install LEMP Stack on Rocky Linux 8

For the remaining prompts, simply type 'Y' to remove anonymous users, deny remote root login, remove the test database, and finally save the changes made.

How to Install LEMP Stack on Rocky Linux 8

To login to the database server, run the command:

$ sudo mysql -u root -p

Provide the password and hit ENTER.

How to Install LEMP Stack on Rocky Linux 8

Step 3: Install PHP on Rocky Linux

The last component to install is PHP via PHP-FPM, which stands for FastCGI Process Manager. This is an efficient and highly advanced processor for PHP that provides features that guarantee optimal performance, and security for high-traffic websites.

To start off, we will install the Remi repository which is a third-party free repository that provides the latest PHP versions.

To enable the Remi repository, run the command:

$ sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm

How to Install LEMP Stack on Rocky Linux 8

Once the Remi repository is enabled, check out the list of PHP modules that are hosted using the command shown.

$ sudo dnf module list php

How to Install LEMP Stack on Rocky Linux 8

From the output, we can see that the default version is 7.2 – with the tag [d]. However, we are going to install the latest module which is Remi 8.0.

Therefore, reset the default PHP modules and enable the latest Remi PHP module.

$ sudo dnf module list reset php
$ sudo dnf module enable php:remi-8.0

How to Install LEMP Stack on Rocky Linux 8

Next, update the system and install PHP and PHP-FPM alongside PHP extensions of your preference.

$ sudo dnf install php php-fpm php-gd php-mysqlnd php-cli php-opcache

How to Install LEMP Stack on Rocky Linux 8

Once the installation is complete, enable and start PHP-FPM as shown.

$ sudo systemctl enable php-fpm
$ sudo systemctl start php-fpm

Next, verify the running status of PHP-FPM.

$ sudo systemctl status php-fpm

How to Install LEMP Stack on Rocky Linux 8

Normally, PHP-FPM runs as the Apache user, but since we are using Nginx, we need to set it to Nginx. So, open the following configuration file.

$ sudo vim /etc/php-fpm.d/www.conf

Set the user and group to Nginx.

user = nginx
Group = nginx

Thereafter, reload the PHP-FPM daemon.

$ sudo systemctl reload php-fpm

To confirm that we have installed the latest version of PHP, run the command.

$ php -v

How to Install LEMP Stack on Rocky Linux 8

Another nifty way of Testin PHP is by creating a simple PHP file and placing it in the webroot directory which is located in /usr/share/nginx/html. So, create a simple info.php file in the /usr/share/nginx/html webroot directory.

$ sudo vim /usr/share/nginx/html/info.php

Add the following content and save the file.

<?php phpinfo();

?>

To effect the changes, reload the Nginx web server.

$ sudo systemctl restart nginx

Finally, access the following URL.

http://server-ip/info.php

A webpage with detailed information about the installed PHP version alongside other PHP extensions will be displayed.

How to Install LEMP Stack on Rocky Linux 8

At this point, our LEMP setup is complete. In the next step, we are going to host a sample site by configuring an Nginx server block.

Step 3: Configure Nginx Server Block in Rocky Linux

A server block allows administrators to host multiple websites on one server by defining different site document root directories. These are the directories that contain the website files.

Here, we will create a single Nginx server block file to host a sample website.

Step 1: Create a Website Directory

First up, create the site’s document directory which will contain the site’s data that will be available to site visitors. Assume you have a domain called example.com. Create the site’s domain directory as follows. Be sure to replace example.com with your site’s Fully Qualified Domain Name or registered domain.

$ sudo mkdir -p /var/www/example.com/html

Step 2: Set Ownership & Permissions on Website

The domain’s directory structure is now set to host the site’s files. Currently, it’s the root user that owns the files. We need to set the ownership such that it’s the regular user that owns the file.

To change the files’ ownership to the currently logged-in user, use the chown command.

$ sudo chown -R $USER:$USER /var/www/example.com/html

The $USER variable takes the value of the currently logged-in user and grants the user ownership to the html files and subdirectories. Additionally, grant read permission to the general web root directory so that site visitors can access the site pages.

$ sudo chmod -R 755 /var/www

The site directory is now well configured to serve the site’s web pages.

Step 3: Create a Demo Site

Let’s now create a sample test site. We will create a very basic index.html file in the domain’s html directory.

$ sudo vim /var/www/example.com/html/index.html

Paste the content below. As you can see, it’s quite basic as we are only using it for testing purposes.


  
    <title>Welcome to Example.com!</title>
  
  
    <h1>Success! The server block is active!</h1>
  

Save and exit the HTML file.

Step 4: Create a Nginx Server Block for Website

A server block file is a file that contains the site’s configuration. It spells out how the Nginx web server responds to requests from the site’s visitors. We will begin by creating two directories:

  • /etc/nginx/sites-available – This is the directory that will hold the server block file.
  • /etc/nginx/sites-enabled – The directory notifies Nginx that the server block file is ready to serve requests.

Therefore, create the directories as follows:

$ sudo mkdir /etc/nginx/sites-available
$ sudo mkdir /etc/nginx/sites-enabled

Thereafter, edit Nginx’s main configuration file.

$ sudo mkdir /etc/nginx/nginx.conf

Paste the following lines. The first line specifies the path to the directory containing additional configuration files. The second line increases the memory allocated to parsing domain names.

include /etc/nginx/sites-enabled/*.conf;
server_names_hash_bucket_size 64;

Save and exit.

Next, create a server block file.

$ sudo vim /etc/nginx/sites-available/example.com.conf

Paste the content below. Replace example.com with your Fully Qualified Domain name (FQDN) or server IP address.

server {
    listen  80;

    server_name <strong>example.com www.example.com</strong>;

    location / {
        root  /var/www/<strong>example.com</strong>/html;
        index  index.html index.htm;
        try_files $uri $uri/ =404;
    }

    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root  /usr/share/nginx/html;
    }
}

Save and exit the file.

Step 5: Enable Nginx Server Block

Finally, we need to enable the server block file. To do so, we’ll create a symbolic link for the server block file to the sites-enabled directory.

$ sudo ln -s /etc/nginx/sites-available/example.com.conf /etc/nginx/sites-enabled/example.com.conf

Then restart Nginx for the changes to be effected.

$ sudo systemctl restart nginx

Step 6: Test Nginx Website

To test the configuration launch your browser and visit your site’s domain

http://example.com

This should display the server block’s site as we configured in Step 3.

How to Install LEMP Stack on Rocky Linux 8

And this wraps it up. In this guide, we have walked you through the installation of the LEMP stack on Rocky Linux 8 and went a step further to create and configure a server block file where we hosted a custom website.

The above is the detailed content of How to Install LEMP Stack on Rocky Linux 8. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

5 Best Open Source Mathematical Equation Editors for Linux 5 Best Open Source Mathematical Equation Editors for Linux Jun 18, 2025 am 09:28 AM

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

Gogo - Create Shortcuts to Directory Paths in Linux Gogo - Create Shortcuts to Directory Paths in Linux Jun 19, 2025 am 10:41 AM

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

What is a PPA and how do I add one to Ubuntu? What is a PPA and how do I add one to Ubuntu? Jun 18, 2025 am 12:21 AM

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

How to create a file of a specific size for testing? How to create a file of a specific size for testing? Jun 17, 2025 am 09:23 AM

How to quickly generate test files of a specified size? It can be achieved using command line tools or graphical software. On Windows, you can use fsutilfilecreatenew file name size to generate a file with a specified byte; macOS/Linux can use ddif=/dev/zeroof=filebs=1Mcount=100 to generate real data files, or use truncate-s100M files to quickly create sparse files. If you are not familiar with the command line, you can choose FSUtilGUI, DummyFileGenerator and other tool software. Notes include: pay attention to file system limitations (such as FAT32 file size upper limit), avoid overwriting existing files, and some programs may

NVM - Install and Manage Multiple Node.js Versions in Linux NVM - Install and Manage Multiple Node.js Versions in Linux Jun 19, 2025 am 09:09 AM

Node Version Manager (NVM) is a simple bash script that helps manage multiple Node.js versions on your Linux system. It enables you to install various Node.js versions, view available versions for installation, and check already installed versions.NV

How to install Linux alongside Windows (dual boot)? How to install Linux alongside Windows (dual boot)? Jun 18, 2025 am 12:19 AM

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

See all articles