这是本文档旧的修订版!
Nginx 服务器
主要关于Nginx服务器安装、维护等事项。
安装
安装和多域名设置,主要参考以下文章:1) 2) 3) 4) 5) 6) 按照步骤去做就好,没有太复杂。
sudo apt update sudo apt install nginx sudo systemctl status nginx sudo systemctl reload nginx
安装完并修改配置文件后,检查配置语法是否正确
sudo nginx -t -c dokuwiki.conf # 测试配置文件是否有效 sudo nginx -t # 测试所有设置
端口配置
sudo ufw allow 'Nginx Full' sudo ufw enable sudo ufw status sudo ufw allow ssh # 很重要,否则 SSH 登录会被拒绝
如果出现502拒绝访问,大概是因为php解释服务没有安装。参考 NGINX 502 Bad Gateway: PHP-FPM
sudo apt -y install php7.4 php7.4-fpm # ubuntu 20.04 上只支持 7.4 版本
出现 “PHP function xml_parser_create ” 错误,是因为 php-xml 包没有安装。
sudo apt-get install php-xml
SSL 证书
请参阅 服务器安全设置 笔记中的记述。以开通https
的安全访问模式。
反向代理
当访问 http://192.168.17.129:9001/deu/a.html 时,会引导到 http://127.0.0.1:8080
server { listen 9001; server_name 192.168.17.129; location ~ /edu/ { proxy_pass http://127.0.0.1:8080 } location ~ /vod/ { proxy_pass http://127.0.0.1:8081 } }