Nginx源码编译与安装

发布 : 2016-02-22 分类 : 大数据 浏览 :

1.nginx源码安装步骤:

1.1.下载

1.2.查看源码

1.3.准备编译环境

1.3.1.上传安装包至指定文件夹下

1
[root@node1 home]# cd /home

1.3.2.查看是否上传成功

1
[root@node1 home]# ll

1.3.3.安装tar命令(因为安装的是centos最简版,所以需要自己用yum安装tar命令)

1
[root@node1 home]# yum install tar

1.3.4.使用tar解压压缩文件

1
[root@node1 home]# tar -zxf nginx-1.8.0.tar.gz

1.3.5.进入目录

1
2
3
[root@node1 home]# cd nginx-1.8.0
[root@node1 nginx-1.8.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README

1.4.检查(依赖.兼容),预编译

1.4.1.进行预编译

1
[root@node1 nginx-1.8.0]# ./configure --prefix=/usr/nginx-1.8/

1.4.2.查看yum能安装什么pcre的软件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[root@node1 nginx-1.8.0]# yum search pcre
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.yun-idc.com
* extras: mirrors.yun-idc.com
* updates: mirrors.yun-idc.com
=================================== N/S Matched: pcre ===================================
pcre-devel.i686 : Development files for pcre
pcre-devel.x86_64 : Development files for pcre
pcre-static.x86_64 : Static library for pcre
pcre.x86_64 : Perl-compatible regular expression library
pcre.i686 : Perl-compatible regular expression library

Name and summary matches only, use "search all" for everything.

1.4.3.安装pcre依赖

1
[root@node1 nginx-1.8.0]# yum install pcre

1
2
[root@node1 nginx-1.8.0]# yum install pcre-devel
[root@node1 nginx-1.8.0]# yum install zlib-devel

1.5.编译

1
2
功能:1.让用户选定编译特性;2.检查编译环境;
[root@node1 nginx-1.8.0]# ./configure --prefix=/usr/nginx-1.8/

1.6.安装

1
[root@node1 nginx-1.8.0]# make && make install


1.7.启动nginx

1.7.1.进入目录

1
2
3
4
5
6
7
8
9
10
11
[root@node1 nginx-1.8.0]# cd /usr/nginx-1.8/
[root@node1 nginx-1.8]# ll
total 16
drwxr-xr-x 2 root root 4096 Feb 28 05:43 conf
drwxr-xr-x 2 root root 4096 Feb 28 05:43 html
drwxr-xr-x 2 root root 4096 Feb 28 05:43 logs
drwxr-xr-x 2 root root 4096 Feb 28 05:43 sbin
[root@node1 nginx-1.8]# cd sbin
[root@node1 sbin]# ll
total 3168
-rwxr-xr-x 1 root root 3240293 Feb 28 05:43 nginx

1.7.2.启动nginx

1
[root@node1 sbin]# ./nginx

1.7.3.查看nginx运行情况

1
2
[root@node1 sbin]# ps aux | grep ngix
root 15698 0.0 0.0 103248 876 pts/0 S+ 05:51 0:00 grep ngix

1.7.4.查看防火墙是否关闭

1
[root@node1 sbin]# service iptables status

1.7.6.在浏览器上查看是否成功启动nginx服务

1
在浏览器地址栏输入:http://192.168.230.10/

本文作者 : Matrix
原文链接 : https://matrixsparse.github.io/2016/02/22/Nginx源码编译与安装/
版权声明 : 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!

知识 & 情怀 | 二者兼得

微信扫一扫, 向我投食

微信扫一扫, 向我投食

支付宝扫一扫, 向我投食

支付宝扫一扫, 向我投食

留下足迹