window10系统安装nginx服务,提供网页方面的服务。下面为详细图文安装配置教程。
nginx_2">1)下载nginx软件
官方下载地址:http://nginx.org/en/download.html
2)解压缩软件
unzip nginx-1.20.1.zip 或者 使用解压缩软件,下面是解压缩后的内容
nginx_11">3)CMD命令行启动nginx
cd nginx-1.20.1
start nginx
nginx -t
tasklist /fi “imagename eq nginx.exe”
nginx -s reload //重新加载
nginx -s stop //此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程
nginx -s quit //此方式停止步骤是待nginx进程处理任务完毕进行停止
说明:
4)测试、访问
正常80端口不被占用的情况下,url输入: localhost,页面显示:
5)配置两个服务的代码:
server {
listen 80;
server_name localhost;
location / {
root html/default;
index index.html index.htm;
}
}
#set port
server {
listen 8001;
server_name localhost;
location /{
root html/demo;
index index.html index.htm;
}
}
nginx_59">6)linux版nginx常用命令
帮助命令:nginx -h
启动Nginx服务器 :sudo nginx
查看进程: ps aux | grep nginx
配置文件路径:/usr/local/nginx/conf/nginx.conf
检查配置文件:sudo nginx -t
指定启动配置文件:sudo nginx -c /usr/local/nginx/conf/nginx.conf
暴力停止服务:sudo nginx -s stop
优雅停止服务:sudo nginx -s quit
重新加载配置文件:sudo nginx -s reload