Last update at :2024-03-05,Edit by888u
The LNMP (Linux+Nginx+MySQL+PHP) environment is the basis for many applications, such as building websites, setting up personal cloud disks, and making online file managers. This article introduces how to install an LNMP environment on a VPS with one click, supporting common Linux systems such as CentOS, Ubuntu, and Debian.
Introduction to LNMP
LNMP is the abbreviation of Linux+Nginx+MySQL+PHP, which refers to installing Nginx, MySQL and PHP on your VPS (VPS can be any common system such as CentOS, Ubuntu, Debian, etc.).
Nginx can be used as a web host, MySQL is a database, and PHP can be used as a web development language. With these three environments, your host can perform many external access operations, including building websites, building cloud disks, and setting up cloud disks. PHP probe, online file manager, etc.
LNMP one-click installation
The LNMP script introduced in this article is also a script commonly used by Lao Wang and me, and supports common Linux systems such as CentOS, Ubuntu, and Debian.
Open a new window (optional)
Since installing the LNMP environment is a time-consuming operation, it is recommended to open another window so that you can reopen the installation window even if you are disconnected from the host. The command is as follows (lnmp is the name of this new window):
screen -S lnmpIf the screen: command not found command does not exist, install screen first. For CentOS systems, execute yum install screen. For Ubuntu/Debian systems, execute apt-get install screen.
If you are disconnected from the host during the LNMP installation environment, you only need to execute screen -r lnmp to see your installation window.
One-click installation of LNMP environment
One-click installation of the LNMP environment includes installing Nginx, MySQL and PHP on Linux. The script download and installation commands are as follows (updated to the latest LNMP 1.8 in 2021):
wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmpIf you want to install LAMP or LNMPA here, you only need to replace the parameter lnmp after install.sh with lamp or lnmpa.
The script will then ask you to enter some installation information, including MySQL version, PHP version, etc. It is recommended to select PHP7, and others can be defaulted:
The entire LNMP installation process takes about 30 minutes. You can leave it there for a while and wait until it is successfully installed. After successful installation, enter your domain name in the browser, which should be the default welcome page of LNMP.
LNMP configuration file
After one-click installation of the LNMP environment, Nginx, MySQL and PHP will be installed by default. The corresponding software installation directories are as follows:
Nginx directory: /usr/local/nginx/ MySQL directory: /usr/local/mysql/ The directory where the MySQL database is located: /usr/local/mysql/var/ PHP directory: /usr/local/php/ Default website directory: /home/wwwroot/default/ Nginx log directory:/home/wwwlogs/
Similarly, the default configuration file directory of LNMP is as follows:
Nginx main configuration (default space) file: /usr/local/nginx/conf/nginx.conf Added space configuration file: /usr/local/nginx/conf/vhost/domain name.conf MySQL configuration file:/etc/my.cnf PHP configuration file: /usr/local/php/etc/php.ini php-fpm configuration file:/usr/local/php/etc/php-fpm.conf
The commands generally needed to maintain the site are as follows:
Restart nginx/mysql/php: lnmp nginx/mysql/php restart
Restart all: lnmp restart
Add site: lnmp vhost add
Add database: lnmp database add
View help: lnmp
LNMP Advanced Tutorial
How to use LNMP to manage the Linux VPS network environment and how to build a website, you can refer to the following tutorials:
- "LNMP adds a website with one click: configure domain name + create new MySQL + configure https certificate"
- "VPS website building tutorial: Build your own personal website based on WordPress in 5 minutes"
Recommended site searches: 6 yuan per year cloud server, high-defense server rental, Hong Kong ip, ip query, Internet cafe ip address query, ip query network, website registration price, expired registration domain name query, free forever space,
发表评论