nginx的安装

前言

首先找到一篇nginx安装教程,我参考的是
https://www.runoob.com/linux/nginx-install-setup.html
因为我使用的是阿里云环境可以连接外网,因此可以使用wget以及yum命令。
虽然是参考的教程,但还是有一些坑。

1.configure命令变动

在这里插入图片描述
将上图的命令修改为

./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.35

这个地方就修改了prefix的位置,修改后的位置是默认的。同时去除–with-http_stub_status_module --with-http_ssl_module这两个配置。这两个配置会导致之后第4点错。

2.make命令报错一
src/core/ngx_murmurhash.c: In function ‘ngx_murmur_hash2’:
src/core/ngx_murmurhash.c:37:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[2] << 16;
         ~~^~~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:38:5: note: here
     case 2:
     ^~~~
src/core/ngx_murmurhash.c:39:11: error: this statement may fall through [-Werror=implicit-fallthrough=]
         h ^= data[1] << 8;
         ~~^~~~~~~~~~~~~~~
src/core/ngx_murmurhash.c:40:5: note: here
     case 1:
     ^~~~

这个是把警告的命令都当成了报错,这个百度可以很轻松找到。
需要编辑nginx目录下的objs/Makefile文件,去除-Werror即可。
在这里插入图片描述
需要注意的是每次重新执行./configure命令后,该文件都会重置为修改前有-Werror的内容。因此执行./configure后需要再修改Makefile文件。
修改后重新执行make命令,上面的error就会变成warning。

3. make命令报错二
src/os/unix/ngx_user.c: In function ‘ngx_libc_crypt’:
src/os/unix/ngx_user.c:35:7: error: ‘struct crypt_data’ has no member named ‘current_salt’
     cd.current_salt[0] = ~salt[0];
       ^

这里根据百度,找到两种说法。
一种是因为系统版本为centos8,需要修改为centos7。这种方式没有尝试过。我采用的是另一种,找到对应的文件,将该部分内容注释掉。
在这里插入图片描述
然后接着重新执行make命令。

4. make命令报错三

关于ssl的配置编译报错。解决办法见1.configure命令变动
在这里插入图片描述

5.nginx命令

经过上述配置,在/usr/local下面可以看到nginx文件夹。在其下的sbin目录下可以执行nginx的命令。
在这里插入图片描述

nginx -v

查看nginx版本
在这里插入图片描述

nginx -s stop

停止nginx命令会遇到报错,是因为这时候都没有nginx在运行。

nginx: [error] invalid PID number "" in "/run/nginx.pid"
nginx -t

检查/etc/nginx/nginx.conf配置文件语法是否正确
在这里插入图片描述

nginx -c /etc/nginx/nginx.conf

编译执行nginx命令。执行这个命令后,就不会报错 invalid PID number “” in “/run/nginx.pid”
在这里插入图片描述

nginx -s reload

重新加载/etc/nginx/nginx.conf配置,用于nginx配置修改后执行,再重启。

nginx -s reopen

修改nginx.conf配置文件后,重启nginx。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值