Nginx在centoslinux安装、部署完整步骤并测试通过
发布时间:2022-11-11 23:07:49阅读:100次来源:HarmonyOS下载网 系统大全为您提供需要先装pcre,zlib,前者为了重写rewrite,后者为了gzip压缩。1.选定源码目录选定目录/usr/local/cd/usr/local/2.安装PCRE库cd/usr/local/wgethttp://exifr/pcre/pcre-8.02.tar.gztar-zxvfpcre-8.02.tar.gzcdpcre-8.02./configure&&make&&makeinstall3.安装zlib库cd/usr/local/wgethttp://zlib-1.2.8.tar.gztar-zxvfzlib-1.2.8.tar.gzcdzlib-1.2.8./configuremakemakeinstall4.安装sslcd/usr/local/wgethttp://org/source/openssl-1.0.1c.tar.gztar-zxvfopenssl-1.0.1c.tar.gz./configmakemakeinstall5.安装nginxNginx一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把Nginx安装到/usr/localinx目录下的详细步骤:cd/usr/local/wgethttp://g/download/nginx-1.2.8.tar.gztar-zxvfnginx-1.2.8.tar.gzcdnginx-1.2.8./configure--prefix=/usr/localinxmakemakeinstall--with-pcre=/usrc/pcre-8.21指的是pcre-8.21的源码路径。--with-zlib=/usrc/zlib-1.2.7指的是zlib-1.2.7的源码路径。6.启动确保系统的80端口没被其他程序占用,/usr/localinx/sbininx检查是否启动成功:netstat-ano|grep80有结果输入说明启动成功打开浏览器访问此机器的IP,如果浏览器出现Welcometonginx!则表示Nginx已经安装并运行成功。7.重启/usr/localinx/sbininx–sreload8.修改配置文件cd/usr/localinx/confvinginx.conf9.常用配置#nginx运行用户和组userwwwwww;#启动进程,通常设置成和cpu的数量相等worker_processes4;#全局错误日志及PID文件pidar/runinx.pid;error_logar/loginx/error.log;events{#epoll是多路复用IO(I/OMultiplexing)中的一种方式,但是仅用于linux2.6以上内核,可以大大提高nginx的性能useepoll;#单个后台workerprocess进程的最大并发链接数worker_connections10240;}#设定http服务器,利用它的反向代理功能提供负载均衡支持http{includemime.types;default_typeapplication/octet-stream;error_page400403500502503504/50x.html;indexindex.htmlindex.shtmlautoindexoff;fastcgi_intercept_errorson;sendfileon;#Thesearegooddefaultvalues.tcp_nopushon;tcp_nodelayoff;#outputcompressionsavesbandwidthgzipoff;#gzip_staticon;#gzip_min_length1k;gzip_http_version1.0;gzip_comp_level2;gzip_buffers416k;gzip_proxiedany;gzip_disable"MSIE[1-6].";gzip_typestext/plaintextmltext/cssapplication/x-Javascriptapplication/xmlapplication/xml+rsstext/Javascript;#gzip_varyon;server_name_in_redirectoff;#设定负载均衡的服务器列表upstreamportals{server172.16.68.134:8082max_fails=2fail_timeout=30s;server172.16.68.135:8082max_fails=2fail_timeout=30s;server172.16.68.136:8082max_fails=2fail_timeout=30s;server172.16.68.137:8082max_fails=2fail_timeout=30s;}#upstreamoverflow{#server10.248.6.34:8090max_fails=2fail_timeout=30s;#server10.248.6.45:8080max_fails=2fail_timeout=30s;#}server{#侦听8080端口listen8080;server_name127.0.0.1;#403、404页面重定向地址error_page403=http:///www.win7cn.comerror_page404=http://www.win7cn.comproxy_connect_timeout90;proxy_send_timeout180;proxy_read_timeout180;proxy_buffer_size64k;proxy_buffers4128k;proxy_busy_buffers_size128k;client_header_buffer_size16k;large_client_header_buffers464k;#proxy_send_timeout3m;#proxy_read_timeout3m;#proxy_buffer_size4k;#proxy_buffers432k;proxy_set_headerHost$http_host;proxy_max_temp_file_size0;#proxy_hide_headerSet-Cookie;#if($host!='www.e100.cn'){#rewrite^/(.*)$http://www.win7cn.com/$1permanent;#}location/{denyall;}location~^/resource/res/imgue/space.gif{proxy_passhttp://tecopera;}location=/{rewrite^(.*)$/ebiz/event/517.htmllast;}location=/ebiz/event/517.html{add_headerVaryAccept-Encoding;root/data/webml;expires10m;}location=eck.html{root/usr/localinxml/;access_logoff;}location=/50x.html{root/usr/localinxml/;expires1m;access_logoff;}location=/index.html{add_headerVaryAccept-Encoding;#定义服务器的默认网站根目录位置root/data/webml/ebiz;expires10m;}#定义反向代理访问名称location~^/ecps-portal/*{#expires10m;#重定向集群名称proxy_passhttp://portals;#proxy_passhttp://}location~^/fetionLogin/*{#expires10m;proxy_passhttp://portals;#proxy_passhttp://}#location~^siness/*{##expires10m; #proxy_passhttp:##proxy_passhttp:#}location~^/rsmanager/*{expires10m;root/data/web/;#proxy_passhttp://rsm;}#定义nginx处理的页面后缀location~*(.*).(jpg|gif|htm|html|png|js|css)${root/data/webml/;#页面缓存时间为10分钟expires10m;}#设定查看Nginx状态的地址location~*^/NginxStatus/{stub_statuson;access_logoff;allow10.1.252.126;allow10.248.6.49;allow127.0.0.1;denyall;}#error_page405=200@405;#location@405#{#proxy_pass#}access_log/data/logsinx/access.logcombined;error_log/data/logsinx/error.log;}server{listen8082;server_name_;location=eck.html{root/usr/localinxml/;access_logoff;}}server{listen8088;server_name_;location~^/*{root/data/web/b2bhtml/;access_logoff;}}server{listen9082;server_name_;#location~^/resource/*{#expires10m;#root/data/webml/;#}location/{root/data/webml/sysMaintain/;if(!-f$request_filename){rewrite^/(.*)$/sysMaintain.htmllast;}}}} 以上就是系统大全给大家介绍的如何使的方法都有一定的了解了吧,好了,如果大家还想了解更多的资讯,那就赶紧点击系统大全官网吧。本文来自系统大全http://www.win7cn.com/如需转载请注明!推荐:win7纯净版