博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx的安装(编译) && 常用配置
阅读量:6693 次
发布时间:2019-06-25

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

  hot3.png

背景:

考虑到生产环节下,nginx的使用可能更多的需要人们去定制化一些配置(如nginx所使用的pcre版本、安装路径、log路径等一些信息),所以,我们更多的采用源代码编译的方式去安装nginx进行使用。

一:mac下安装nginx

转自:  (转)

二:centos下安装nginx

启动的时候出现:

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory错误的话,解决方案转自:,即执行:ln -s /usr/local/lib/libpcre.so.1 /lib64 即可! 

ps:我的一些软件的版本信息:(切换到root进行install)

常见错误以及解决方案

1. no acceptable C compiler found in $PATH

    则说明缺少GCC环境,安装即可:yum install gcc

2. You need a C++ compiler for C++ support

    安装环境即可:yum install -y gcc gcc-c++

  1. pcre:pcre-8.37.tar.gz

    1. tar -zxvf pcre-8.37.tar.gz

    2. cd pcre-8.37

    3. ./configure

    4. make && make install

    5. ln -s /usr/local/lib/libpcre.so.1 /lib64/

  2. zlib-1.2.8.tar.gz

    1. tar -zxvf zlib-1.2.8.tar.gz 

    2. cd zlib-1.2.8

    3. ./configure

    4. make && make install

  3. openssl-1.0.2d.tar.gz (时间稍微久点)

    1. tar -zxvf openssl-1.0.2d.tar.gz

    2. cd openssl-1.0.2d

    3. ./config

    4. make && make install

  4. pagespeed (看个人需求)

  5. tar -zxvf  headers-more-nginx-module.tar.gz

  6. nginx-1.8.1.tar.gz

    1. tar -zxvf nginx-1.8.1.tar.gz 

    2. cd nginx-1.8.1

    3. ./configure --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_random_index_module --without-http_referer_module  --with-pcre=/data/soft/pcre-8.37 --with-zlib=/data/soft/zlib-1.2.8 --with-openssl=/data/soft/openssl-1.0.2d --add-module=/data/soft/headers-more-nginx-module

    4. make && make install (过程稍微久点)

    5. cd  /usr/local/nginx/sbin

    6. ./nginx -t (检测nginx是否安装成功)

    7. ./nginx (启动nginx)

    8. netstat -ntlp | grep 80 (查看nginx的端口是否成功启动)

    9. 访问你目标主机的外网IP,出现了 『Welcome to nginx!』则说明OK!

    10. ./nginx -V ,可以查看nginx ./configure的一些信息

    11. 如果需要重新安装,重新 ./configure 开始即可

  7. 配置nginx.conf

    1. 防止直接用IP地址访问nginx (如果做其它动作,自行配置即可)

      1. server {        listen 80 default_server;        server_name _;        rewrite ^/(.*) https://www.abc.com redirect;}

         

    2.  

 

ps :

参考:

  1.  

  2. (编译的时候参数说明)

  3. (ngx_headers_more说明)

  4. (nginx.conf说明)

 

 

转载于:https://my.oschina.net/hebad/blog/416485

你可能感兴趣的文章