在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 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM