Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux LNMP Environment Setup Preparations

If we manually install the LNMP environment, then we also need to install about 14 source packages (depending on the version and function). However, the construction process of the very popular LNMP environment on the Internet is to use the LNMP one-click installation package to install directly. This one-click installation package is actually a pre-written installation script. According to this installation script, as long as you specify some basic options, it can be installed automatically, so the installation process will be greatly simplified.

Next, we will use the one-click installation package to build the LNMP environment. However, there are still some preparations to be done before installation.

1. Can it coexist with the LAMP environment?

In fact, it is possible to build an LNMPA environment in Linux, that is, to install a website server architecture such as Nginx, MySQL, PHP and Apache in Linux. This is a new website server architecture that combines the advantages of the LAMP environment and the LNMP environment. .

However, we are only building the LNMP architecture today, so the author suggests not to overwrite the installation of the LNMP environment in the LAMP environment, but to use a completely clean environment to rebuild the LNMP environment to avoid unnecessary troubles. Since my server was using a virtual machine, I just reverted to a snapshot of the original installation and started all over again.

Download LNMP one-click installation package

Since it is a one-click installation package, we don't need to download a single source package, just download LNMP one-click installation at http://soft.vpser.net/lnmp/lnmp1.0-full.tar.gz package.

other preparations

We also need to do the following preparations:
  • Make sure the yum source is available.
  • Upload the LNMP one-click installation package to the Linux server.
  • Install the gcc compilation tools. If the gcc compilation tool is not installed, the LNMP one-click installation package will try to install yum automatically, but make sure that the yum source is available.
  • Disable apache and MySQL installed by RPM packages.
  • Disable firewall and SELinux.
  • Shut down unnecessary services in Linux.

These preparations are basically the same as the LAMP environment, and will not be listed here.
  1. Preparations for LNMP environment setup on Linux:

    Before setting up an LNMP stack, ensure your Linux system is up-to-date, and you have access to necessary privileges. Back up important data and consider specific project requirements.

  2. Installing required dependencies for LNMP on Linux:

    Install the required packages for an LNMP stack. Package names may vary based on your Linux distribution.

    Example code (on Ubuntu):

    sudo apt-get update
    sudo apt-get install nginx mysql-server php-fpm
    
  3. Securing Linux server before LNMP installation:

    Secure your server by updating packages, configuring firewalls, and implementing security best practices.

  4. Configuring firewall settings for LNMP stack:

    Open necessary ports for Nginx and MySQL in the firewall settings.

    Example code (on Ubuntu with UFW):

    sudo ufw allow 80
    sudo ufw allow 3306
    sudo ufw enable
    
  5. Setting up users and permissions for LNMP components:

    Create MySQL users, set passwords, and configure permissions for database access.

    Example code (MySQL):

    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;
    
  6. Ensuring prerequisite software for LNMP on Linux:

    Verify that Nginx, MySQL, and PHP are installed and running. Check versions and configurations.

    Example code (checking Nginx):

    nginx -v
    

    Example code (checking MySQL):

    mysql --version
    

    Example code (checking PHP):

    php -v
    
  7. Preparing MySQL database for LNMP environment:

    Create databases, tables, and populate data based on your application requirements.

    Example code (MySQL):

    CREATE DATABASE dbname;
    USE dbname;