• 编译安装nginx1.16.1


    这边有个不错的编译安装的步骤,来记录一下
    1、安装预处理环境

    [root@localhost ~]# dnf install -y lrzsz  psmisc lsof wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel net-tools iotop bc zip unzip zlib-devel  nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed gd-devel GeoIP GeoIP-devel
    

    2、下载包并解压

    wget -O /usr/local/nginx-1.16.1.tar.gz http://nginx.org/download/nginx-1.16.1.tar.gz
    tar xf /usr/local/nginx-1.16.1.tar.gz -C /usr/local
    

    3、编译选项

    cd nginx-1.16.1
    ./configure --prefix=/usr/local/nginx  --with-http_ssl_module 
                --with-http_v2_module  
                --with-http_realip_module 
                --with-http_addition_module  
                --with-http_image_filter_module 
                --with-http_geoip_module 
                --with-http_gunzip_module 
                --with-http_stub_status_module 
                --with-http_gzip_static_module 
                --with-pcre 
                --with-stream 
                --with-stream_ssl_module 
                --with-stream_realip_module
    

    4、编译及安装

    [root@localhost nginx-1.16.1]# make && make install                      #创建目录,并将生成的模块和文件件复制到相应的目录:
    

    5、添加nginx用户

    [root@master2 nginx-1.16.1]# useradd nginx -s /sbin/nologin -u 2000                                  #以普通用户启动nginx
    [root@master2 nginx-1.16.1]# chown nginx.nginx -R /usr/local/nginx                                   #授权
    

    nginx安装完毕之后,在/usr/local/nginx目录下面能够看到几个目录

    [root@master2 nginx-1.16.1]# cd /usr/local/nginx
    [root@master2 nginx]# ls
    conf  html  logs  sbin
    

    conf:该目录中保存了nginx所有的配置文件,其中nginx.conf是nginx服务器的最核⼼最主要的配置文件,其他的.conf则是用来配置nginx相关的功能的,例如fastcgi功能使用的是fastcgi.conf和fastcgi_params两个文件,配置文件一般都有个样板配置文件,是文件名.default结尾,使用时将其复制为并将default去掉即可。
    html:该目录中保存了nginx服务器的web文件,但是可以更改为其他目录保存web文件,另外还有一个50x的web文件是默认的错误页面提示页面。
    logs:该目录用来保存nginx服务器的访问日志错误日志等日志,logs目录可以放在其他路径,比如/var/logs/nginx里面。
    sbin:该目录用来保存nginx二进制启动脚本,可以接受不同的参数以实现不同的功能。

    6、验证版本

    [root@master2 nginx]# sbin/nginx -V
    nginx version: nginx/1.16.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
    built with OpenSSL 1.0.2k-fips  26 Jan 2017
    TLS SNI support enabled
    configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_geoip_module --with-http_gunzip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
    

    7、启动nginx并访问

    [root@master2 nginx]# sbin/nginx 
    

    一些排错问题

    这是后续慢慢自己总结的一些。
    1、今天遇到一个学员的问题。在执行make install 的时候,报了错误,详细的错误是Error: mkdir: cannot create directory ‘/srv/nginx --with-file-aio File name too long就是这种类似的,这是在make install 阶段。一般来说,make install阶段出现问题主要有权限问题,比如使用普通用户进行make install可能写不进去prefix指定的目录,改成使用root用户就可以了。但是这次不一样,报的错误是不能创建目录,其实在make install阶段报错只是把问题表现出来了,实际上configure阶段就有问题了,只是没有明显的错误,执行echo $?你会发现也是显示结果为0,表示成功。经过后续的仔细研究,发现在configure的命令中出现了可疑字符问题。如下所示:

    [root@localhost nginx-1.16.1]# cat -A a.sh
    ./configure $
    --prefix=/srv/nginxM-BM- $
    --with-file-aioM-BM- $
    --with-http_auth_request_moduleM-BM-  $
    --with-http_ssl_module $
    --with-http_addition_moduleM-BM- $
    --with-http_xslt_module=dynamicM-BM- $
    --with-http_geoip_module=dynamicM-BM- $
    

    也就是里面的M-BM-字符,这种字符会导致我们命令直接不可用,但是看不到的,只能使用cat -A把所有的字符都显示出来才行。所以我们要去掉,很简单,如下命令所示:

    sed -i 's/xc2xa0/ /g' a.sh
    

    这样就可以去掉特殊字符了、

  • 相关阅读:
    img标签中alt属性与title属性在seo的作用-摘自网友
    C# 从补码中获取有符号数的实际数值
    you need to load the kernel first
    桌面远程访问
    供应商通过向日葵访问公司外网办公电脑,通过办公电脑访问内网内生产用电脑
    配置交换机口可以上外网
    抠图和不失真的改变图形大小
    用机房现有双网口电脑添加监控
    服务器配置IP
    在DELL服务器上安装windows2012 r2服务器系统
  • 原文地址:https://www.cnblogs.com/FengGeBlog/p/13534156.html
Copyright © 2020-2023  润新知