版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、简介Nginx(发音同 engine x)是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:)使用。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:新浪、网易、 腾讯等。官网:/cn/一、 yum配置1. 将光盘内容拷贝到/mnt/redhat5.5目录下 rootlocalhost redhat5.5# cp
2、 -fr /media/RHEL_5.5 x86_64 DVD/* /mnt/redhat5.5 #把光盘未见拷贝至root根目录下的mnt文件下的redhat5.5中2. 检查是否安装createrepo(linux下的创建仓库的软件包)rootlocalhost redhat5.5# rpm -qa |grep createrepo #如果装了显示版本号;未装则结果为空 1)安装createreporootlocalhost redhat5.5# cd Server/rootlocalhost Server# pwd/mnt/redhat5.5/Serverrootlocalhost Se
3、rver# rpm -ivh ./createrepo-0.4.11-3.el5.noarch.rpmwarning: ./createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186Preparing. # 100% 1:createrepo # 100%rootlocalhost Server#检查安装结果rootlocalhost Server# rpm -qa |grep createrepocreaterepo-0.4.11-3.el53. 创建YUM仓库rootlocalhos
4、t Server# createrepo -g /mnt/redhat5.5/Server/repodata/comps-rhel5-server-core.xml /mnt/redhat5.5/Serverrootlocalhost Server# createrepo -g /mnt/redhat5.5/VT/repodata/comps-rhel5-vt.xml /mnt/redhat5.5/VT/rootlocalhost Server# createrepo -g /mnt/redhat5.5/Cluster/repodata/comps-rhel5-cluster.xml /mnt
5、/redhat5.5/Cluster/rootlocalhost Server#createrepo -g /mnt/redhat5.5/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /mnt/redhat5.5/ClusterStorage/4. 创建本地yum客户端的repo文件rootlocalhost yum.repos.d# cd /etc/yum.repos.d/ rootlocalhost yum.repos.d# vi local.repo内容如下:localname=hntlbaseurl=file:/mnt/redha
6、t5.5/Servergpgcheck=0enabled=1VTname=VTbaseurl=file:/mnt/redhat5.5/VTgpgcheck=0Clustername= Clusterbaseurl=file:/mnt/redhat5.5/Clustergpgcheck=0CSname= ClusterStoragebaseurl=file:/mnt/redhat5.5/ClusterStoragegpgcheck=05. Yum 安装验证rootlocalhost yum.repos.d# yum install samba以下命令自己学习1.使用YUM查找软件包命令:yum
7、search 2.列出所有可安装的软件包命令:yum list3.列出所有可更新的软件包命令:yum list updates4.列出所有已安装的软件包命令:yum list installed5.列出所有已安装但不在 Yum Repository 內的软件包命令:yum list extras6.列出所指定的软件包命令:yum list 7.使用YUM获取软件包信息命令:yum info 8.列出所有软件包的信息命令:yum info9.列出所有可更新的软件包信息命令:yum info updates10.列出所有已安裝的软件包信息命令:yum info installed11.列出所有已安
8、裝但不在 Yum Repository 內的软件包信息命令:yum info extras12.列出软件包提供哪些文件命令:yum provides 六、清除YUM缓存yum会把下载的软件包和header存储在cache中,而不会自动删除。如果我们觉得它们占用了磁盘空间,可以使用yum clean指令进行清除,更精确的用法是yum clean headers清除header,yum clean packages清除下载的rpm包,yum clean all一股脑儿端1.清除缓存目录(/var/cache/yum)下的软件包命令:yum clean packages2.清除缓存目录(/var/c
9、ache/yum)下的 headers命令:yum clean headers3.清除缓存目录(/var/cache/yum)下旧的 headers命令:yum clean oldheaders4.清除缓存目录(/var/cache/yum)下的软件包及旧的headers命令:yum clean, yum clean all (= yum clean packages; yum clean oldheaders)二、 nginx 安装nginx安装依赖pcre、zlib两个包,安装包的版本为:nginx-1.2.8(统一安装最新版本的nginx即1.4.3版本)、pcre-8.30、zlib-
10、1.2.7下载地址分别为:/en/download.htmlftp:/ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 1. 选定源码目录可以是任何目录,本文选定的是/usr/local/src,将上述安装包上传至/usr/local/src文件夹下。rootlocalhost src# cd /usr/local/srcrootlocalhost src# pwd/usr/local/src2. 安装PCRE库使用下面命令下载编译和安装 PCRE 包:rootlocalhost src# tar -zxvf pcr
11、e-8.30.tar.gzpcre-8.30/pcre-8.30/doc/pcre-8.30/doc/html/pcre-8.30/doc/html/pcre16.htmlpcre-8.30/doc/html/pcre_assign_jit_stack.htmlpcre-8.30/doc/html/pcre.htmlpcre-8.30/doc/html/pcreperform.htmlpcre-8.30/doc/html/pcrepartial.htmlpcre-8.30/doc/html/pcreunicode.html.rootlocalhost src# cd pcre-8.30root
12、localhost pcre-8.30# ./configurerootlocalhost pcre-8.30# makerootlocalhost pcre-8.30# make install输出结果的后几行如下,注意输出过程是否报错.make3: Leaving directory /usr/local/src/pcre-8.30'make2: Leaving directory /usr/local/src/pcre-8.30'make1: Leaving directory /usr/local/src/pcre-8.30'3. 安装zlib库使用下面命令下载
13、编译和安装 zlib包:rootlocalhost src# cd /usr/local/srcrootlocalhost src# tar -zxvf zlib-1.2.7.tar.gzrootlocalhost src# cd zlib-1.2.7rootlocalhost zlib-1.2.7# ./configurerootlocalhost zlib-1.2.7# pwd/usr/local/src/zlib-1.2.7rootlocalhost zlib-1.2.7# ./configurerootlocalhost zlib-1.2.7# makerootlocalhost zl
14、ib-1.2.7# make install输出结果的后几行如下,注意输出过程是否报错.chmod 644 /usr/local/share/man/man3/zlib.3cp zlib.pc /usr/local/lib/pkgconfigchmod 644 /usr/local/lib/pkgconfig/zlib.pccp zlib.h zconf.h /usr/local/includechmod 644 /usr/local/include/zlib.h /usr/local/include/zconf.h4. 安装ssl(某些vps默认没装ssl,需要手动安装,或者按照下面附录1.
15、2的方法)Openssl openssl-develrootlocalhost nginx-1.2.8# yum -y install openssl openssl-devel5. 安装nginxNginx 一般有两个版本,分别是稳定版和开发版,可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:rootlocalhost src# tar -zxvf nginx-1.2.8.tar.gzrootlocalhost src# cd nginx-1.2.8rootlocalhost nginx-1.2.8# ./conf
16、igure -sbin-path=/usr/local/nginx/nginx -conf-path=/usr/local/nginx/nginx.conf -pid-path=/usr/local/nginx/nginx.pid -with-http_ssl_module -with-pcre=/usr/local/src/pcre-8.30 -with-zlib=/usr/local/src/zlib-1.2.7运行结果最后几行如下,注意过程是否报错.Configuration summary + using PCRE library: /usr/local/src/pcre-8.30 +
17、 using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using zlib library: /usr/local/src/zlib-1.2.7 nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/nginx" nginx configuration prefix: "/usr/local/nginx" ngin
18、x configuration file: "/usr/local/nginx/nginx.conf" nginx pid file: "/usr/local/nginx/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary fil
19、es: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"rootlocalhost nginx-1.2.8# make objs/s
20、rc/http/modules/ngx_http_upstream_least_conn_module.o objs/src/http/modules/ngx_http_upstream_keepalive_module.o objs/ngx_modules.o -lpthread -lcrypt /usr/local/src/pcre-8.30/.libs/libpcre.a -lssl -lcrypto -ldl /usr/local/src/zlib-1.2.7/libz.amake1: Leaving directory /usr/local/src/nginx-1.2.8'm
21、ake -f objs/Makefile manpagemake1: Entering directory /usr/local/src/nginx-1.2.8'sed -e "s|%PREFIX%|/usr/local/nginx|" -e "s|%PID_PATH%|/usr/local/nginx/nginx.pid|" -e "s|%CONF_PATH%|/usr/local/nginx/nginx.conf|" -e "s|%ERROR_LOG_PATH%|/usr/local/nginx/logs/err
22、or.log|" < man/nginx.8 > objs/nginx.8make1: Leaving directory /usr/local/src/nginx-1.2.8'rootlocalhost nginx# make install6. 服务启停启动 rootlocalhost nginx# cd /usr/local/nginx/ rootlocalhost nginx#./nginx 停止 rootlocalhost nginx# cd /usr/local/nginx/rootlocalhost nginx#./nginx -s stop 重新启
23、动 rootlocalhost nginx# cd /usr/local/nginx/rootlocalhost nginx#./nginx s reload 查看状态rootlocalhost nginx# ps -ef|grep nginxroot 7425 1 0 13:38 ? 00:00:00 nginx: master process ./nginxnobody 7460 7425 0 13:42 ? 00:00:00 nginx: worker processnobody 7461 7425 0 13:42 ? 00:00:00 nginx: worker processnobo
24、dy 7462 7425 0 13:42 ? 00:00:00 nginx: worker processnobody 7463 7425 0 13:42 ? 00:00:00 nginx: worker processroot 7465 4683 0 13:42 pts/1 00:00:00 grep nginx7. 安装成功验证默认端口为80,在IE中输入服务IP地址,页面显示如下图,表明安装成功8. Nginx配置(修改nginx.conf中的 配置如下,然后上传至/usr/local/nginx目录下即可)user root;worker_processes 10;#error_log
25、 logs/error.log;error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;worker_rlimit_nofile 65535;events worker_connections 65535;http include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user $time_local "$request&q
26、uot; ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"' #access_log logs/access.log main; sendfile on; server_names_hash_bucket_size 128; server_tokens off; client_header_buffer_size 32k; large_client_heade
27、r_buffers 4 32k; client_max_body_size 16m; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_
28、intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; server listen 80; server_name 31; default_type 'text/html' charset utf-8; #acces
29、s_log logs/host.access.log main; location / root /weblogic/apps/cms; index /publish/html/main/index.html; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size
30、 64k; proxy_temp_file_write_size 64k; location /.*.(jsp|do) proxy_pass 31:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k
31、; proxy_temp_file_write_size 64k; proxy_max_temp_file_size 512m; location /(WEB-INF)/ deny all; #error_page 404 # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /404.html; location = /404.html root html; # proxy the PHP scripts to Apache listening on :
32、80 # #location .php$ # proxy_pass ; # # pass the PHP scripts to FastCGI server listening on :9000 # #location .php$ # root html; # fastcgi_pass :9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #
33、 # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # # 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; # inde
34、x index.html index.htm; # # # HTTPS server # #server # listen 443; # server_name localhost; # ssl on; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location /
35、# root html; # index index.html index.htm; # # 检查配置结果有无错误rootlocalhost nginx# cd /usr/local/nginx/rootlocalhost nginx# ./nginx -t -c ./nginx.confnginx: the configuration file /usr/local/nginx/./nginx.conf syntax is oknginx: configuration file /usr/local/nginx/./nginx.conf test is successful 重新启动 roo
36、tlocalhost nginx# cd /usr/local/nginx/rootlocalhost nginx#./nginx s reload测试配置结果:http:/ 30/(如果发生页面乱码的情况,先清除浏览器的缓存,再重新访问)正常显示结果为网站首页地址测试集成结果:30/test_license_info.jsp显示结果为license信息9. 升级查看服务状态及进程rootlocalhost local# ps -ef|grep nginxroot 7425 1 0 13:38 ? 00:00:00 nginx: ma
37、ster process ./nginxroot 8083 7425 0 14:47 ? 00:00:00 nginx: worker processroot 8084 7425 0 14:47 ? 00:00:00 nginx: worker processroot 8085 7425 0 14:47 ? 00:00:00 nginx: worker processroot 8086 7425 0 14:47 ? 00:00:00 nginx: worker processroot 8512 4683 0 15:36 pts/1 00:00:00 grep nginx查看原始版本rootlo
38、calhost local# nginx/nginx -Vnginx version: nginx/1.2.8built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)TLS SNI support disabledconfigure arguments: -sbin-path=/usr/local/nginx/nginx -conf-path=/usr/local/nginx/nginx.conf -pid-path=/usr/local/nginx/nginx.pid -with-http_ssl_module -with-pcre=/usr/local/
39、src/pcre-8.30 -with-zlib=/usr/local/src/zlib-1.2.7上传新版本至/usr/local目录,解压编译rootlocalhost local# tar -zxvf nginx-1.4.3.tar.gzrootlocalhost local# cd nginx-1.4.3rootlocalhost nginx-1.4.3# ./configure -sbin-path=/usr/local/nginx/nginx -conf-path=/usr/local/nginx/nginx.conf -pid-path=/usr/local/nginx/ngin
40、x.pid -with-http_ssl_module -with-pcre=/usr/local/src/pcre-8.30 -with-zlib=/usr/local/src/zlib-1.2.7Configuration summary + using PCRE library: /usr/local/src/pcre-8.30 + using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using zlib library: /usr/local/src/zlib
41、-1.2.7 nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/nginx" nginx configuration prefix: "/usr/local/nginx" nginx configuration file: "/usr/local/nginx/nginx.conf" nginx pid file: "/usr/local/nginx/nginx.pid" nginx error l
42、og file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: &quo
43、t;fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"rootlocalhost nginx-1.4.3# make.objs/ngx_modules.o -lpthread -lcrypt /usr/local/src/pcre-8.30/.libs/libpcre.a -lssl -lcrypto -ldl /usr/local/src/zlib-1.2.7/libz.amake1:
44、 Leaving directory /usr/local/nginx-1.4.3'make -f objs/Makefile manpagemake1: Entering directory /usr/local/nginx-1.4.3'sed -e "s|%PREFIX%|/usr/local/nginx|" -e "s|%PID_PATH%|/usr/local/nginx/nginx.pid|" -e "s|%CONF_PATH%|/usr/local/nginx/nginx.conf|" -e "s
45、|%ERROR_LOG_PATH%|/usr/local/nginx/logs/error.log|" < man/nginx.8 > objs/nginx.8make1: Leaving directory /usr/local/nginx-1.4.3'注意:此时一定不要make installrootlocalhost nginx-1.4.3# mv /usr/local/nginx/nginx /usr/local/nginx/nginx1103rootlocalhost nginx-1.4.3# cp objs/nginx /usr/local/nginx/nginxrootlocalhost nginx-1.4.3# cd ./nginx回原目录执行升级rootlocalhost nginx# cd /usr/local/nginx-1.4.3rootlocalhost nginx-1.4.3# make up
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026江苏南京大学现代工程与应用科学学院博士后招聘1人备考题库及答案详解(夺冠系列)
- 2026安徽皖信人力资源管理有限公司招聘外委电力系统施工员3人备考题库有答案详解
- 2026中化明达西南地质有限公司(中化地质矿山总局贵州地质勘查院)招聘10人备考题库及参考答案详解
- 2026广东佛山市高明国盈市政工程建设有限公司第一期招聘3人备考题库附答案详解(考试直接用)
- 2026江苏省交通技师学院招聘高层次人才4人备考题库附答案详解(a卷)
- 2026中国联通苍南县分公司招聘3人备考题库(浙江)附答案详解(满分必刷)
- 2026北京航标时代检测认证有限公司浙江分公司非事业编制人员招聘3人备考题库(浙江)含答案详解(研优卷)
- 2026中国标准化研究院人力资源部人力资源管理岗企业编制职工招聘1人备考题库含答案详解
- 2026中铁华铁工程设计集团有限公司区域指挥部招聘备考题库附答案详解(b卷)
- 2026宁夏回族自治区残疾人康复中心(宁夏康复医院)自主招聘事业单位人员3人备考题库及完整答案详解1套
- 皮肤外科进修汇报
- 公司厂房租赁管理制度
- 防汛应急服务合同范本
- T/CTRA 01-2020废轮胎/橡胶再生油
- 科技助农:农业新篇章
- 思考快与慢课件
- 学前特殊儿童语言教育
- 学校防投掷爆炸物预案
- 幼教培训课件:《幼儿园区域活动与幼儿成长》
- 高等数学(上下册全套)全套教学课件
- 混凝土预制块护坡施工方案
评论
0/150
提交评论