在ubuntu18 安装nginx过程,以及遇到的错误!

1.下载

nginx下载的地址:https://nginx.org/en/download.html

我选择的版本:1.10.3

2.解压

指定一个目录下面放置下载的文件,然后解压文件

命令:tar zxvf nginx-1.6.3.tar.gz

3.安装

然后进入到解压的目录下:

执行命令:

3.1 执行命令1:

1
./configure  

注意可能遇到报错:

  错误1:

1
2
3
4
/configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

  解决1:

1
sudo apt-get install libpcre3 libpcre3-dev

 3.2 执行命令2:

1
make

 可能遇到错误1:

1
2
3
4
5
6
7
8
9
10
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  

原因:将警告当成错误处理

解决错误1:进入到nginx-1.6.3目录下(解压的目录)

找到当前目录下找到objs文件夹,并进入,打开文件Makefile,找到有一下内容的这行:

1
CFLAGS =  -pipe  ---Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  

把这行内容中的 “-Werror”去掉

-Werror: gcc将所有的警告当成错误进行处理

转至博客:https://segmentfault.com/a/1190000016370803

3.3 执行命令3:

sudo make install

4.启动,重启,停止

nginx默认安装到:

/usr/local/nginx

进入到该目录下(注意:一定要进入到该目录下面,不然下面的命令无效):

1
cd /usr/local/nginx

启动:

1
sudo sbin/nginx

查看是否成功

1
ps aux | grep nginx

重新加载配置文件

sudo sbin/nginx -s reload

停止nginx服务:

1
sudo sbin/nginx -s stop

5.卸载nginx  

1
sudo apt-get --purge autoremove nginx

6.查看nginx版本

注意:一定要进入nginx安装目录下

sbin/nginx -V 

 

posted on   剩余价值  阅读(796)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示