linux-nginx

匿名 (未验证) 提交于 2019-12-02 21:56:30
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

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!