日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx网站服务器

發(fā)布時(shí)間:2024/9/30 Nginx 126 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx网站服务器 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

    • Nginx網(wǎng)站服務(wù)器
      • Nginx安裝
      • Nginx啟動(dòng)與停止
        • 啟動(dòng)nginx
        • 關(guān)閉nginx
        • 重啟nginx
      • Nginx配置文件

Nginx網(wǎng)站服務(wù)器

Nginx安裝

Nginx Web服務(wù)器軟件安裝完成后,程序主目錄位于/usr/local/nginx/,該目錄下的內(nèi)容分別為

目錄作用
conf主配置文件目錄
html網(wǎng)站根目錄
logs日志文件目錄
sbin主程序目錄

Nginx啟動(dòng)與停止

進(jìn)入sbin目錄下(以下操作,如無特殊說明,均在sbin目錄下操作)

啟動(dòng)nginx

./nginx :啟動(dòng)nginx,這種方式nginx會(huì)自動(dòng)讀取conf目錄下的nginx.conf的配置文件

./nginx -c 指定配置文件:用指定的配置文件啟動(dòng)nginx

./nginx -s reopen :重新打開日志文件

[root@localhost sbin]# ./nginx [root@localhost sbin]# ps -aux |grep nginx root 831 0.0 0.0 25516 1352 ? Ss 14:50 0:00 nginx: master process ./nginx nobody 832 0.0 0.0 28032 2124 ? S 14:50 0:00 nginx: worker process root 834 0.0 0.0 112660 976 pts/2 S+ 14:51 0:00 grep --color=auto nginx

一個(gè)主進(jìn)程

關(guān)閉nginx

./nginx -s stop :快速停止nginx

./nginx -s quit :完整有序的停止nginx

其他停止nginx方式:

1.通過信號(hào)量強(qiáng)行關(guān)閉

[root@localhost nginx]# ps -aux | grep nginx root 831 0.0 0.0 25516 1352 ? Ss 14:50 0:00 nginx: master process ./nginx nobody 832 0.0 0.0 28032 2368 ? S 14:50 0:00 nginx: worker process root 954 0.0 0.0 112660 976 pts/2 S+ 14:59 0:00 grep --color=auto nginx [root@localhost nginx]# kill -INT 831 [root@localhost nginx]# ps -aux | grep nginx root 964 0.0 0.0 112660 972 pts/2 S+ 15:00 0:00 grep --color=auto nginx

2.改變配置文件,平滑重讀配置文件

[root@localhost nginx]# ps -aux|grep nginx root 985 0.0 0.0 25516 1984 ? Ss 15:01 0:00 nginx: master process ./sbin/nginx nobody 1864 0.0 0.0 27600 2060 ? S 15:49 0:00 nginx: worker process root 2005 0.0 0.0 112664 976 pts/2 S+ 15:52 0:00 grep --color=auto nginx [root@localhost nginx]# kill -HUP 985

重啟nginx

./nginx -s reload : 重啟,一般修改配置后重新加載生效

Nginx配置文件

Nginx默認(rèn)配置文件為/usr/local/nginx/conf/nginx.conf,配置文件主要包括全局,event,http,server設(shè)置。event主要用來定義Nginx工作模式;http提供web功能;server用來設(shè)置虛擬主機(jī),且server必須位于http內(nèi)部,一個(gè)配置文件中可以有多個(gè)server

... #全局塊events { #events塊... }http #http塊 {... #http全局塊server #server塊{ ... #server全局塊location [PATTERN] #location塊{...}location [PATTERN] {...}}server{...}... #http全局塊 } #user nobody; 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; }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 80;server_name localhost;#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;# }#} } //設(shè)置用戶與組,一般用#注釋掉 user nobody; //啟動(dòng)子進(jìn)程數(shù),可以通過ps aux | grep nginx 查看 worker_processes 1; //錯(cuò)誤日志文件,以及日志級(jí)別 error_log logs/error.log info; //進(jìn)程號(hào)保存的文件 pid logs/nginx.pid;//主要用來定義Nginx工作模式 events {//每個(gè)進(jìn)程可以處理的鏈接數(shù),受系統(tǒng)文件句柄的限制worker_connections 1024; }//提供web功能 http {//mime.types為文件類型定義文件include mime.types;default_type application/octet-stream;sendfile on;tcp_nopush on;keepalive_timeout 65;gzip on;//使用server定義虛擬主機(jī)server {listen 80;server_name www.baidu.com;location / {root html;index index.html index.htm;}error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}//消費(fèi)者查詢系統(tǒng)中間件 、 全程版系統(tǒng)中間件location ~ /api/1.0/ll/(.*) {proxy_pass http://59.68.29.89:18081/api/1.0/ll/$1;proxy_set_header Host $host:80;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}}

總結(jié)

以上是生活随笔為你收集整理的Nginx网站服务器的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。