分类 Linux 下的文章

在安装 wordpress 后遇到一个问题,打开后台的 theme 页面后,一直无法加载出来内容,查看后台 nginx 的日志,发现如下错误:

[error] 10929#10929: *337 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /wp-admin/theme-install.php HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.3-fpm.sock:", host: "127.0.0.1", referrer: "http://127.0.0.1/wp-admin/themes.php"

大概是处理 php 页面的时候 timeout 了,Google 了发现问题出在转发到代理服务器 fastCGI 时超时了:https://talk.plesk.com/threads/upstream-timed-out-110-connection-timed-out-randomly.350497/
解决方案就是在 nginx 配置文件内定义一下相关超时时间设定:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

将上述内容加入 config 文件,reload nginx 测试页面加载是否正常:

sudo service nginx configtest
sudo service nginx reload



在使用 WSL 中发现无法使用 systemd 指令,会有如下报错信息:System has not been booted with systemd as init system (PID 1). Can't operate

查询后发现 WSL 的确有这个问题:https://github.com/MicrosoftDocs/WSL/issues/457

解决方法是用管理员权限打开 WSL,然后使用 sudo service 来控制进程,如:

sudo service nginx start

升级到 wsl2 可以通过安装 genie 来激活 systemd:https://blog.niekun.net/archives/1805.html


手册:http://nginx.org/en/docs/

涵盖了安装教程,开始使用教程,常用使用情景教程,指令索引,变量索引 等链接。

变量:http://nginx.org/en/docs/varindex.html

变量在 nginx 配置中使用很多,使用变量可以根据需要处理特定部分。如:$rui, $scheme, $request_filename, $host, $request_uri

指令:http://nginx.org/en/docs/dirindex.html

如:listen, include, location, if, auth_basic


vim 是 Linux 下常用的编辑器,学会常用的操作如:光标移动 复制 粘贴 删除 撤销 等指令,对于日常使用很有必要,下面介绍常用指令。

注意 vim 所有控制指令都区分大小写。

阅读全文