Centos系統Nginx安裝與配置

2021-10-23 10:25:08 字數 2032 閱讀 8005

安裝nginx需要依賴某些包,執行以下命令

yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
//可自行更換版本

//解壓

tar -zxvf nginx-1.10.1.tar.gz

//進入目錄

cd nginx-1.10.1

//執行

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

啟動命令

cd /usr/local/nginx/sbin/

./nginx

./nginx -s stop

./nginx -s quit

./nginx -s reload

配置nginx.service

//新建service檔案

vim /usr/lib/systemd/system/nginx.service

//儲存以下內容

//賦與操作許可權

chmod +x /usr/lib/systemd/system/nginx.service

//啟動/關閉/重啟/開機自啟

systemctl start nginx.service

systemctl stop nginx.service

systemctl restart nginx.service

systemctl enabled nginx.service

nginx配置檔案參考

}#禁用空主機頭訪問

include /work/server/nginx/sites-enabled/*.conf;

}實際配置檔案參考

upstream nwpt-jenkins 

server

}server

centOs系統安裝nginx

1 使用yum安裝ngnix nginx自帶yum命令,可以直接使用 yum install y nginx2 設定開機啟動 systemctl start nginx.service systemctl enable nginx.service cd usr share nginx html ng...

CentOS系統下安裝Nginx

系統平台 centos 7.7.1908 core nginx1.9.1 pcre8.42 01.安裝編譯環境及庫檔案 yum y install make zlib zlib devel gcc c libtool openssl openssl devel02.安裝pcre,讓nginx支援re...

CentOS 7 5 系統下安裝nginx

選擇你想要安裝的位址 cd usr local etc wget 安裝nginx執行庫 yum y install gcc gcc c automake autoconf libtool make yum y install pcre zlib openssl openssl devel 解壓ngi...