安装前准备

对于nginx编译安装需要先安装编译 的工具,然后再安装nginx依赖

yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
1
2
下载nginx

#管网镜像
http://nginx.org/download/

#获取nginx,官方地址
wget http://nginx.org/download/nginx-1.10.1.tar.gz
wget http://nginx.org/download/nginx-1.6.2.tar.gz

#这个是我自己七牛的服务器
wget http://yellowcong.qiniudn.com/nginx-1.10.1.tar.gz

#解压 /usr/local/nginx 目录
tar -zxvf nginx-1.10.1.tar.gz
1
2
3
4
5
6
7
8
9
10
11
12
安装nginx

第一步是配置,第二步是编译安装

配置nginx

#进入到nginx-1.10.1 ,并配置nginx
cd nginx-1.10.1

#配置nginx
#--prefix 指定安装的目录
#/usr/local/nginx 是安装目录,不能和自己下载的文件目录重了
#./configure --prefix=/usr/local/nginx

#带ssl stub_status模块 添加strem模块 –with-stream,这样就能传输tcp协议了
#http_stub_status_module 状态监控
#http_ssl_module 配置https
#stream 配置tcp得转发
#http_gzip_static_module 压缩
#http_sub_module 替换请求
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream

#带用户得方式
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-http_gzip_static_module --with-http_sub_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
到nginx的目录下,然后配置nginx

看到了结果,就差不多 代表成功了

编译安装

只要出现上面的,差不多就是完事了,可以编译了,如果还是有错误,可以使用yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel命令,安装所有依赖

#编译安装
make && make install
1
2

安装成功

安装成功后,会在./configure --prefix=/usr/local/nginx,指定的目录/usr/local/nginx创建4个 文件夹。具体功能下面有介绍。

#启动 nginx服务
/usr/local/nginx/sbin/nginx
#停止服务
/usr/local/nginx/sbin/nginx -s stop

#重启服务
/usr/local/nginx/sbin/nginx -s reload

#查看启动情况
ps -ef|grep nginx

#查看是否启动成功
curl 192.168.100.10

#查看端口情况
netstat -ano|grep 80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
nginx正常运行

网页访问正常

查看端口情况

目录结构

目录 作用
conf 用于存储nginx配置文件
html 用于存放静态网页
logs 存放日志
sbin 用于存放 nginx这种工具

错误合集

1、./configure: error: C compiler cc is not found

错误消息

[root@1088d470c710 nginx-1.10.1]# ./configure
checking for OS
+ Linux 3.10.0-514.26.2.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found
1
2
3
4
5
6
7
解决办法
安装编译工具

[root@1088d470c710 nginx-1.10.1]# yum -y install gcc gcc-c++ autoconf automake make
1
2
然后再次编译,可以了,然而又遇到了新问题

2、checking for PCRE library … not found

pcre没有发现的问题,需要安装pcre ,他作用是让ngnix支持rewrite功能
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
1
2
3
4
5
6
7
8
9
10
3、安装pcre

我打算安装的,结果发现这鸡毛已经安装过了,然后我需要在./configure的时候指定目录./configure --with-pcre=./auto/lib/pcre

[root@1088d470c710 nginx-1.10.1]# yum install pcre
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package pcre-8.32-15.el7_2.1.x86_64 already installed and latest version
1
2
3
4
5
6
7
8
简单说一下centos如何查找文件

#查找文件,需要获取pcre的安装位置
find -name pcre
1
2
4、安装zlib

还缺少zlib library信息,感觉编译nginx是一个错误,直接使用rpm安装包多爽,安装zlib吧,别说别的了

yum -y install make zlib zlib-devel gcc-c++ libtool
1
错误信息

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
1
2
3
4

5、cp: “conf/koi-win” 与”/usr/local/nginx/nginx-1.6.2/conf/koi-win” 为同一文件

文件为同一个文件的问题

cp: "conf/koi-win" 与"/usr/local/nginx/nginx-1.6.2/conf/koi-win" 为同一文件
make[1]: *** [install] 错误 1
make[1]: 离开目录“/usr/local/nginx/nginx-1.6.2”
make: *** [install] 错误 2
1
2
3
4
5

---------------------
作者:狂飙的yellowcong
来源:CSDN
原文:https://blog.csdn.net/yelllowcong/article/details/76382900
版权声明:本文为博主原创文章,转载请附上博文链接!

Nginx之解压编译安装-yellowcong的更多相关文章

  1. MySQL 5.7 解压版 安装教程(图文详细)[Windows]

    最近在学习中用到了MySQL数据库,在安装过程中遇到了不少问题,在翻了大半天百度后,问题基本都解决了,所以写一篇MySQL 5.7 解压版的图文详细安装教程. 至于为什么我会选择解压版而不是安装版,一 ...

  2. ubuntu 下rar解压工具安装方法

    1.压缩功能安装 sudo apt-get install rar卸载 sudo apt-get remove rar2.解压功能安装 sudo apt-get install unrar卸载 sud ...

  3. mysql 5.7 64位 解压版安装

    64位操作系统最好安装64位的mysql数据库,充分利用内存的寻址能力,对于windows而言,mysql官网只提供了32位的MSI安装程序,因为在windows下安装64位的mysql,选择解压版安 ...

  4. MySQL解压版安装配置详解

    MySQL解压版安装起来比较简单,步骤相对较少.下面我们就来详细介绍一下如何在windows操作系统上安装解压班的MySQL. 1.下载解压版MySQL,地址:http://downloads.mys ...

  5. MariaDB数据解压版安装(10.0.16)

    官网下载地址:https://downloads.mariadb.org/    (自己选择版本下载) 在windows 7 下安装 1.下载到解压版安装文件mariadb-10.0.16-win32 ...

  6. Win10下Mysql5.7.13,解压版安装流程

    一.环境变量配置 1.将下载好的压宿包解压到安装目录,我的安装目录就是:D:\DevelopmentTool\Mysql5.7.13\mysql-5.7.13-winx64 2.鼠标选择计算机右键,点 ...

  7. 【Linux】MySQL解压版安装及允许远程访问

    安装环境/工具 1.Linux( centOS 版) 2.mysql-5.6.31-linux-glibc2.5-x86_64.tar 安装步骤 1.下载mysql解压版(mysql-5.6.31-l ...

  8. mysql-5.7.17-winx64解压版本安装图解附带一些常见问题

    第一步:下载mysql-5.7.17-winx64解压版本:http://dev.mysql.com/downloads/mysql/ 第二步:解压到安装目录,如:D:\MySql\mysql-5.7 ...

  9. MySQL5.7.23解压版安装教程

    每次找安装教程太麻烦,因此给自己备份一下步骤,方便以后查看.解压版下载地址https://dev.mysql.com/downloads/mysql/,详细图解如下: 1.根据自己需求,选择适合自己的 ...

随机推荐

  1. [转]MySQL的简单使用和JDBC示例

    MySql简单操作 //启动mysql net start mysql //登陆 mysql -u root -p //创建建数据库 create database mydb; create data ...

  2. CF - 420B - Online Meeting(思维)

    题意:n 个人參加线上会议.某经理记录了中间一段时间的 m 条上下线记录(1 ≤ n, m ≤ 105).+ 表示上线,- 表示下线. leader是指仅仅要有人在线,他都在线的人.求全部可能的lea ...

  3. 【VBS】检索Outlook本地邮箱

    实现功能:使用VBS检索Outlook本地邮箱中,今天是否收到某标题的邮件. 代码如下: ' yyyy-m-d 0:00 AM ' yyyy-m-d 11:59 PM Function CheckMa ...

  4. vue 中 this.$router.push() 路由跳转传参 及 参数接收的方法

    传递参数的方法:1.Params 由于动态路由也是传递params的,所以在 this.$router.push() 方法中 path不能和params一起使用,否则params将无效.需要用name ...

  5. Vue2.0 :key作用

    转自:https://www.cnblogs.com/zhumingzhenhao/p/7688336.html 为了给 Vue 一个提示,以便它能跟踪每个节点的身份,从而重用和重新排序现有元素,你需 ...

  6. BC 1.2 模式(Battery Charging Specification 1.2)

    转自:http://blog.csdn.net/liglei 转自:http://blog.csdn.net/liglei/article/details/22852755 USB BC1.2有以下三 ...

  7. request获取数据的几种方法

    1.request.getparameter(); String value=request.getparameter("key"); 2.request.getParameter ...

  8. emacs 简记

    简介 Emacs作为神的编辑器,不用介绍了吧,说点感受. 用了一段时间了,总体感觉其实Emacs是很简单的,甚至比vim还简单,因为在X环境下,打开后可以就像记事本一样使用.但是,使用Emacs的人一 ...

  9. Linux内核编译过程分析

    http://pan.baidu.com/s/1mgtACVu 其中是我总结生成的一些文档,以便于理解当我们输入make uImage后,系统是怎么一步一步生成uImage的,我采用的是逆向分析的方法 ...

  10. PowerBuilder -- Len(), LenA() 与 String, Blob

    使用的是Powerbuilder12.5与Powerbuild9 不太一样 函数 String Blob Len() 返回字符数 返回字符数对应的字节数 LenA() 返回字节数 返回字符数对应的字节 ...