Loading...

How to Install LEMP Stack (Linux, Nginx, MySQL, PHP) on CentOS 8

Simple.Predictable.Scalable

Easily deploy your favorite applications in seconds at an unbeatable price for your next projects.

Installing LEMP Stack (Linux, Nginx, MySQL, PHP) on CentOS 8

The LEMP stack is a popular open-source software stack used for building and running dynamic websites and applications. It consists of the following components:

  • Linux: The operating system.
  • Nginx: A high-performance web server that can handle a large number of simultaneous connections.
  • MySQL: A widely-used relational database management system.
  • PHP: A server-side scripting language for creating dynamic web pages.

Here are the steps to install the LEMP stack on CentOS 8:

  1. Update the system packages:
    sudo dnf update
  2. Install the Nginx web server:
    sudo dnf install nginx
  3. Start and enable the Nginx service:
    sudo systemctl start nginx
    sudo systemctl enable nginx
  4. Install MySQL:
    sudo dnf install @mysql
  5. Start and enable the MySQL service:
    sudo systemctl start mysqld
    sudo systemctl enable mysqld
  6. Secure the MySQL installation by running the MySQL Secure Installation script:
    sudo mysql_secure_installation
  7. Install PHP and required modules:
    sudo dnf install php php-fpm php-mysqlnd
  8. Start and enable the PHP-FPM service:
    sudo systemctl start php-fpm
    sudo systemctl enable php-fpm
  9. Configure Nginx to use PHP-FPM:
    sudo nano /etc/nginx/conf.d/default.conf
    Add the following inside the "server" block:
    location ~ .php$ {
                 root /usr/share/nginx/html;
                 fastcgi_pass unix:/run/php-fpm/www.sock;
                 fastcgi_index index.php;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 include fastcgi_params;
    }
  10. Test the PHP installation:
    sudo nano /usr/share/nginx/html/info.php
    Add the following line:
  11. Restart Nginx:
    sudo systemctl restart nginx
  12. Access the PHP info page in a web browser by navigating to:
    http://your-server-ip/info.php

You have now successfully installed the LEMP stack on CentOS 8. This will allow you to host and run dynamic websites and applications using Nginx as the web server, MySQL as the database, and PHP for server-side scripting.

Installing LEMP Stack
LEMP Stack on CentOS 8
LEMP Stack installation
LEMP Stack Linux setup
Nginx installation
MySQL installation on CentOS 8
PHP installation on CentOS 8
CentOS 8 LEMP Stack setup
LEMP Stack configuration on CentOS 8
CentOS 8 LEMP Stack installation guide

Why Customers Love Us

What our customers say about us

Ready To Get Started For Free?

Create your free account today.