
LNMP
安装步骤:
1、使用putty或类似的SSH工具登陆VPS或服务器;
登陆后运行:screen -S lnmp
如果提示screen: command not found 命令不存在可以执行:yum install screen 或 apt-get install screen安装,详细内容参考screen教程。
2、下载并安装lnmp一键安装包:
您可以选择使用下载版(推荐美国及海外VPS或空间较小用户使用)或者完整版(推荐国内VPS使用,国内用户可用在下载中找国内下载地址替换),两者没什么区别,只是完整版把一些需要的源码文件预先放到安装包里。
安装lnmp稳定版
如需无人值守安装,请使用 无人值守命令生成工具,或查看无人值守说明教程
wget lnmp/lnmp1.9.tar.gz">http://soft.vpser.net/lnmp/lnmp1.9.tar.gz -cO lnmp1.9.tar.gz && tar zxf lnmp1.9.tar.gz && cd lnmp1.9 && ./install.sh lnmp
1. 安装Nginx
安装Nginx需要先安装epel-release,命令如下:
shell
yum install epel-release -y
安装完成后,使用下面的命令安装Nginx:
shell
yum install nginx -y
安装完成后,使用以下命令启动Nginx和设置开机启动:
shell
systemctl start nginx
systemctl enable nginx
2. 安装MySQL/MariaDB
安装MySQL或MariaDB,本教程以MariaDB为例,安装命令如下:
shell
yum install mariadb-server -y
安装完成后,使用以下命令启动MariaDB和设置开机启动:
shell
systemctl start mariadb
systemctl enable mariadb
3. 安装php
在安装php前,需要先安装EPEL repository。安装命令如下:
shell
yum install epel-release -y
安装完成后,使用下面的命令安装php及其相关的模块(此处安装php7.2,其他版本将版本号改为对应版本即可):
shell
yum install php72-fpm php72-cli php72-MySQLnd php72-gd php72-imap php72-ldap php72-odbc php72-pear php72-XML php72-XMLrpc php72-bcmath php72-mbstring php72-soap php72-snmp php72-tidy -y
安装完成后,使用以下命令启动php和设置开机启动:
shell
systemctl start php-fpm
systemctl enable php-fpm
4. 配置Nginx和php
编辑Nginx的配置文件,添加如下内容:
nginx
server {
listen 80;
server_name yourdomAIn.com;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
其中,server_name替换成自己的域名,root用于指定网站根目录。
编辑php的配置文件,修改以下内容:
ini
cgi.fix_pathinfo=0
保存后重启php和Nginx服务:
shell
systemctl restart php-fpm
systemctl restart nginx
至此,lnmp环境搭建完成。
Copyright © 2025 IZhiDa.com All Rights Reserved.
知答 版权所有 粤ICP备2023042255号