centos7 nginx安装

  1. 下载
wget http://nginx.org/download/nginx-1.14.0.tar.gz
  1. 解压
tar -zxvf nginx-1.14.0.tar.gz -C  /usr/local
  1. 进入文件 进行编译
yum -y install gcc gcc-c++ autoconf automake make

cd /usr/local/nginx-1.14.0

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

  make 

可能会报错:
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/download/nginx_upstream_check_module-master/ -I objs \
    	-o objs/src/os/unix/ngx_user.o \
    	src/os/unix/ngx_user.c
    src/os/unix/ngx_user.c: 在函数‘ngx_libc_crypt’中:
    src/os/unix/ngx_user.c:26:7: 错误:‘struct crypt_data’没有名为‘current_salt’的成员
         cd.current_salt[0] = ~salt[0];

处理方案;

打开 src/os/unix/ngx_user.c  

    #ifdef __GLIBC__
        /* work around the glibc bug */
        cd.current_salt[0] = ~salt[0];     ##把这一行注释掉
    #endif
  1. 编译安装
 make install
可能会报错
igned int (*)(struct <匿名> *)} to ‘void (*)(ngx_http_script_engine_t *){或称 ‘void (*)(struct <匿名> *)} [-Werror=cast-function-type]
         code->code = (ngx_http_script_code_pt)
                      ^
    src/http/ngx_http_script.c: 在函数‘ngx_http_script_add_full_name_code’中:
    src/http/ngx_http_script.c:1296:18: 错误:cast between incompatible function types from ‘size_t (*)(ngx_http_script_engine_t *){或称 ‘long unsigned int (*)(struct <匿名> *)} to ‘void (*)(ngx_http_script_engine_t *){或称 ‘void (*)(struct <匿名> *)} [-Werror=cast-function-type]
         code->code = (ngx_http_script_code_pt) ngx_http_script_full_name_len_code;
                      ^
    cc1:所有的警告都被当作是错误
    make[1]: *** [objs/Makefile:893:objs/src/http/ngx_http_script.o] 错误 1
    make[1]: 离开目录“/usr/download/nginx-1.14.1”
    make: *** [Makefile:8:build] 错误 2
    解决办法:打开  vim objs/Makefile  把 -Werrori删掉  
  1. 启动:
cd /usr/local/nginx 

./sbin/nginx -s reload
可能报错:
nginx: [error] open() "/usr/local/nginx-1.14.1/logs/nginx.pid" failed (2: No such file or directory)

解决方案:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

ps -A | grep nginx
查看nginx 是否启动

浏览器进行访问
ip+80

出现403
解决方案1
配置文件头
把配置文件头部的#user nginx;注释去掉改为 user root;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值