博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
非root用户下安装nginx及运行
阅读量:7067 次
发布时间:2019-06-28

本文共 2413 字,大约阅读时间需要 8 分钟。

hot3.png

        本章主要讲如何在无root权限(包含无sudo权限)条件下于centos命令行中安装nginx以及在大于1024的端口(这里用8080)上运行。两种方式,一是下载预编译好的rpm包安装(如果是通过下载rpm方式安装,首先要找对应centos版本的rpm包),二是下载源码后自己编译(要依赖pcre库、zlib库等)。

一、 安装依赖

        1、 下载nginx依赖包

            pcre 下载地址: ,
            zlib 下载地址: ,
            openssl 下载地址:

        2、 安装依赖

        2.1  PCRE库的安装

        解压:

                unzip pcre2-10.31.zip,解压目录为:pcre2-10.31

                然后进入到 cd pcre2-10.31,进行配置、编译、安装

        配置

                ./configure或./config

        编译

                make

        安装

                make install

        备注:也可编译安装一起进行 make && make install

 

        2.2  OpenSSL库的安装

        解压:

                tar –zxvf openssl-1.1.1-pre7.tar.gz,解压目录为:openssl-1.1.1-pre7

                然后进入到 cd openssl-1.1.1-pre7,进行配置、编译、安装

        配置

                ./configure或./config

        编译

                make

        安装

                make install

        备注:也可编译安装一起进行 make && make install

 

        1.3 安装zlib库安装

        解压:

                tar –zxvf zlib-1.2.11.tar.gz,解压目录为:zlib-1.2.11

                然后进入到 cd zlib-1.2.11,进行配置、编译、安装

        配置

                ./configure或./config

        编译

                make

        安装

                make install

        备注:也可编译安装一起进行 make && make install

二、 安装nginx

        解压 nginx : 

# 解压tar -zxvf nginx-1.15.0.tar.gz

        安装 nginx :

# 进入解压目录cd ~/tools/nginx-1.15.0#  --with-pcre=后的路径为pcre的解压后的源路径#  --prefix=路径为nginx想要安装到的目录./configure  --with-http_stub_status_module  --prefix=/home/redhat/tools/nginx  --with-pcre=/home/redhat/tools/pcre2-10.31

        编译与安装 :

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

 

三、常见问题

        1、 不改配置无法正常   

        提示:

nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

        原因:

                启动不了的,因为非root用户启动不了1024以下端口
        解决方案:
                修改一下nginx.conf监听端口为1024以上端口,重新启动nginx

    2、 直接安装nginx提示缺少依赖

        提示:

./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=
option.

        原因:

                因为Nginx需要其他第三方库的支持,比如rewrite模块需要pcre库,ssl需要openssl库等。
        解决方案:
                安装所需的pcre(www.pcre.org),zlib(www.zlib.org),openssl(www.openssl.org)等。

    3、 ngixn 进行make时报错

        提示:

make -f objs/Makefilemake[1]: Entering directory `/home/redhat/tools/nginx'cd /home/redhat/tools/nginx/zzw_other/pcre-8.10 \        && if [ -f Makefile ]; then make distclean; fi \        && CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \        ./configure --disable-shared /bin/sh: line 2: ./configure: 没有那个文件或目录make[1]: *** [/home/redhat/tools/nginx/zzw_other/pcre-8.10/Makefile] 错误 127make[1]: Leaving directory `/home/redhat/tools/nginx'make: *** [build] 错误 2

        原因:

                --with-pcre=让你设置到源码目录,而不是编译安装后的目录。这点与apache的编译还有点不同。用./configure  -help 可以看配置参数帮助
        解决方案:
                修改 --with-pcre=后的路径为pcre的解压后的源路径

 

 

 

转载于:https://my.oschina.net/u/3375733/blog/1827778

你可能感兴趣的文章
配置FTP服务(二):vsftpd部署和优化
查看>>
在C#中调用API获取网络信息和流量
查看>>
Java集合遍历引发的"血案"
查看>>
Webpack入门教程六
查看>>
编译原理:正规式转变成DFA算法
查看>>
MongoDB数据库的MapReduce简单操作(转)
查看>>
cisco图标
查看>>
java获取类的信息
查看>>
Hibernate5-进阶添加工具类,对获取Session的方法封装
查看>>
通过内存映射文件来颠倒文本内容(暂没有处理Unicode和换行符)
查看>>
Debian软件包信息查询
查看>>
天猫物流提速背后:大数据加速颠覆传统零售业
查看>>
网页优化十大策略
查看>>
为每一个table单元格设置不同的背景颜色
查看>>
盘点智能硬件中那些脑洞大开的黑科技
查看>>
[HDFS Manual] CH4 HDFS High Availability Using the Quorum Journal Manager
查看>>
maven pom.xml详解
查看>>
活动目录数据库文件介绍
查看>>
Linux下配置tomcat+apr+native应对高并发
查看>>
html5播放mp4视频代码
查看>>