最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Centos7安裝、卸載nginx及配置,配置成系統(tǒng)服務(wù)方式(一步到位)

 更新時間:2023年12月25日 15:36:54   作者:luvJie-7c  
這篇文章主要介紹了Centos7安裝、卸載nginx及配置,配置成系統(tǒng)服務(wù)方式(一步到位),具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

前言

最近斥巨資買了臺服務(wù)器,現(xiàn)記錄下nginx安裝配置過程。

一、下載安裝解壓

1.進(jìn)入臨時文件夾里(隨便一個都行)

cd /tmp/

2.下載并安裝nginx壓縮包

wget http://nginx.org/download/nginx-1.23.3.tar.gz

3.解壓該壓縮包

tar -xvf nginx-1.23.3.tar.gz

4.創(chuàng)建目標(biāo)文件夾

cd /tmp/nginx-1.23.3

5.(默認(rèn)會安裝在/usr/local/nginx)這里通過configure命令指定安裝目錄

./configure --prefix=/data/nginx

6.編譯安裝

make && make install

7.最后生成的文件夾具體如下

二、SSL模塊安裝(SSL證書)用于htpps請求  沒此需求可略過

./configure --prefix=/data/nginx --with-http_ssl_module

三、運(yùn)行

1.進(jìn)入nginx下的sbin目錄

cd /data/nginx/sbin

2.執(zhí)行啟動

./nginx

3.查看nginx是否啟動

ps -ef | grep nginx

 

4.瀏覽器訪問你的IP(如下就是成功了)

四、卸載

1.查看nginx是否運(yùn)行

ps aux | grep nginx

2.進(jìn)入nginx下的sbin目錄

cd /data/nginx/sbin

3.停止nginx運(yùn)行

./nginx -s stop

4.查看與Nginx有關(guān)的文件夾

find / -name nginx

5.刪除與Nginx有關(guān)的文件

rm -rf file /data/nginx*

6.再查看

find / -name nginx*

7.卸載Nginx的依賴

yum remove nginx

五、Nginx的基本操作命令

1.進(jìn)入nginx下的sbin目錄

cd /data/nginx/sbin

2.啟動

./nginx

3.關(guān)閉 

./nginx -s stop

4.重啟 

./nginx -s reload

六、配置成系統(tǒng)服務(wù)

1.創(chuàng)建nginx.service文件

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

2.nginx.service文件中寫入內(nèi)容

[Unit]
Description=nginx web service
Documentation=http://nginx.org/en/docs/
After=network.target
 
[Service]
Type=forking
PIDFile=/data/nginx/logs/nginx.pid
ExecStartPre=/data/nginx/sbin/nginx -t -c /data/nginx/conf/nginx.conf
ExecStart=/data/nginx/sbin/nginx
ExecReload=/data/nginx/sbin/nginx -s reload
ExecStop=/data/nginx/sbin/nginx -s stop
PrivateTmp=true
 
[Install]
WantedBy=default.target

3.改權(quán)限

chmod 755 /usr/lib/systemd/system/nginx.service

4.文件生效  

systemctl daemon-reload

5.設(shè)置開機(jī)自啟 

systemctl enable nginx.service 

七、系統(tǒng)服務(wù)操作Nginx基本命令

1.啟動

systemctl start nginx

2.停止

systemctl stop nginx

3.重啟

systemctl restart nginx

4.重新加載配置文件

systemctl reload nginx

5. 查看Nginx狀態(tài)

systemctl status nginx

6.開機(jī)自動

systemctl enable nginx

八、nginx.conf文件基本配置詳解

 
#user  nobody;
#進(jìn)程的數(shù)量
worker_processes  1;
#錯誤日志:存放路徑
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#進(jìn)程標(biāo)識符
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
#設(shè)定http服務(wù)器,利用它的反向代理功能提供負(fù)載均衡支持
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
 
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #超時時間
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
    #配置虛擬機(jī)
    server {
        listen       8585;#監(jiān)聽端口
        server_name  localhost;#主機(jī)ip
        #請求轉(zhuǎn)發(fā)
        location / {
            proxy_pass http://localhost:8001;
        }
        
        location /app{
			try_files $uri $uri/ /app/index.html;
		}
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html;
            index  index.html index.htm;
        }
 
        #error_page  404              /404.html;
 
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
 
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
 
 
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
 
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
 
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
 
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
 
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
 
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
 
}

總結(jié)

以上為個人經(jīng)驗(yàn),希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • nginx?負(fù)載均衡輪詢方式配置詳解

    nginx?負(fù)載均衡輪詢方式配置詳解

    負(fù)載均衡(load-balance)就是將負(fù)載分?jǐn)偟蕉鄠€操作單元上執(zhí)行,從而提高服務(wù)的可用性和響應(yīng)速度,帶給用戶更好的體驗(yàn),本文給大家介紹nginx?負(fù)載均衡輪詢方式配置,感興趣的朋友一起看看吧
    2022-03-03
  • nginx搭建文件服務(wù)器的詳細(xì)過程

    nginx搭建文件服務(wù)器的詳細(xì)過程

    這篇文章主要介紹了nginx搭建文件服務(wù)器,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-06-06
  • nginx代理文件目錄、下載站點(diǎn)方式

    nginx代理文件目錄、下載站點(diǎn)方式

    這篇文章主要介紹了nginx代理文件目錄、下載站點(diǎn)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2025-03-03
  • 為Nginx添加SPDY功能

    為Nginx添加SPDY功能

    我也開始嘗試著給自己的論壇加上SPDY協(xié)議,WEB服務(wù)器本人選擇的是nginx,在過去,Nginx并沒有內(nèi)置SPDY協(xié)議,需要打開的話還要下載開發(fā)版然后手動編譯,很不方便
    2014-12-12
  • Nginx配置為HTTPS的完整步驟(支持?SSL/TLS?加密)

    Nginx配置為HTTPS的完整步驟(支持?SSL/TLS?加密)

    Nginx是一個高性能的HTTP和反向代理web服務(wù)器,是運(yùn)維中十分常用的中間件,HTTPS協(xié)議簡單來說就是HTTP協(xié)議和SSL/TLS協(xié)議的組合,這篇文章主要介紹了Nginx配置為HTTPS(支持?SSL/TLS?加密)的相關(guān)資料,需要的朋友可以參考下
    2025-11-11
  • 瀏覽器控制臺報錯Failed to load module script:解決方法

    瀏覽器控制臺報錯Failed to load module script:解決方

    這篇文章主要為大家介紹了瀏覽器控制臺報錯Failed to load module script:解決方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-11-11
  • Nginx重定向后請求參數(shù)丟失的原因分析及解決方案

    Nginx重定向后請求參數(shù)丟失的原因分析及解決方案

    在日常開發(fā)和運(yùn)維中,我們經(jīng)常會遇到需要使用 Nginx 進(jìn)行反向代理的場景,但在配置 proxy_pass 時,有時候可能會遇到請求參數(shù)丟失的問題,在這篇文章中,我們將會詳細(xì)探討這個問題并給出幾種解決方案,需要的朋友可以參考下
    2023-11-11
  • Nginx?location和proxy_pass配置示例詳解

    Nginx?location和proxy_pass配置示例詳解

    這篇文章主要介紹了Nginx?location和proxy_pass配置的相關(guān)資料,本文詳細(xì)探討了Nginx配置中`location`和`proxy_pass`指令的不同組合方式及其對請求轉(zhuǎn)發(fā)路徑的影響,通過列舉多種組合,展示了`location`匹配目錄與`proxy_pass`地址路徑如何相互作用,需要的朋友可以參考下
    2024-11-11
  • 詳解Nginx 虛擬主機(jī)配置的三種方式(基于IP)

    詳解Nginx 虛擬主機(jī)配置的三種方式(基于IP)

    Nginx配置虛擬主機(jī)支持3種方式主要有基于IP的虛擬主機(jī)配置,基于端口的虛擬主機(jī)配置,基于域名的虛擬主機(jī)配置。本文主要介紹了基于IP配置的實(shí)現(xiàn),感興趣的小伙伴們可以參考一下
    2018-10-10
  • 使用Nginx為自己的網(wǎng)站資源加上防盜鏈保護(hù)實(shí)現(xiàn)

    使用Nginx為自己的網(wǎng)站資源加上防盜鏈保護(hù)實(shí)現(xiàn)

    這篇文章主要為大家介紹了使用Nginx為自己的網(wǎng)站資源加上防盜鏈保護(hù)實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-08-08

最新評論

洪江市| 遂川县| 祁门县| 庄浪县| 高州市| 理塘县| 宝鸡市| 大新县| 于田县| 紫阳县| 乌拉特前旗| 青川县| 尼勒克县| 寻乌县| 徐闻县| 塔河县| 鄂托克前旗| 陆河县| 保靖县| 体育| 安国市| 彰化市| 虎林市| 灌云县| 海兴县| 余庆县| 石渠县| 花莲县| 榆树市| 辛集市| 广安市| 合肥市| 来安县| 高平市| 三门县| 宝鸡市| 永清县| 凉城县| 长乐市| 阳谷县| 肃宁县|