在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  -O -W -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 @   xqs42b  阅读(3205)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
点击右上角即可分享
微信分享提示