Skip to content

英文关键词搜索 #1110

Closed
Closed

Description

@gaofeng-bj

Describe the bug
英文关键词的搜索功能有欠缺,页面中包含的关键词搜索不到
To Reproduce
Steps to reproduce the behavior:

  1. Go to '搜索或创建新页面'
  2. 输入 fuser
  3. 弹出的下拉框中把 fuser 做了各种拆分,但就是没有搜索到想要的结果(红色标记)

Expected behavior
能精确匹配

Screenshots
snap035

Desktop (please complete the following information):

  • OS: [e.g. iOS] win10
  • Browser [e.g. chrome, safari] chrome
  • Version [e.g. 22] 87.0.4280.141

Additional context
Add any other context about the problem here.
#+TITLE: Nginx排错

** Nginx安装完成后,可访问 http://www.example.com ,但 systemctl status nginx 异常
:PROPERTIES:
:last_modified_at: 1610423797758
:created_at: 1610353033630
:END:
#+BEGIN_SRC
root@instance-1:/home/root# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: inactive (dead)
Docs: http://nginx.org/en/docs/

Jan 11 16:16:13 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:16:13 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:16:14 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:16:14 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:16:18 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:18:22 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:18:22 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 16:18:22 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
~
#+END_SRC
由此引出 /var/run 的一些知识 *[[Run-time variable data]] * 和 * [[systemctl管理脚本-nginx]] *
重新启动 nginx
#+BEGIN_SRC
root@instance-1:/home/root# systemctl start nginx.service
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root@instance-1:/home/root# systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-01-11 16:37:23 CST; 25s ago
Docs: http://nginx.org/en/docs/
Process: 3026 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Jan 11 16:37:20 instance-1 systemd[1]: Starting nginx - high performance web server...
Jan 11 16:37:20 instance-1 nginx[3026]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 11 16:37:21 instance-1 nginx[3026]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 11 16:37:21 instance-1 nginx[3026]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 11 16:37:22 instance-1 nginx[3026]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 11 16:37:22 instance-1 nginx[3026]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jan 11 16:37:23 instance-1 nginx[3026]: nginx: [emerg] still could not bind()
Jan 11 16:37:23 instance-1 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jan 11 16:37:23 instance-1 systemd[1]: nginx.service: Failed with result 'exit-code'.
Jan 11 16:37:23 instance-1 systemd[1]: Failed to start nginx - high performance web server.
#+END_SRC
提示 80 端口被占用,查看配置
#+BEGIN_SRC
root@instance-1:/# cd /etc/nginx && grep -R listen *
conf.d/default.conf: listen 80;
conf.d/default.conf: # proxy the PHP scripts to Apache listening on 127.0.0.1:80
conf.d/default.conf: # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
conf.d/default.conf: listen 443 ssl;
root@instance-1:/etc/nginx#
#+END_SRC
解决方案是重启系统,或者杀进程(用 fuser )
fuser -k 80/tcp,首先安装 psmisc


:PROPERTIES:
:last_modified_at: 1610427213489
:created_at: 1610369689917
:END:
#+BEGIN_SRC
root@instance-1:/usr/local# apt-get install psmisc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
psmisc
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 126 kB of archives.
After this operation, 652 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 psmisc amd64 23.2-1 [126 kB]
Fetched 126 kB in 0s (9254 kB/s)
Selecting previously unselected package psmisc.
(Reading database ... 39241 files and directories currently installed.)
Preparing to unpack .../psmisc_23.2-1_amd64.deb ...
Unpacking psmisc (23.2-1) ...
Setting up psmisc (23.2-1) ...
Processing triggers for man-db (2.8.5-2) ...
root@instance-1:/usr/local# fuser -k 80/tcp
80/tcp: 2002 3003
root@instance-1:/usr/local# systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
root@instance-1:/usr/local# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-01-11 20:56:40 CST; 51s ago
Docs: http://nginx.org/en/docs/
Main PID: 4803 (nginx)
Tasks: 2 (limit: 627)
Memory: 1.8M
CGroup: /system.slice/nginx.service
├─4803 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─4804 nginx: worker process

Jan 11 20:56:40 instance-1 systemd[1]: Starting nginx - high performance web server...
Jan 11 20:56:40 instance-1 systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after start: No such file or directory
Jan 11 20:56:40 instance-1 systemd[1]: Started nginx - high performance web server.
Jan 11 20:57:17 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 20:57:18 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
Jan 11 20:57:18 instance-1 systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
root@instance-1:/usr/local#
#+END_SRC
** 接下来生成密钥,由于证书 *[[rate limits]] * 的存在,因此必须指定 * [[Server]] *
:PROPERTIES:
:last_modified_at: 1610413060668
:created_at: 1610413049470
:END:
#+BEGIN_SRC
/.acme.sh/acme.sh --issue -d www.example.com -k ec-256
--server https://acme-staging-v02.api.letsencrypt.org/directory
--webroot /usr/share/nginx
root@instance-1:
# ~/.acme.sh/acme.sh --issue -d www.example.com -k ec-256 \

--server https://acme-staging-v02.api.letsencrypt.org/directory
--webroot /usr/share/nginx
[Tue Jan 12 08:57:11 CST 2021] Using CA: https://acme-staging-v02.api.letsencrypt.org/directory
[Tue Jan 12 08:57:11 CST 2021] Create account key ok.
[Tue Jan 12 08:57:11 CST 2021] Registering account: https://acme-staging-v02.api.letsencrypt.org/directory
[Tue Jan 12 08:57:11 CST 2021] Registered
[Tue Jan 12 08:57:11 CST 2021] ACCOUNT_THUMBPRINT='TavEbLu-MxoLN64qGpRuSw-DSO5qugSW04p7WGEIP1E'
[Tue Jan 12 08:57:11 CST 2021] Creating domain key
[Tue Jan 12 08:57:11 CST 2021] The domain key is here: /root/.acme.sh/www.example.com_ecc/www.example.com.key
[Tue Jan 12 08:57:11 CST 2021] Single domain='www.example.com'
[Tue Jan 12 08:57:11 CST 2021] Getting domain auth token for each domain
[Tue Jan 12 08:57:12 CST 2021] Getting webroot for domain='www.example.com'
[Tue Jan 12 08:57:12 CST 2021] Verifying: www.example.com
[Tue Jan 12 08:57:15 CST 2021] www.example.com:Verify error:Invalid response from http://www.example.com/.well-known/acme-challenge/kR5CkDQK3vg1KNH_7ewc51lm1uzPf0pb_Hj0imGcgTo [35.236.87.106]:
[Tue Jan 12 08:57:15 CST 2021] Please add '--debug' or '--log' to check more details.
[Tue Jan 12 08:57:15 CST 2021] See: https://github.com/acmesh-official/acme.sh/wiki/How-to-debug-acme.sh
root@instance-1:~#
#+END_SRC
Verify error:Invalid response from http://www.example.com/.well-known/acme-challenge/kR5CkDQK3vg1KNH_7ewc51lm1uzPf0pb_Hj0imGcgTo [35.236.87.106]
需要 ((5ff7f90c-0e7a-40e1-84c5-bc6a9a7ff307))
** Configure TLS/SSL on Nginx web Server
:PROPERTIES:
:last_modified_at: 1610456022153
:created_at: 1610456022153
:END:
#+BEGIN_SRC
server {
listen 443 ssl;
server_name www.example.com;

    ssl_certificate      /etc/nginx/ssl/cert.pem;
    ssl_certificate_key  /etc/nginx/ssl/key.pem;

    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;

    ssl_protocols   TLSv1 TLSv1.1 TLSv1.2
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

}
#+END_SRC
重启出现错误,检查配置文件
#+BEGIN_SRC
root@instance-1:/etc/nginx/conf.d# nginx -t
nginx: [emerg] invalid value "ssl_ciphers" in /etc/nginx/conf.d/default.conf:62
nginx: configuration file /etc/nginx/nginx.conf test failed
root@instance-1:/etc/nginx/conf.d#
#+END_SRC
仔细检查,发现 ssl_protocols TLSv1 TLSv1.1 TLSv1.2 语句后少了一个 ;

The directives ssl_protocols and ssl_ciphers can be used to limit connections to include only the strong versions and ciphers of SSL/TLS. Since version 1.0.5, nginx uses ssl_protocols SSLv3 TLSv1 and ssl_ciphers HIGH:!aNULL:!MD5 by default, so configuring them explicitly only makes sense for the earlier nginx versions. Since versions 1.1.13 and 1.0.12, nginx uses ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2 by default.

((5ff8772b-d9af-43ae-bc5a-43022db72088)) 显式支持TLS 1.0 或 TLS 1.1,会导致 [[https://letsencrypt.org/][Let's Encrypt]] 评分降低
** Can't open PID file /run/nginx.pid
:PROPERTIES:
:last_modified_at: 1610457987722
:created_at: 1610414352911
:END:
systemd[1]: /lib/systemd/system/nginx.service:8: PIDFile= references path below legacy directory /var/run/, updating /var/run/nginx.pid → /run/nginx.pid; please update the unit file accordingly.
*** 根据提示,修改 ((5ffda54f-1ca1-4e47-915a-9dba2860b502))/nginx.pid 的指向
#+BEGIN_SRC
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"
ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"

[Install]
WantedBy=multi-user.target
#+END_SRC
修改对应 PIDFile ,将其指向 /run/nginx.pid,重启服务后提示
#+BEGIN_SRC
root@instance-1:/etc/nginx# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-01-13 16:53:24 CST; 4h 26min ago
Docs: http://nginx.org/en/docs/
Process: 716 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Process: 782 ExecReload=/bin/sh -c /bin/kill -s HUP $(/bin/cat /var/run/nginx.pid) (code=exited, status=0/SUCCESS)
Main PID: 717 (nginx)
Tasks: 2 (limit: 627)
Memory: 2.3M
CGroup: /system.slice/nginx.service
├─717 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─785 nginx: worker process

Jan 13 16:53:24 instance-1 systemd[1]: Starting nginx - high performance web server...
Jan 13 16:53:24 instance-1 systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after start: No such file or directory
Jan 13 16:53:24 instance-1 systemd[1]: Started nginx - high performance web server.
Jan 13 16:53:37 instance-1 systemd[1]: Reloading nginx - high performance web server.
Jan 13 16:53:37 instance-1 systemd[1]: Reloaded nginx - high performance web server.
Jan 13 16:57:50 instance-1 systemd[1]: Reloading nginx - high performance web server.
Jan 13 16:57:50 instance-1 systemd[1]: Reloaded nginx - high performance web server.
root@instance-1:/etc/nginx#
#+END_SRC
*** The directory /run exists on the server:
#+BEGIN_SRC
root@instance-1:/etc/nginx# ls -ld /run
drwxr-xr-x 17 root root 580 Jan 13 21:43 /run
#+END_SRC
*** The pid setting is commented out by a # (hash) character at the beginning of the line in nginx configuration files:
#+BEGIN_SRC
root@instance-1:/etc/nginx# grep -ir pid /etc/nginx
/etc/nginx/nginx.conf:pid /var/run/nginx.pid;
#+END_SRC
原来是 /etc/nginx/nginx.conf 配置不一致导致
Systemd does NOT create PID files by itsef. It expects the executables to create it (usually within the /run , or specifically for Ubuntu within the /var/run folder). Systemd only checks, if it has been created after the service started. It also deletes the PID file when killing the service.
[[https://www.freedesktop.org/software/systemd/man/systemd.service.html#PIDFile=][systemd]]

Nginx server as forking process does support creating a PID file. To change its location, you may use the pid directive in its nginx.conf file, which you may find in the /etc/nginx folder for the standard package. This pid directive defaults to logs/nginx.pid .

When manually creating the Nginx service, you need to make sure, that both locations within your Systemd nginx.service file and within your Nginx nginx.conf configuration file match.
修改后重启服务,问题依旧
*** master process 是 root 发起,而worker process是nginx用户发起, [[Nginx's process]] 是正常的。
stopping nginx by killing it's master process first
#+BEGIN_SRC
root@instance-1:/home/root# ps -ef|grep nginx
root 364 1 0 09:28 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 365 364 0 09:28 ? 00:00:00 nginx: worker process
root 597 591 0 09:44 pts/0 00:00:00 grep nginx
root@instance-1:/home/root#
#+END_SRC
*** kill the PID of nginx master process
#+BEGIN_SRC
root@instance-1:/home/root# kill -9 364
root@instance-1:/home/root# ps -ef|grep nginx
root 601 591 0 09:49 pts/0 00:00:00 grep nginx
root@instance-1:/home/root#
#+END_SRC
netstat -tulpn |grep 80 查看是否有进程监听 80 端口
重启后,问题照旧
*** 注意一个细节,在Ubuntu和Debian,the directory /var/run is a symbolic link to the directory /run
#+BEGIN_SRC
root@instance-1:/etc/nginx# ls -ld /var/run
lrwxrwxrwx 1 root root 4 Dec 17 03:27 /var/run -> /run
#+END_SRC
那么问题的根源实质不在这里
*** That warning with the nginx.pid file is a know bug (at least for Ubutnu if not for other distros as well). More details here: https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1581864
**** It seems to be a race between systemd and nginx. As if systemd was expecting the PID file to be populated before nginx had the time to create it.
**** We are also affected, and I've looked into the source. In main(), the ngx_create_pidfile() gets called right after the ngx_daemon() function. ngx_daemon of course forks, and the parent process exits immediately with exit(0). This is a pure race condition between nginx and systemd.

This is not a problem (other than the scary log), because the PIDFile option is not needed for determining the main PID of nginx (systemd can correctly "guess" the main pid), it's only for removing the file when the service exits.

As far as I can tell, this daemonization is not needed for the systemd service use-case. The service should be Type=simple, and 'daemon off'. The standard file handles get redirected by systemd anyway, and non-stop upgrade cannot be used in this case either. (See: http://nginx.org/en/docs/faq/daemon_master_process_off.html )

If this is too much of a change, another workaround is removing the PIDFile option, and adding the line:
ExecStopPost=/bin/rm -f /run/nginx.pid
*** Workaround (on a ssh console, as root, use the commands bellow):
#+BEGIN_SRC
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
systemctl restart nginx
#+END_SRC

Then check if you still see that nginx.pid error and also if nginx is actually running and if you can connect to port 80 on your server.
#+BEGIN_SRC
root@instance-1:/home/root# systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/nginx.service.d
└─override.conf
Active: active (running) since Thu 2021-01-14 09:55:04 CST; 9s ago
Docs: http://nginx.org/en/docs/
Process: 716 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Process: 718 ExecStartPost=/bin/sleep 0.1 (code=exited, status=0/SUCCESS)
Main PID: 717 (nginx)
Tasks: 2 (limit: 627)
Memory: 1.8M
CGroup: /system.slice/nginx.service
├─717 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
└─719 nginx: worker process

Jan 14 09:55:04 instance-1 systemd[1]: Starting nginx - high performance web server...
Jan 14 09:55:04 instance-1 systemd[1]: Started nginx - high performance web server.
root@instance-1:/home/root#
#+END_SRC
** 参考 :
https://www.cyberciti.biz/faq/how-to-configure-nginx-with-free-lets-encrypt-ssl-certificate-on-debian-or-ubuntu-linux/

Activity

  1. tiensonqin commented on May 9, 2021

    @tiensonqin
    Contributor

    桌面端已修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions