Windows下Nginx安装配置教程
首先去官网下载nginx1.0.11的Windows版本,官网下载
下载到软件包后,解压nginx-nginx1.0.11.zip包到你喜欢的根目录,并将目录名改为nginx。
然后,执行下列操作:
cdnginx
startnginx
这样,nginx服务就启动了。打开任务管理器,查看nginx.exe进程,有二个进程会显示,占用系统资源,那是相当的少。然后再打开浏览器,输入http://127.0.0.1/就可以看到nginx的欢迎页面了,非常友好
nginx-sstop//停止nginx nginx-sreload//重新加载配置文件 nginx-squit//退出nginx
接下来就是配置nginx的conf文件了。
下面是我的配置:
#usernobody; worker_processes1; #error_loglogs/error.log; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-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; include../conf.d/*.conf; #server{ #listen80; #server_namelocalhost; #charsetkoi8-r; #access_loglogs/host.access.logmain; #location/{ #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 #concurswithnginx'sone # #location~/\.ht{ #denyall; #} #} #anothervirtualhostusingmixofIP-,name-,andport-basedconfiguration # #server{ #listen8000; #listensomename:8080; #server_namesomenamealiasanother.alias; #location/{ #roothtml; #indexindex.htmlindex.htm; #} #} #HTTPSserver # #server{ #listen443ssl; #server_namelocalhost; #ssl_certificatecert.pem; #ssl_certificate_keycert.key; #ssl_session_cacheshared:SSL:1m; #ssl_session_timeout5m; #ssl_ciphersHIGH:!aNULL:!MD5; #ssl_prefer_server_cipherson; #location/{ #roothtml; #indexindex.htmlindex.htm; #} #} }
server{ listen80; server_namelocalhost; roote:/workspaces/react-project/build; location/api{ proxy_passhttp://127.0.0.1; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。