注意:事实证明根本没有任何问题。详情见评论。
我刚刚从 Oracle Cloud 获得了新的实例,Ubuntu 20.04 Minimized。因为我试图在这个实例上运行 DokuWiki,所以我安装了这些包:
sudo apt install net-tools lsof wget nano
sudo apt install php7.4-fpm php7.4-xml php7.4-mbstring imagemagick nginx certbot python3-certbot-nginx
我从未接触过但删除nginx.conf
了符号链接并将我自己的 conf 文件与名称一起放入(虽然真实名称已被编辑)/etc/nginx
default
/etc/sites-enabled
/etc/nginx/conf.d
example.com.conf
server {
listen 80 default_server;
server_name example.com;
root /var/www/dokuwiki;
index index.php index.html;
location / {
try_files $uri $uri/ @dokuwiki;
}
location @dokuwiki {
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1&$args last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /(conf|bin|inc|vendor)/ {
deny all;
}
location ~ /data/ {
internal;
}
}
当然,使用以下命令/var/www/dokuwiki
由www-data
(用户和组)拥有:
sudo chown -R www-data:www-data /var/www/dokuwiki
问题是,我无法访问我的网站。当我输入nginx
终端时,它会像这样尖叫:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
但是,我检查过没有apache2
类似的东西,也没有其他进程监听端口 80。
root@redacted:~# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 1296 root 6u IPv4 32966 0t0 TCP *:http (LISTEN)
nginx 1297 www-data 6u IPv4 32966 0t0 TCP *:http (LISTEN)
nginx 1298 www-data 6u IPv4 32966 0t0 TCP *:http (LISTEN)
root@redacted:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-11-06 13:24:23 UTC; 16min ago
Docs: man:nginx(8)
Process: 1294 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 1295 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 1296 (nginx)
Tasks: 3 (limit: 1110)
Memory: 3.1M
CGroup: /system.slice/nginx.service
├─1296 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─1297 nginx: worker process
└─1298 nginx: worker process
Nov 06 13:24:23 redacted systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 06 13:24:23 redacted systemd[1]: Started A high performance web server and a reverse proxy server.
root@redacted:~# fuser -v 80/tcp
USER PID ACCESS COMMAND
80/tcp: root 1296 F.... nginx
www-data 1297 F.... nginx
www-data 1298 F.... nginx
由于我没有碰过nginx.conf
,nginx -t
所以说没有错误。但检查.conf
文件失败:
root@redacted:~# nginx -tc /etc/nginx/conf.d/example.com.conf
nginx: [emerg] "server" directive is not allowed here in /etc/nginx/conf.d/example.com.conf:1
nginx: configuration file /etc/nginx/conf.d/example.com.conf test failed
但我认为这与这个问题无关(虽然不确定)。
即使使用端口 80 杀死所有进程也不起作用。
我在谷歌上搜索了这个问题的解决方案,但没有找到任何可行的解决方案。
PS。我已经从iptables
OC Web 面板打开了端口。所以端口的事情不会是我认为这个问题的原因。