在前面我们已经实现了lamp架构的创建,今天就让我们来看一看lnmp架构是如何实现的。计划的实验步骤如下:

1. 数据库mysql的安装

2. Nginx的安装,libevent(编译库代码)的安装,pcre的安装

3. Php的安装

4. 测试

1. Mysql 的安装

//注意:小编这次用的mysql是经过编译好的压缩包,解压之后就能使用了,如果解压后的目录名过长,我们可以创建一个软连接

Linux(redhat5.4)下lnmp环境的搭建_Linux

Linux(redhat5.4)下lnmp环境的搭建_安装_02

//进入到解压目录下,查看使用前的配置、权限的更改步骤

Linux(redhat5.4)下lnmp环境的搭建_压缩包_03

//安装上面给出的步骤进行操作

Linux(redhat5.4)下lnmp环境的搭建_Linux_04

Linux(redhat5.4)下lnmp环境的搭建_计划_05

//做完必要的更改后,我们来做一些与系统必要的关联

// include 头文件关联

Linux(redhat5.4)下lnmp环境的搭建_Linux_06

// bin 目录文件关联

Linux(redhat5.4)下lnmp环境的搭建_计划_07

// lib 库文件目录关联

Linux(redhat5.4)下lnmp环境的搭建_计划_08

Linux(redhat5.4)下lnmp环境的搭建_计划_09

// 加入开机自动管理

Linux(redhat5.4)下lnmp环境的搭建_Linux_10

// 为mysql 配置帐号

Linux(redhat5.4)下lnmp环境的搭建_Linux_11

到这里mysql的安装基本完成

2. Pcre、libevent、nginx的安装

// pcre 的安装:

[root@localhost ~]# tar -jxvf pcre-8.32.tar.bz2 -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/pcre-8.32/

[root@localhost pcre-8.32]# ./configure --prefix=/usr/local/pcre

[root@localhost pcre-8.32]# make && make install

// 系统必要的关联

Linux(redhat5.4)下lnmp环境的搭建_Linux_12

//libevent 的安装

[root@localhost ~]# tar -zxvf libevent-2.0.21-stable.tar.gz -C /usr/local/src/

[root@localhost ~]#cd /usr/local/src/libevent-2.0.21-stable

[root@localhostlibevent-2.0.21-stable]#./configure --prefix=/usr/local/libevent

[root@localhost libevent-2.0.21-stable]# make && make install

//bin文件的关联

[root@localhost libevent]# vim /etc/profile

Linux(redhat5.4)下lnmp环境的搭建_计划_13

[root@localhost libevent]# . /etc/profile

// include 头文件关联

Linux(redhat5.4)下lnmp环境的搭建_压缩包_14

// nginx的安装

[root@localhost ~]# tar -zxvf nginx-1.3.16.tar.gz -C /usr/local/src/

[root@localhost ~]#cd /usr/local/src/nginx-1.3.16

// 注意:最后一个参数--with-pcre 后面跟的是pcre安装包的解压目录路径,如果是用系统中提供的rpm包装的,则可以不用加路径了

Linux(redhat5.4)下lnmp环境的搭建_计划_15

[root@localhost nginx-1.3.16]# maka && make install

// 系统帐号和组的创建

Linux(redhat5.4)下lnmp环境的搭建_Linux_16

//小编先测试一下nginx是否能够正常工作,注意:如果使用的浏览器版本过低则不一定能够成功访问,多试几个浏览器

Linux(redhat5.4)下lnmp环境的搭建_安装_17

// 修改nginx 配置文件,使nginx能够支持php网页

Linux(redhat5.4)下lnmp环境的搭建_计划_18

Linux(redhat5.4)下lnmp环境的搭建_计划_19

Linux(redhat5.4)下lnmp环境的搭建_安装_20

3. php 的安装

[root@localhost ~]# tar -jxvf php-5.4.13.tar.bz2 -C /usr/local/src/

[root@localhost ~]# cd /usr/local/src/php-5.4.13/

Linux(redhat5.4)下lnmp环境的搭建_压缩包_21

[root@localhost php-5.4.13]# make && make install

// 更改php启动前配置及设置文件

Linux(redhat5.4)下lnmp环境的搭建_压缩包_22

到这里我们所需要的包已基本安装配置完成

4. 下面咱们就来测试一下:

测试1:

Linux(redhat5.4)下lnmp环境的搭建_安装_23

Linux(redhat5.4)下lnmp环境的搭建_计划_24

// 测试结果

Linux(redhat5.4)下lnmp环境的搭建_压缩包_25

测试2:

Linux(redhat5.4)下lnmp环境的搭建_计划_26

// 测试结果

Linux(redhat5.4)下lnmp环境的搭建_压缩包_27