CentOS6 9編譯安裝Nginx1 12

2022-04-11 02:40:30 字數 4009 閱讀 6313

1:安裝必要的庫

bash

yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel
2:建立nginx使用者和組

bash

groupadd www

#建立乙個使用者,不允許登陸和不創主目錄

useradd -s /sbin/nologin -g www -m www

bash

wget 

tar -xzvf nginx-1.12.0

cd nginx-1.12.0

4:配置並編譯安裝

引數說明:

nginx大部分常用模組,編譯時./configure --help以--without開頭的都預設安裝。

--prefix=path : 指定nginx的安裝目錄。預設 /usr/local/nginx

--conf-path=path : 設定nginx.conf配置檔案的路徑。nginx允許使用不同的配置檔案啟動,通過命令列中的-c選項。預設為prefix/conf/nginx.conf

--user=name: 設定nginx工作程序的使用者。安裝完成後,可以隨時在nginx.conf配置檔案更改user指令。預設的使用者名稱是nobody。--group=name類似

--with-zlib=path : 指定 zlib(版本1.1.3 - 1.2.5)的原始碼解壓目錄。在預設就啟用的網路傳輸壓縮模組ngx_http_gzip_module時需要使用zlib 。

--with-http_ssl_module : 使用https協議模組。預設情況下,該模組沒有被構建。前提是openssl與openssl-devel已安裝

--with-http_stub_status_module : 用來監控 nginx 的當前狀態

--with-http_realip_module : 通過這個模組允許我們改變客戶端請求頭中客戶端ip位址值(例如x-real-ip 或 x-forwarded-for),意義在於能夠使得後台伺服器記錄原始客戶端的ip位址

--add-module=path : 新增第三方外部模組,如nginx-sticky-module-ng或快取模組。每次新增新的模組都要重新編譯(tengine可以在新加入module時無需重新編譯)

5:配置nginx命令和服務並開機啟動

bash

vim /etc/init.d/nginx
複製一下**到上面的檔案

#附加執行許可權

chmod 755 /etc/init.d/nginx

#開機自啟

chkconfig --level 345 nginx on

service nginx start #可選 start | stop | restart | reload | status | help

6.檢視系統ip位址,開啟nginx的本地網頁

[root@bogon ~]# ifconfig eth0

CentOS 6 9編譯安裝Memcached

將之前放在onenote上的筆記放到部落格,如有錯誤還請指出 先編譯安裝libevent 安裝到 usr local libevent wget org files memcached 1.5 7.tar gztar zxvf memcached 1.x.x tar gz 解壓原始碼 cd memc...

centos6 9編譯安裝nginx

1 安裝nginx所需的依賴包 yum y install gcc gcc c autoconf automake zlib zlib devel openssl openssl devel pcre devel wget tar zxvf nginx 1.10.3.tar.gz 4 cd opt ...

Centos6 9編譯安裝httpd2 4

環境 一 安裝開發包組 三 編譯安裝 建立賬戶 編譯安裝 四 配置 1 配置httpd服務 user apache group apache 2 配置path變數 root centos6 httpd 2.4.27 vim etc profile.d httpd24.sh3 配置服務指令碼 4 新增...