解压后即可使用,
注意不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程
在nginx.exe目录,打开命令行工具,用命令 启动/关闭/重启nginx
start nginx : 启动nginx
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确
关闭nginx:
nginx -s stop :快速停止nginx
nginx -s quit :完整有序的停止nginx
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80; #监听端口
server_name 127.0.0.1 localhost; #域名
location / {
root C:/MyProject/nginxTest; #html的根目录地址
index index.html index.htm; #启动页的各个格式
}
}
}
这里强调一下这个目录
root C:/MyProject/nginxTest;
在windows上文件夹路径是这样的 C:\MyProject\nginxTest,所以得将反斜杠变成斜杠。不然就会跳转到nginx的介绍页面
网友评论