亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

前言

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

一、下載安裝解壓

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

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)建目標文件夾

cd /tmp/nginx-1.23.3

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

./configure --prefix=/data/nginx

6.編譯安裝

make && make install

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

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

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

三、運行

1.進入nginx下的sbin目錄

cd /data/nginx/sbin

2.執(zhí)行啟動

./nginx

3.查看nginx是否啟動

ps -ef | grep nginx

 

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

四、卸載

1.查看nginx是否運行

ps aux | grep nginx

2.進入nginx下的sbin目錄

cd /data/nginx/sbin

3.停止nginx運行

./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.進入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è)置開機自啟 

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.開機自動

systemctl enable nginx

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

 
#user  nobody;
#進程的數(shù)量
worker_processes  1;
#錯誤日志:存放路徑
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#進程標識符
#pid        logs/nginx.pid;
 
 
events {
    worker_connections  1024;
}
 
#設(shè)定http服務(wù)器,利用它的反向代理功能提供負載均衡支持
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;
 
    #配置虛擬機
    server {
        listen       8585;#監(jiān)聽端口
        server_name  localhost;#主機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)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • nginx反向代理下的長連接實現(xiàn)

    nginx反向代理下的長連接實現(xiàn)

    本文主要介紹了Nginx反向代理下的長連接實現(xiàn),包括客戶端到Nginx和Nginx到后端服務(wù)器之間的長連接設(shè)置,具有一定的參考價值,感興趣的可以了解一下
    2024-11-11
  • 在Nginx服務(wù)器中配置針對TCP的負載均衡的方法

    在Nginx服務(wù)器中配置針對TCP的負載均衡的方法

    這篇文章主要介紹了在Nginx服務(wù)器中配置針對TCP的負載均衡的方法,另外還介紹了TCP負載均衡的執(zhí)行原理,需要的朋友可以參考下
    2015-12-12
  • nginx使用sticky基于cookie的會話保持方式

    nginx使用sticky基于cookie的會話保持方式

    這篇文章主要介紹了nginx使用sticky基于cookie的會話保持方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • Nginx啟動顯示80端口占用問題的解決方案

    Nginx啟動顯示80端口占用問題的解決方案

    這篇文章主要介紹了Nginx啟動顯示80端口占用問題的解決方案,文中通過代碼示例和圖文講解的非常詳細,對大家解決問題有一定的幫助,需要的朋友可以參考下
    2024-04-04
  • nginx中的proxy_set_header參數(shù)指令詳解

    nginx中的proxy_set_header參數(shù)指令詳解

    本文介紹了Nginx中的proxy_set_header指令,用于自定義代理請求的HTTP頭部信息,實現(xiàn)更靈活的反向代理功能,提供了實際應用場景和配置示例,幫助讀者更好地理解和使用proxy_set_header指令,感興趣的朋友一起看看吧
    2025-03-03
  • nginx訪問返回504問題及解決

    nginx訪問返回504問題及解決

    這篇文章主要介紹了nginx訪問返回504問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • Nginx可視化管理工具結(jié)合cpolar實現(xiàn)遠程訪問的步驟詳解

    Nginx可視化管理工具結(jié)合cpolar實現(xiàn)遠程訪問的步驟詳解

    Nginx Proxy Manager 是一個開源的反向代理工具,本文將給大家介紹在Linux 安裝Nginx Proxy Manager并且結(jié)合 cpolar內(nèi)網(wǎng)穿透工具實現(xiàn)遠程訪問管理界面,同等,當我們使用Nginx Proxy Manager配置其他本地服務(wù),并且需要遠程訪問,也是同樣的方式,需要的朋友可以參考下
    2023-09-09
  • Nginx緩存設(shè)置案例詳解

    Nginx緩存設(shè)置案例詳解

    這篇文章主要介紹了Nginx緩存設(shè)置案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • Nginx中使用gzip_http_version解決CDN只支持http 1.0問題

    Nginx中使用gzip_http_version解決CDN只支持http 1.0問題

    這篇文章主要介紹了Nginx中使用gzip_http_version解決CDN只支持http 1.0問題,問題原因是在Header信息中看到Transfer-Encoding: chunked,使用本文方法就可以解決這個問題,需要的朋友可以參考下
    2014-09-09
  • Nginx如何安裝withSSL模塊

    Nginx如何安裝withSSL模塊

    這篇文章主要介紹了Nginx如何安裝withSSL模塊,Nginx 配置文件,開啟ssl訪問時經(jīng)常報錯,原因是由于nginx缺少http_ssl_module模塊,編譯安裝的時候帶上 --with-http_ssl_module 配置就行了,感興趣的朋友跟隨小編一起看看吧
    2024-04-04

最新評論