当前位置:首页 > nginx > 正文

windows怎么启动nginx

  • nginx
  • 2024-05-06 15:28:28
  • 2362

⑴如何在Windows上配置并运行Nginx
Nginx(“enginex”)是一个高性能、轻量级的HTTPWeb服务器、反向代理和IMAP/POP3/SMTP电子邮件代理。
Nginx是由俄罗斯程序员IgorSysoev为俄罗斯第二大访问量网站Rambler.ru开发的。 他已经在这个网站上工作了四年多。 Igor将源代码转换为类似BSD的代码。 根据许可。
自发布以来的四年里,Nginx以其稳定性、丰富的功能集、示例配置文件和低系统资源消耗而闻名。 Nginx在高性能和稳定性上超越了Apache,导致越来越多的国内网站使用Nginx作为Web服务器。
Nginx目前部署在新浪、网易、腾讯等国内各大门户网站上,最近发现Nginx技术在国内越来越流行,越来越多的网站涌现;应用并部署Nginx。
1.首先下载Windows版的nginx1.0.11版本。 下载软件包后,将nginx-nginx1.0.11.zip包解压到您喜欢的根目录下,并将目录名称更改为nginx。
然后执行以下操作:
cdnginx
startnginx
这将启动nginx服务。 打开任务管理器,查看nginx.exe进程。 会显示两个进程,占用系统资源很小。 然后打开浏览器输入127.0.0.1就可以看到nginx的欢迎页面,非常友好
nginx-sstop//停止nginx
nginx-sreload//重新加载配置文件
nginx-quit//退出nginx
2.下一步是设置nginx配置文件。 这是我的配置:
#usernobody;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.;
#pidlogs/nginx.pid;
事件{
worker_connections1024;

http{
includemime.types;
default_typeapplication/八位组-stream;
log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
access_loglogs/access.logmain;
sendfileon;
#tcp_nopushon;
#keepalive_timeout0;
keepalive_timeout65;
#gzipon;
服务器{
listen80;
server_namelocalhost;
#charsetkoi8-r;
#access_loglogs/host.access.logmain;
位置~*软件/(.**)。 \.(jpg|rar)
{
expires21d;
rootd:/temp/;
access_logd:/temp/soft.3g.cn_nginx_s3gd-205.log;
proxy_storeon;
proxy_store_accessuser:rwgroup:rwall:rw;
proxy_temp_pathd:/temp/;
proxy_redirectoff;
proxy_set_headerHost112.25.10.140;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
client_max_body_size10m;
client_body_buffer_size1280k;
proxy_connect_timeout900;
proxy_send_timeout900;
proxy_read_timeout900;
proxy_buffer_size40k;
proxy_buffers40320k;
proxy_busy_buffers_size640k;
proxy_temp_file_write_size640k;
if(!-e$request_filename)
{
proxy_passhttp://112.25.10.140:80;


位置/{
roothtml;
indexindex.htmlindex.htm;
}
#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;
#}
#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
#与nginx一致
#
#location~/\.ht{
#denyall;
#}
}
#anothervirtualhostusingmixofIP-、name-和port-于配置
#
#server{
#listen8000;
#listensomename:8080;
#server_namesomenamealiasanother.alias;
#location/{
#roothtml;
#indexindex.htmlindex.htm;
#}
#}
#HTTPSserver
#
#server{
#Listen443;
#server_namelocalhost;
#sslon;
#ssl_certificatecert.pem;
#ssl_certificate_keycert.key;
#ssl_session_timeout5m;
#ssl_protocolsSSLv2SSLv3TLSv1;#ssl_ciphersHIGH:!aNULL:!MD5;
#ssl_pre fer_server_cipherson;
#location/{
#roothtml;
#indexindex.htmlindex.htm;
#}
#}
}