Linux中Nginx的安裝

2021-08-11 12:22:01 字數 3768 閱讀 7695

yum庫中沒有需要自己設定一下,檢視其官網,設定yum庫,

to

set up the yum repository for rhel/centos, create the file named /etc/yum.repos.d/nginx.repo with the following contents:

[nginx]

name=nginx repo

baseurl=

gpgcheck=0

enabled=1

replace 「os」 with 「rhel」 or 「centos」, depending on the distribution used, and 「osrelease」 with 「6」 or 「7」, for

6.x or

7.x versions, respectively.

也就是說在/etc/yum.repos.d目錄下新建乙個nginx.repo檔案在裡邊填寫內容

[nginx]

name=nginx repo

baseurl=

gpgcheck=0

enabled=1

我是centos7,就把os換成centos,把osrelease換成7。之後就可以直接yum install nginx了。

epel(extra packages for enterprise linux),linux附加軟體包,用以建立、維護以及管理針對企業版 linux 的乙個高質量附加軟體包集,面向的物件包括但不限於 紅帽企業版 linux (rhel)、 centos、scientific linux (sl)、oracle linux (ol) 。

先執行

yum install -y epel-release
nginx是c語言開發的,進行原始碼安裝。

安裝編譯器

yum install -y gcc
安裝第三方的庫

yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
然後執行如下命令,其中\是換行用的,和都寫在一行效果是一樣的

nginx http scgi temporary files: "scgi_temp"然後執行

make

make install

這樣就安裝好了

啟動nginx

進入到/usr/local/nginx/sbin目錄下執行

./nginx
這樣就可以啟動了,注意關閉防火牆

然後執行ps aux|grep nginx,顯示三個程序,其中乙個是grep的,兩個是nginx的,其中nginx的兩個程序master和worker都是必須存在的,存在的話就代表nginx正常啟動了。之後在瀏覽器中訪問就可以看到nginx的歡迎介面了,nginx的為80埠。

停止服務

./nginx -s stop

./nginx -s quit

推薦使用quit,會在退出之前完成已經接受的連線請求。而stop是快速關閉,不管有沒有正在處理的請求。

在不停止服務的情況下重新整理配置檔案

./nginx -s reload
linux 安裝nginx - csdn部落格

vim /etc/init.d/nginx

寫入如下內容

$retval儲存該指令碼後更改許可權

chmod 755 /etc/init.d/nginx

chkconfig --add nginx

如果想開機啟動nginx,執行如下命令

chkconfig nginx on

Linux中Nginx的安裝

官網 2.上傳並解壓nginx tar zxvf nginx 1.8.1 tar.gz c usr local src3.編譯nginx 進入到nginx原始碼目錄 cd usr local src nginx 1.8 1 檢查安裝環境,並指定將來要安裝的路徑 configure prefix us...

Linux中的軟體安裝 Nginx

tar zxvf nginx 1.18.0.tar.gz 進入解壓後的目錄 cd nginx 1.18.0 執行.configure 進入sbin目錄中 cd usr local nginx sbin 啟動nginx nginx 關閉防火牆,僅本次生效,重啟後失效 systemctl stop fi...

Linux 中如何安裝nginx

linux系統 centos 7 64位 root localhost pcre 8.37 pcre config version root localhost pcre 8.37 yum y make zlib zlib devel gcc c libtool openssl openssl de...