LNMP搭建2:Nginx编译安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LNMP搭建2:Nginx编译安装相关的知识,希望对你有一定的参考价值。

1.切换到/usr/local/src/目录下载nginx-1.6.2.tar.gz安装包

[[email protected] ~]# cd /usr/local/src

[[email protected] src]# ls

nginx-1.6.2.tar.gz

2.解压安装包

[[email protected] src]# tar zxvf nginx-1.6.2.tar.gz

[[email protected] src]# echo $?

0

3.进入安装目录

[[email protected] src]# cd nginx-1.6.2

安装配置依赖项

[[email protected] src]# yum install -y gcc pcre-devel zlib-devel

配置安装选项

[[email protected] nginx-1.6.2]# ./configure --prefix=/usr/local/nginx --with-pcre

4.直到配置全部正确开始编译

[[email protected] nginx-1.6.2]# echo $?

0

[[email protected] nginx-1.6.2]# make

5.编译无误之后开始安装

[[email protected] nginx-1.6.2]# echo $?

0

[[email protected] nginx-1.6.2]# make install

[[email protected] nginx-1.6.2]# echo $?

0

6.安装好之后可以看到如下目录结构,其中nginx是可执行文件,类似于httpd

[[email protected] nginx-1.6.2]# ls /usr/local/nginx/

conf  html  logs  sbin

[[email protected] nginx-1.6.2]# ls /usr/local/nginx/sbin

nginx

7.将nginx加入系统环境变量PATH中:

[[email protected] nginx-1.6.2]# vim /etc/profile.d/path.sh

#!/bin/bash

export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/php/bin/:/usr/local/php/php/sbin/:/usr/local/nginx/sbin/

[[email protected] nginx-1.6.2]# source /etc/profile.d/path.sh

8.启动Nginx服务

[[email protected] nginx-1.6.2]# nginx

9.查看Nginx进程

[[email protected] nginx-1.6.2]# ps aux | grep nginx

root  1870  0.0  0.0   3548   520 ?   Ss   06:48   0:00 nginx: master process nginx

nobody  1871  0.0  0.0   3732   876 ?    S    06:48   0:00 nginx: worker process

root  1873  0.0  0.0   5984   748 pts/0    S+   06:48   0:00 grep nginx

10.查看端口

[[email protected] nginx-1.6.2]# netstat -lnp |grep nginx

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      12001/nginx


以上是关于LNMP搭建2:Nginx编译安装的主要内容,如果未能解决你的问题,请参考以下文章

LNMP搭建02 -- 编译安装Nginx

使用编译搭建LNMP环境

LNMP环境搭建

LNMP搭建过程详解,验证搭建论坛

CentOS 7 搭建 LNMP 架构详细过程 + Discuz 论坛安装 (手工编译)

LNMP平台搭建案例:部署论坛,电影院管理系统