Web服务器ngin虚拟主机与反向代理

上传人:人*** 文档编号:513732416 上传时间:2023-11-24 格式:DOC 页数:22 大小:77.50KB
返回 下载 相关 举报
Web服务器ngin虚拟主机与反向代理_第1页
第1页 / 共22页
Web服务器ngin虚拟主机与反向代理_第2页
第2页 / 共22页
Web服务器ngin虚拟主机与反向代理_第3页
第3页 / 共22页
Web服务器ngin虚拟主机与反向代理_第4页
第4页 / 共22页
Web服务器ngin虚拟主机与反向代理_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《Web服务器ngin虚拟主机与反向代理》由会员分享,可在线阅读,更多相关《Web服务器ngin虚拟主机与反向代理(22页珍藏版)》请在金锄头文库上搜索。

1、Web服务器nginx虚拟主机与反向代理web 服务器 -nginxweb服务器简介:apache , web服务器:访问网页,查找、浏览信息。蜘蛛程序一网络爬虫常见的web服务器:apachelighttpdn gi nxtomcatIIS介绍nginx :高性能的http服务器和反向代理服务器(web加速),运行在类unix和windows上为什么选择 nginx ?处理速度快,占用的资源少apache里的模块是动、静结合;在nginx里面,都是静态的。支持热部署可以7x24不间断运行书写的代码质量很高,也很规范问题:俄国人写的,一些官方资料,文档比较少。安装之前:1、准备工作:1) ap

2、ache是停止的,释放80端口nginx2) 添加一个普通用户,出于安全的目的使用这个普通用户去运行# useradd -M -s /sbin/no logi n www默认使用的是nobody 这个用户。2、开始安装rootlocalhost l nmp# tar zxvf n gi nx-x.tar.gz -C /usr/local/src/安装nginx所需的软件包支持正则表达式(1) PCRE: Perl 库,Perl Compatible Regular Expressionsrootlocalhost nginx# cd pcre-8.10rootlocalhost pcre-8.

3、10# lsrootlocalhost pcre-8.10# ./c on figurerootlocalhost pcre-8.10# makerootlocalhost pcre-8.10# make in stall(2)安装 nginxrootlocalhostngi nx-0.8.46#./c on figure-user=www-group=www-prefix=/usr/local/ngi nx-with-http_stub_status_module -with-http_ssl_module-user-group-prefix-with-http_stub_status_mo

4、dule状态模块-with-http_ssl_module支持 httpsyum in stall -y ope nssl-develrootlocalhost nginx-0.8.46# makerootlocalhost ngi nx-0.8.46# make in stallrootlocalhost nginx-0.8.46# cd /usr/local/nginx/rootlocalhost ngin x# lsconf html logs sbin启动服务:rootlocalhost n gi nx# ./sb in/nginx -c conf/ngin x.c onfrootlo

5、calhost nginx# n etstat -antp | grep 80tcp00 0.0.0.0:800.0.0.0:* LISTEN 19449/ngi nx.c onf访问:Welcome to nginx! OK解读配置文件:rootlocalhost conf# pwd/usr/local/nginx/confrootlocalhost conf# vim ngin x.c onf12 user www;3 worker_processes 1; #开启的进程数,与 CPU的核数一致,查看CPU的信息:rootlocalhost html# cat /proc/cpu info

6、5 #error_log logs/error.log;错误日志6 #error_log logs/error.log no tice;7 #error_log logs/error.log info;redhat 5man 5 syslog.c onfredhat 6man 5 rsyslog.c onf ?9 #pidlogs/ngi nx.pid;*12 events 13 use epoll;#指定nginx使用高效的工作模式14 worker_connections1024;#每个进程能够处理的最大连接数15 能够处理的最大连接数=worker_processes x worker_

7、c onnectionsuse epoll; 指定nginx的工作模式默认使用的是select和pollepoll 2.6内核之后,某些发行版,比如SUSE、redhat支持epoll模型# un ame -rlinux 和redhat 和 windows 有没有可比性?其他的发行版,要想使用高效模式:kqueue BSD系列MacOS等# cat /etc/issueRed Hat En terprise Li nux Server release 5.5 (Tika nga)18http 192022-26282931323436373839404142in eludemime.types

8、;#文件的扩展名和文件类型default_type applicatio n/octet-stream; #文件的类型默认是二进制访问日志sen dfileon;#开启高效的文件传输模式#tcp_nopushon; #防止网络阻塞#keepalive_timeout 0;#长连接的超时时间,秒keepalive_timeout65;#gzip on;#开启gzip压缩传输数据server liste n80;server_ namelocalhost;#charset koi8-r; # 字符集#access_log logs/host.access .log main;4344 locati

9、on / 45 root html; = docume ntroot46 in dexin dex.html in dex.htm;页面文件的名字47 虚拟主机:基于域名的虚拟主机。FQDNDocume ntrootww1. ngi ngi /logs(raidO)日志迁移: 从 /usr/local/nginx/logs# mkdir -p /htdocs/ww1,ww2,default -v注意权限: www 进去 xrootlocalhost conf# cd /htdocs/ww1rootlocalhost ww1# echo ww1. ngin in dex.htmlrootl

10、ocalhost ww1# cd ./ww2rootlocalhost ww2# echo ww2. ngin in dex.htmlrootlocalhost ww2# cd ./default/rootlocalhost default# echo default .ngin in dex.html测试配置文件是否正确:rootlocalhost ngin x# ./sb in/nginx-tthe configuration file /usr/local/nginx/conf/nginx.conf syntax is okconfiguration file /usr/local/

11、nginx/conf/nginx.conf test is successful重启:用kill命令给nginx的pid传递一个信号,让它重新读取配置文件rootlocalhost n gi nx# cat logs/ngin x.pid19449nginx的平滑重启:rootlocalhost nginx# kill -HUP 19449客户端测试:vim /etc/hosts添加192.168.7.253ww1. ngi 192.168.7.253ww2. ngi 打开浏览器:. ngi ngin . ngin ngin .ngin nginx的日志管理错误日志:nginx出问题,查

12、看错误日志,排错访问日志:查看有哪些客户端来访问自己log_format ww1 $remote_addr - $remote_user $time_local $request$status $body_bytes_se nt $http_referer$http_user_age nt $http_x_forwarded_for;access_log logs/ww1.log ww1;1. Iog_format指定日志的格式log_format n ame format$remote_addr 禾口 $http_x_forwarded_for: i己录 ip 地址 *$remote_use

13、r :记录客户端的用户名称$time_local :记录访问时间和时区*$request :记录请求的URL和HTTP协议$status :记录请求状态$body_bytes_sent:记录发送给客户端的文件的主体内容的大小$http_referer :记录从哪个页面链接过来的$http_user_age nt :记录客户端浏览器的信息2. access_log指定日志的存放路径问题:日志轮替写一个日志轮替的脚本,结合计划任务。1周替换一个新的日志文件?农场和斗地主斗地主:server ip : rootlocalhost si# yum in stall -y httpd mysql-ser

14、ver php php-mysqlrootlocalhost html# pwd/var/www/htmlrootlocalhost html# lsddzrootlocalhost html# chmod -R 777 ddz/rootlocalhost html# /etc/i nit.d/mysqld startmysql create database ddz;mysql grant all on ddz.* to ddzuserlocalhost identified by 123456;mysql flush privileges;rootlocalhost html# vim +391 /e

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号