windows下安装nginx与配置

阅读:336 2019-03-19 15:04:39 来源:开源中国

在nginx官网下载页面下载最新的包http://nginx.org/en/download.html,目前最新的版本是1.13.3,window系统选择nginx/windows-1.13.3下载。

下载完成之后解压到c盘,并进入到该目录c:nginx-1.13.3,双击运行nginx.exe文件;(启动的时候会有一个窗口闪一下,这是正常情况)

然后打开浏览器访问http://localhost/,如果页面上显示welcometonginx!,那么恭喜,到这一步已经成功了!

接下来我们开始配置nginx,配置文件是c:nginx-1.13.3confnginx.conf;

配置文件的代码结构是:

****http{includemime.types;default_typeapplication/octet-stream;****server{listen80;server_namelocalhost;****}#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都分别是一个站点。

比如我有一个网站放在d盘(跨磁盘那是很简单的事),那么配置文件就这样配置:

server{listen80;server_namewww.test.com;location/{rootd:/nginx_www/test;indexindex.htmlindex.htm;}}

当然也肯定是需要修改hosts文件的,里面增加一行配置:

127.0.0.1www.test1.com

前面已经开启了nginx服务,需要重启一下;关于如何重启,请看下面段落。

然后就可以打开浏览器访问www.test1.com站点了;

这些命令都需要在c:nginx-1.13.3目录下面执行

相关文章
{{ v.title }}
{{ v.description||(cleanHtml(v.content)).substr(0,100)+'···' }}
你可能感兴趣
推荐阅读 更多>
推荐商标

{{ v.name }}

{{ v.cls }}类

立即购买 联系客服