linux-nginx

来源:https://www.cnblogs.com/shy13138/archive/2019/09/12/11512853.html
-Advertisement-
Play Games

IO分為記憶體IO,網路IO,磁碟IO IO模型: 同步IO模型: 同步阻塞:一個進程對應一個IO,進程在運行時,不能去乾別的,一直等待 同步非阻塞:一個進程對應一個IO,進程運行時,可以去做別的事,等待別的程式的數 據傳輸,進程會定時詢問是否準備完成 多路訪問的IO模型--IO復用(select p... ...


IO分為記憶體IO,網路IO,磁碟IO
IO模型:
同步IO模型:
同步阻塞:一個進程對應一個IO,進程在運行時,不能去乾別的,一直等待
同步非阻塞:一個進程對應一個IO,進程運行時,可以去做別的事,等待別的程式的數
據傳輸,進程會定時詢問是否準備完成
多路訪問的IO模型--IO復用(select poll epoll)
多線程運行
這種情況適合大併發請求的情況,
非同步IO模型:
*非同步10*
進程只需要發起請求,內核准備數據,當數據準備就緒以後,會主動通知進程;
apache採用的select就是同步IO模型,而nginx採用的就是 epoll的非同步模型;所以,從這點上說,nginx要遠遠由於apache;
nginx適用環境:小文件的高併發傳輸
nginx - engine X
(Tengin:屬於淘寶公司對nginx的=次開發優化版本,更好的支持高併發,與web安全功能);
由俄羅斯I君開發的,2004年開發的,I君為elusive第二大網站開發的一個前端靜態資源解析程式
安裝nginx
安裝nginx:
		./configure 
		--prefix=/usr/local/nginx  
		--conf-path=(配置文件一定要放到程式目錄下,不要放到etc目錄下麵去)/etc/nginx/nginx.conf  
		--user=nginx 
		--group=nginx 
		--error-log-path=/var/log/nginx/error.log     // /var/log/httpd/access_log  error_log
		--http-log-path=/var/log/nginx/access.log 
		--pid-path=/var/run/nginx/nginx.pid 
		--lock-path=/var/log/nginx.log 
		--with-http_ssl_module 
		*--with-http_stub_status_module* 
		--with-http_gzip_static_module 
		--with-http_flv_module 
		--with-http_mp4_module 
		--http-client-body-temp-path=/var/tmp/nginx/client 
		--http-proxy-temp-path=/var/tmp/nginx/proxy 
		--http-fastcgi-temp-path=/var/tmp/nginx/fstacgi
		--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
nginx.conf文件解讀
#user  nobody; ##指定Nginx Worker進程運行的用戶及用戶組
worker_processes  2; ##指定了Nginx要開啟的進程數

#error_log  logs/error.log;  ##定義全局錯誤日誌文件
#error_log  logs/error.log  notice;##notice、info是輸出級別
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

##設定工作模式及連接數上限
events {
    worker_connections  1024;
}


http {
    include       mime.types; ##實現對配置文件所包含的的文件的設定,可以減少主配置文件的複雜度。
    default_type  application/octet-stream; ##設定預設類型為二進位流,
    ##指定Nginx日誌的輸出格式。
    #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;##設置開啟和關閉gzip模塊

    server { ##虛擬主機配置
        listen       80;##指定虛擬主機的服務埠
        server_name  www.whr.com; ##指定ip地址及功能變數名稱

        #charset koi8-r;##預設字元集

        #access_log  logs/host.access.log  main;##指定虛擬主機的訪問日誌存放路徑,main用於
        指定訪問日誌的輸出格式

        location / {
            root   html/zero_47_zVintauge; ##返回根路徑地址(相對路徑:相對於/usr/local/nginx/)
            index  index.html index.htm;   ##預設訪問文件
            #autoindex on;
        }
        #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
        #配置反向代理tomcat伺服器;攔截.jsp結尾的請求轉向到tomcat
        #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;
    #    }
    #}
}

設置多主機名的nginx
在http下添加一個新的server,設定新的主機名
 server {
        listen       80;
        #listen       somename:8080;
        server_name  www.welcome.com;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }
     server {
        listen       80;
        #listen       somename:8080;
        server_name  www.whr.com;

        location / {
            root   html/zero_47_zVintauge;
            index  index.html index.htm;
        }
    }

然後再主機上配置hosts文件:
10.6.29.144	www.whr

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 用於其他發行版如rhel、centos有時候要用到oracle linux的源來裝軟體比如oracle、mysql等配置oel7源wget http://public-yum.oracle.com/public-yum-ol7.repo -O /etc/yum.repos.d/public-yum-... ...
  • #include<unistd.h>int access(const char* pathname, int mode);參數介紹: pathname 是文件的路徑名+文件名 mode:指定access的作用,取值如下: F_OK 值為0,判斷文件是否存在 X_OK 值為1,判斷對文件是可執行許可權 ...
  • vi /etc/sysconfig/network-scripts/ifcfg-eth0rm -rf /etc/udev/rules.d/70-persistent-net.rules ...
  • 控制面板 –> 管理工具 –> Internet信息服務管理器打開後左側選擇相應的FTP站點右擊 –> 屬性 –> 安全帳戶允許匿名連接 前面的√取消掉,點擊確定完成 ...
  • 找到vsftpd.conf中的 保存退出 ...
  • 重置Mysql root用戶賬號密碼 By:授客 QQ:1033553122 問題描述: 使用mysqladmin.exe執行命令時出現以下錯誤提示: mysqladmin: connect to server at 'localhost' failed error: 'Access denied ...
  • 轉載自https://www.cnblogs.com/90zeng/p/Lagrange_duality.html,本人覺得講的非常好! 1.原始問題 假設是定義在上的連續可微函數(為什麼要求連續可微呢,後面再說,這裡不用多想),考慮約束最優化問題: 稱為約束最優化問題的原始問題。 現在如果不考慮約 ...
  • 1.下載MongoDB www.mongodb.com/download-center#community 2.下一步下一步安裝. 安裝完成後配置環境變數 我的的預設安裝,環境變數地址 C:\Program Files\MongoDB\Server\4.2\bin 3. 添加配置在C:\Progra ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...