天天看點

linux下安裝nginx

linux版本:centos7 64位

【yum 安裝最新版nginx:https://www.cnblogs.com/xxoome/p/7256214.html】

在安裝nginx前首先要确認系統中安裝了gcc、pcre-devel、zlib-devel、openssl-devel。

linux下檢查是否安裝過某軟體包:http://www.cnblogs.com/xxoome/p/5866553.html

安裝指令:

nginx下載下傳位址:https://nginx.org/download/

下載下傳“nginx-1.9.9.tar.gz”,移動到/usr/local/下。

linux下安裝nginx
linux下安裝nginx

ok,現在可以執行make 了。 

linux下安裝nginx

執行make、make install指令

測試是否安裝成功

錯誤資訊:

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: no such file or directory)

2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: no such file or directory)

原因分析:nginx/目錄下沒有logs檔案夾

解決方法:

正常情況的資訊輸出:

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

啟動nginx 

在浏覽器中輸入伺服器的ip位址,如:192.168.1.12

很不幸,打不開連結。下面進行原因排查:

linux下安裝nginx
linux下安裝nginx

說明伺服器的80端口是打不開的。

因為我使用的linux系統版本是centos7,是以可以在伺服器中執行如下指令來驗證》》

linux下安裝nginx

顯然80端口沒有開啟。

下面我們開啟80端口:

 --permanent   #永久生效,沒有此參數重新開機後失效

linux下安裝nginx

重新整理浏覽器

linux下安裝nginx

====================== 分割線 ====================

配置完畢!

2、配置nginx開機自啟動

linux下安裝nginx