×
新网 > 虚机资讯 > 正文

nginx安装与配置

从今开始,学nginx   #安装pcre   [root@svr3 ~]# tar -xjf pcre-8.02.tar.bz2 -C /usr/src/   [root@svr3 ~]# cd /usr/src/pcre-8.02/   [root@svr3 pcre-8.02]# ./configure && make && make install   

 

从今开始,学nginx #安装pcre [root@svr3~]#tar-xjfpcre-8.02.tar.bz2-C/usr/src/ [root@svr3~]#cd/usr/src/pcre-8.02/ [root@svr3pcre-8.02]#./configure&&make&&makeinstall #安装nginx [root@svr3~]#useradd-M-s/sbin/nologinnginx [root@svr3~]#tar-xzfnginx-1.0.5.tar.gz-C/usr/src/ [root@svr3~]#cd/usr/src/nginx-1.0.5/ [root@svr3nginx-1.0.5]#./configure--prefix=/usr/local/nginx--user=nginx--group=nginx [root@svr3nginx-1.0.5]#make&&makeinstall [root@svr3~]#vim/usr/local/nginx/conf/nginx.conf +++++++++++++++相关说明+++++++++++++++++++++++++++++ usernginx;#用户使用nginx worker_processes1;#程序启动后,初始化的进程数;内核多的话,可根据内核数量设置。 #error_loglogs/error.log; #error_loglogs/error.lognotice; error_loglogs/error.loginfo;#设置错误日志的记录级别 pidlogs/nginx.pid;#重启关闭nginx时,需要知道pid文件。 worker_rlimit_nofile51000; # events{ worker_connections50000;#允许的连接数,我这里设置50000个。 } http{ includemime.types; default_typeapplication/octet-stream; #log_formatmain\'$remote_addr-$remote_user[$time_local]"$request"\' #\'$status$body_bytes_sent"$http_referer"\'

1 (74).jpg

#\'"$http_user_agent""$http_x_forwarded_for"\'; #access_loglogs/access.logmain; sendfileon; tcp_nopushon; #keepalive_timeout0; keepalive_timeout30; gzipon;#允许gzip压缩。 gzip_buffers 32 4k; gzip_comp_level 1; gzip_min_length 1024; gzip_types text/html text/css application/xml; server{ listen80; server_namelocalhost; #charsetkoi8-r; access_loglogs/host.access.logmain; location/{ roothtml;#目录 indexindex.htmlindex.htm;#index类型 } #error_page404/404.html; #redirectservererrorpagestothestaticpage/50x.html # error_page500502503504/50x.html; location=/50x.html{ roothtml; } #这里是关于转发的部分 #proxythePHPscriptstoApachelisteningon127.0.0.1:80 # #location~.php${ #proxy_passhttp://127.0.0.1; #} #fastcgi的部分 #passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000 # #location~.php${ #roothtml; #fastcgi_pass127.0.0.1:9000; #fastcgi_indexindex.php; #fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; #includefastcgi_params; #} #denyaccessto.htaccessfiles,ifApache\'sdocumentroot #concurswithnginx\'sone # #location~/.ht{ #denyall; #} } #anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration 虚拟主机的部分 } +++++++++++++++++++++++++++++++++++++++++++++ 现在就配置一台主机,改了以下内容: server{ listen80; server_namesvr3.labexam.com10.1.1.30; #charsetkoi8-r; access_loglogs/w1.access.logcombined; location/{ root/var/www/w1; indexindex.htmlindex.htm; } #看了下日志 [root@svr3nginx]#tail/usr/local/nginx/logs/w1.access.log 10.1.1.8--[15/Aug/2011:02:21:50+0800]"GET/HTTP/1.1"2008"-""Opera/9.80(WindowsNT5.1;U;zh-cn)Presto/2.9.168Version/11.50" 10.1.1.8--[15/Aug/2011:02:21:50+0800]"GET/favicon.icoHTTP/1.1"404142"http://svr3.labexam.com/""Opera/9.80(WindowsNT5.1;U;zh-cn)Presto/2.9.168Version/11.50" ===>如何启动nginx?<假定nginx安装在/usr/local/nginx中> 方法1、执行/usr/local/nginx/sbin/nginx-t检查配置文件是否有误!或是直接执行/usr/local/nginx/sbin/nginx 如果有多个配置文件可以使用指定的配置文件启动: #/usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx.conf ===>nginx的信号控制: TERM,INT快速关闭 QUIT从容关闭 HUP重启,重新加载配置文件 USR1重启打开日志,在切割日志时用途大 USR2平滑升级可执行程序 WINCH从容关闭进程

 

本文出自 “潜入技术的海洋” 博客,请务必保留此出处http://myhat.blog.51cto.com/391263/639564

  • 相关专题

免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:operations@xinnet.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。

免费咨询获取折扣

Loading