生活是美好的

 找回密碼
 立即註冊
搜索
查看: 287|回復: 0

nginx安裝1.12

[複製鏈接]

112

主題

112

帖子

453

積分

管理員

Rank: 9Rank: 9Rank: 9

積分
453
發表於 2019-9-27 11:12:15 | 顯示全部樓層 |閱讀模式
#安裝PCRE庫支持
  1. yum install pcre-devel pcre -y
複製代碼
#安裝wget
  1. yum install wget -y
複製代碼
#下載Nginx源碼包
  1. cd /usr/src
複製代碼
  1. wget -c http://nginx.org/download/nginx-1.12.0.tar.gz
複製代碼
#解壓Nginx源碼包
  1. tar -xzf nginx-1.12.0.tar.gz
複製代碼
#進入解壓目錄,然後sed修改Nginx版本信息為JWS
  1. cd nginx-1.12.0
複製代碼
  1. sed -i -e 's/1.12.0//g' -e 's/nginx\//JWS/g' -e 's/"NGINX"/"JWS"/g' src/core/nginx.h
複製代碼
#預編譯Nginx
  1. useradd www
複製代碼
  1. ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
複製代碼
出現以下報錯:
checking for OS
+ Linux 3.10.0-327.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

解决方法:安装gcc

  1. yum -y install gcc
複製代碼


错误信息:

./configure: error: the HTTP rewrite module requires the PCRE library.

解决方法:安装pcre-devel

  1. yum install pcre-devel
複製代碼


错误信息:

./configure: error: the HTTP gzip module requires the zlib library.

解决方法:安装zlib-devel

  1. yum install zlib-devel
複製代碼
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

解决方法:

执行以下命令:

  1. yum -y install openssl openssl-devel
複製代碼


#.configure預編譯成功後,執行make命令進行編譯

  1. make
複製代碼


#make執行成功後,執行make install 正式安裝

  1. make install
複製代碼
#至此Nginx Web服務器安裝完畢
測試Nginx服務安裝是否正確,同時啟動Nginx Web服務,具體步驟如下:
1.檢查Nginx配置文件是否正確,返回OK既正確。代碼如下
  1. /usr/local/nginx/sbin/nginx -t
複製代碼
[root@c7-node1 ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful


2.然後啟動Nginx,執行命令
  1. /usr/local/nginx/sbin/nginx
複製代碼
按Enter鍵即可。查看進程是否已啟動,代碼如下:
  1. ps -ef | grep nginx
複製代碼


[root@c7-node4 ~]# ps -ef | grep nginx
root      6892     1  0 10:40 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www       6893  6892  0 10:40 ?        00:00:00 nginx: worker process
root      7082  1431  0 11:29 pts/0    00:00:00 grep --color=auto nginx

Centos 7默認防火墻是沒打開80端口,需要以下命令打開80端口:
#查看防火墻運行情況
  1. firewall-cmd --state
複製代碼
#打開80端口
  1. firewall-cmd --zone=public --add-port=80/tcp --permanent
複製代碼
#重啟防火墻
  1. systemctl restart firewalld.service
複製代碼


通過瀏覽器訪問Nginx默認測試頁面。出現Welcome to nginx!就代表安裝成功
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即註冊

本版積分規則

GMT+8, 2025-4-19 16:40 , Processed in 0.231673 second(s), 20 queries .

© 本站内容由個人原創或轉載,如果侵犯了您的合法權益,請及時聯繫處理! Email:lyb@qq.com

快速回復 返回頂部 返回列表