nginx安裝手冊(cè)

當(dāng)前操作系統(tǒng):Redhat 7.8

1.安裝依賴包

  • 在線安裝:
    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
  • 離線安裝:
    yum localinstall *.rpm

redhat7.8離線包下載地址:https://mirrors.aliyun.com/centos-vault/7.8.2003/

rpm包下載清單:


截圖.png

2.下載并解壓安裝包

下載nginx安裝包

wget http://nginx.org/download/nginx-1.21.6.tar 
tar -xvf nginx-1.21.6.tar

3.安裝nginx

cd nginx-1.21.6
 #創(chuàng)建nginx目錄 
mkdir /usr/local/nginx 
#執(zhí)行命令 考慮到后續(xù)安裝ssl證書(shū) 添加兩個(gè)模塊 
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module 
#執(zhí)行make命令 
make
#執(zhí)行make install命令 
make install

4.配置nginx.conf

#在nginx.conf中添加虛擬站點(diǎn)配置引用 
include vhost/*.conf;

5.配置虛擬站點(diǎn)(***.com.conf)

upstream a_api_server{
    server 10.86.237.108:8091;
    server 10.86.237.109:8091;
}
server {
    listen 443 ssl;
    server_name ***.com;
    ssl_certificate /usr/local/nginx/conf/cert/***.com.pem;
    ssl_certificate_key /usr/local/nginx/conf/cert/***.com.key;
    ssl_session_timeout 5m;
    ssl_ciphers ***;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
        
    add_header X-Frame-Options DENY;
  
    location /admin/ {
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass http://a_api_server/admin/;
    }
}

6.配置開(kāi)機(jī)啟動(dòng)

cd /etc/systemd/system vi nginx.service

nginx.service內(nèi)容:

[Unit]
Description=nginx service
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

設(shè)置開(kāi)機(jī)自啟動(dòng):

systemctl enable nginx

常用命令:

#啟動(dòng)nginx服務(wù) 
systemctl start nginx 
#重新加載配置 
systemctl reload nginx 
#重新啟動(dòng)服務(wù) 
systemctl restart nginx 
#停止開(kāi)機(jī)自啟動(dòng) 
systemctl disable nginx
#關(guān)閉防火墻命令: 
systemctl stop firewalld
#禁用防火墻命令: 
systemctl disable firewalld
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、環(huán)境安裝 nginx 是 C 語(yǔ)言開(kāi)發(fā),建議在 linux 上運(yùn)行,本教程使用 Centos6.5 作為安裝環(huán)...
    ArcadeChan閱讀 130評(píng)論 0 0
  • 個(gè)人專題目錄 nginx安裝手冊(cè) LVS,Nginx和HAProxy負(fù)載均衡對(duì)比 Nginx支持TCP代理和負(fù)載均...
    Java及SpringBoot閱讀 500評(píng)論 0 2
  • 1 nginx安裝環(huán)境nginx是C語(yǔ)言開(kāi)發(fā),建議在linux上運(yùn)行,本教程使用Centos6.5作為安裝環(huán)境。?...
    nerowu閱讀 513評(píng)論 0 5
  • 1、安裝配置docker并準(zhǔn)備基礎(chǔ)鏡像 1.1 環(huán)境準(zhǔn)備 Ubuntu 18.04 :192.168.7.38 1...
    一塵_1dd6閱讀 1,053評(píng)論 0 0
  • 在上一片文章中說(shuō)明了使用mac終端進(jìn)行服務(wù)器的登陸操作,接下來(lái)我們來(lái)看一下,怎么配置服務(wù)器的ngxin環(huán)境 安裝環(huán)...
    Morbid_D閱讀 6,803評(píng)論 1 1

友情鏈接更多精彩內(nèi)容