---
title: "LNMP 安装php环境"
author: "xxi"
date: "2021-02-25T13:16:10Z"
tags: []
categories: ["操作系统"]
slug: "lnmp-php"
draft: false
lastmod: "2021-02-25T13:16:10Z"
id: 2519303
url: "https://xxi.iteye.com/blog/2519303"
---

###### 1. 安装LNMP

```
//防止安装中断
yum install screen
screen -S lnmp

//中断可使用恢复
screen -r lnmp

//安装lnmp
wget http://soft.vpser.net/lnmp/lnmp1.7.tar.gz -cO lnmp1.7.tar.gz && tar zxf lnmp1.7.tar.gz && cd lnmp1.7 && ./install.sh lnmp

//选择mysql 5.6或5.7需要1G以上内存才可安装, 一般选5.7
```

![](https://lnmp.org/images/1.5/lnmp1.5-install-1.png)

```

设置mysql密码
```

![](https://lnmp.org/images/1.5/lnmp1.5-install-2.png)

```

选择php版本 7.1即可
```

![](https://lnmp.org/images/1.5/lnmp1.5-install-4.png)

```

内存优化: 3 不优化
```

![](https://lnmp.org/images/1.5/lnmp1.5-install-5.png)

```

安装完成
```

![](https://lnmp.org/images/1.5/lnmp1.5-install-success.png)

```

```

 

###### 2 安装扩展

```
./addons.sh install memcached
memcached安装, 选2
```

![addons-install-memcached.png](https://lnmp.org/usr/uploads/2015/05/3448493554.png)

```



./addons.sh install opcache
php加速
```

 

###### 3.添加网站

 

 

```
lnmp vhost add
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-add-2.png)

```
输入要添加的域名

设置网站目录
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-add-3.png)

```

伪静态: n 关闭
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-add-4.png)

```

n 不开启
```

![lnmp-add-vhost-pathinfo.png](https://lnmp.org/usr/uploads/2020/09/2772103874.png)

```

日志
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-add-6.png)

```

n 不添加数据库
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-add-9.png)

```

虚拟主机添加成功
```

![](https://lnmp.org/images/1.4/lnmp1.4-vhost-info.png) 

 

 3. 虚拟机配置

 

```
虚拟主机配置文件在：/usr/local/nginx/conf/vhost/域名.conf

//配置框架入口
if (!-e $request_filename){
     rewrite ^/(.*)$ /index.php?s=/$1 last;
}
```