![](https://img.haomeiwen.com/i9177328/46f82d1280b60969.jpg)
![](https://img.haomeiwen.com/i9177328/b799e220f8665dd8.png)
nginx的具体介绍可以百度,这里就不做过多解释
其实作为前端开发者,虽然用的不深,但是还是要记一记的
常用命令
启动为nginx -c \conf\nginx.conf
活着为 start nginx
停止 nginx -s stop
重启 nginx -s reload
测试 nginx -t -c \conf\nginx.conf
下面的配置文件我已经做了详细的注释 以备忘
#全局参数 worker_processes使用几个内核 worker_connections每一个内核中的进程数量1024 error_log错误日志 pid表示ngnix在系统里的进程号
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_processes 1;
events {
worker_connections 1024;
}
# mime.types告诉客户端我们要打开的文件是什么类型 default_type表示默认的文件类型 access_log客户端状态日志 sendfile允不允许发送文件 keepalive_timeout请求超时设置
# include表示加载进来
# listen监听端口 server_name监听域名 root路径 error_page指定错误码指向文件名 下面的root是错误文件的根目录
http{
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server{
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
error_page 404 /hi.html;
location = /hi.html {
root html;
}
}
server{
}
}
server_name别忘了在本机的hosts文件改一下指向
再加一个判断手机的
![](https://img.haomeiwen.com/i9177328/9fc3b5fe64ccddf9.png)
网友评论