1.下载nginx windows
2.windows+R ,cmd进入命令行
3.进入nginx的目录下
4.执行命令start nginx
5.输入 http://localhost:80
如果能看到欢迎页面服务器就已经启动了
6.打开conf下的nginx.config进行配置
listen后的80为端口号
server_name中的localhost为端口前的名字
location中的root后为我的项目的路径,项目下有css,html,js等静态资源文件
如我想访问项目下的index.html,在浏览器中输入http://localhost:80/index.html
80为listen后的值,localhost为server_name后的值,index.html为root后的路径下的html文件
index后的login.html为只输入http://localhost:80时默认跳转的页面
error_page中的404.html为项目中的404页面,当出现403和404错误时,跳到该页面。
7.命令
start nginx 启动服务器
nginx -s stop 快速停止服务器
nginx -s quit 完全正常停止
nginx -s reload 重新加载配置文件,修改后执行该命令即可