linux nginx 安裝 與 配置

2022-09-08 06:51:14 字數 3171 閱讀 7189

1,安裝

安裝sudo yum install -y nginx

檢視安裝路徑

whereis nginx

如 nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8

.gz新增啟動服務

sudo systemctl start nginx.service

設定開機啟動

sudo systemctl enable nginx.service

2.操作

指定配置檔案啟動

nginx -c /etc/nginx/nginx.conf

重啟 【指定配置檔案重啟】

/usr/sbin/nginx -s reload -c /etc/nginx/nginx.conf

檢視程序資訊

ps -ef |grep nginx

關閉nginx -s stop

3.配置模板

使用 yum 安裝 ,配置檔案在/etc/nginx 裡面

#訪問vue 靜態頁面

location ^~ /

error_page 500 502 503 504 /50x.html;

location = /50x.html

}server

location ^~ /attchapi/images/

#訪問vue 靜態頁面

location ^~ /

error_page 500 502 503 504 /50x.html;

location = /50x.html

}}view code

順便把win10的配置也記錄下

# 訪問附件

location ^~/attchapi/images/

# vue前端 ,訪問 http:

//localhost:50/

location ^~ /

# #訪問vue 靜態頁面

# location ^~ /

#error_page

404 /404

.html;

# redirect server error pages to the

static page /50x.html

#error_page

500502

503504 /50x.html;

location = /50x.html

}server

location ^~ /manage

location ^~ /permission

location ^~ /weixin

location ^~ /zuul

location ^~ /eureka

# 訪問附件

location ^~/attchapi/images/

# # vue前端 ,訪問 http:

//localhost:50/

# location ^~ /

#訪問vue 靜態頁面

location ^~ /

#error_page

404 /404

.html;

# redirect server error pages to the

static page /50x.html

#error_page

500502

503504 /50x.html;

location = /50x.html

}}view code

Linux Nginx安裝與配置 1

一.nginx 簡介與作用 a.高效能http伺服器 b.可做反向 c.imap pop3 smtp 伺服器 二.特點 a.記憶體占用少 b.併發能力強 c.輕量級的 web伺服器 三.安裝依賴 1.rewrite模組 需要 pcre 庫 2.gzip模組需要 zlib 庫 3.ssl 功能需要 o...

Linux nginx安裝與配置(參考)

1.進入linux伺服器安裝依賴 yum install y gcc c zlib zlib devel openssl openssl devel pcre pcre devel 2.新增使用者和組 groupadd nginx useradd s sbin nologin m g nginx n...

Linux Nginx 安裝配置

nginx安裝 關於nginx的安裝推薦 牛遷遷的教程,裡面包含了安裝過程和常見錯誤 nginx.conf檔案配置 nginx作為前置http伺服器 如果僅使用ip來訪問,那麼直接訪問埠號即可,nginx.conf檔案裡做如下配置 upstream web server 如果使用網域名稱來訪問,而網...