nginx基本配置和常用的命令
A常见问题:找不到 nginx.pid 而启动失败
1)使用nginx 的 -c 指令 生成日志文件
语法 ./nginx -c nginx.conf # 这里的nginx.conf一般在你的nginx安装目录中
./nginx -c /usr/local/nginx/conf/nginx.conf
2)然后再 nginx -s reload 或者 nginx -s reopen 此时不会报错了
1.启动或重启nginx
/usr/local/nginx/sbin/nginx -s reload
2.停止nginx
./nginx -s stop
3.退出nginx
./nginx -s quit
4.nginx基本配置
server { listen 192.168.1.111:80; listen 443 ssl; server_name test.com;
root /www/wwwroot/ok-admin/;
#HTTP_TO_HTTPS_START 强制https if ($server_port !~ 443){ rewrite ^(/.*)$ https://$host$1 permanent; } #HTTP_TO_HTTPS_END #配置ssl证书 ssl_certificate /usr/local/nginx/ssl/www.zhizous.cn.pem; ssl_certificate_key /usr/local/nginx/ssl/www.zhizous.cn.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass "http://localhost:8081"; # 代理这个端口 # root /www/wwwroot/ok-admin/; # 指向的项目路径 index index.html index.htm;
try_files $uri $uri/ /index.html; #解决页面刷新404问题 } }
5.引入其他目录中的配置文件:include
# nginx.conf 主文件里边配置 http { server { listen 80; server_name 你的域名; # www.test.com } include /usr/local/nginx/myconf/*.conf; }