我有一个专用的服务器,使用 arakasi72 的 ruTorrent 安装脚本运行 ruTorrent:
https://github.com/arakasi72/rtinst
我想在同一台服务器上安装一个 WordPress 网站,但遇到了错误,而且我不知道如何修复它们。
我使用本教程来安装 WordPress:
https://www.linuxbabe.com/ubuntu/install-wordpress-ubuntu-20-04-nginx-mariadb-php7-4-lemp
按照说明进行操作非常简单,直到需要执行为止:
sudo nginx -t
此时我得到了以下输出:
nginx: [warn] conflicting server name "www.<domain_name.tld>" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "<domain_name.tld>" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.<domain_name.tld>" on [::]:80, ignored
nginx: [warn] conflicting server name "<domain_name.tld>" on [::]:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
我知道什么问题是,问题是,我不太明白怎么解决问题。我知道我定义了多个服务器块,其中一个位于 的文件中/etc/nginx/sites-available/default
,该文件基于https://github.com/arakasi72/rtinst/blob/master/conf/nginxsite看起来像:
server {
listen 80;
listen [::]:80;
#server_name <Domain Name>;
root /var/www;
index index.html index.php index.htm;
error_page 403 = @denied;
#Below enter IP address or block to allow, eg LAN and/or VPN blocks
allow 10.0.0.0/8;
allow 172.16.0.0/12;
allow 192.168.0.0/16;
deny all;
location @denied {
return 301 https://$host$request_uri;
}
location / {
try_files $uri $uri/ =404;
}
location /rutorrent {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
include /etc/nginx/conf.d/php;
include /etc/nginx/conf.d/cache;
}
#include /etc/nginx/sites-available/dload-loc;
location ~ /\.ht {
deny all;
}
}
我猜是其他服务器块导致了问题?LinuxBabe 教程中的那个服务器块如下所示:
server {
listen 80;
listen [::]:80;
server_name www.example.com example.com;
root /usr/share/nginx/example.com/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php;
}
location ~ ^/wp-json/ {
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
location ~* /wp-sitemap.*\.xml {
try_files $uri $uri/ /index.php$is_args$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
client_max_body_size 20M;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
# Add headers to serve security related headers
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Permitted-Cross-Domain-Policies none;
add_header X-Frame-Options "SAMEORIGIN";
}
#enable gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1000;
gzip_comp_level 5;
gzip_types application/json text/css application/x-javascript application/javascript image/svg+xml;
gzip_proxied any;
# A long browser cache lifetime can speed up repeat visits to your page
location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires 360d;
}
# disable access to hidden files
location ~ /\.ht {
access_log off;
log_not_found off;
deny all;
}
}
因为 arakasi72 的脚本使用标准化的 Apache 目录结构/var/www/
来存储所有与 Web 相关的内容,所以我想保留这个惯例,并且在 LinuxBabe 教程中,任何地方都/usr/share/nginx/
存在,/var/www/
为了保持一致性,我将其更改为(尽管如果这不是必要的,我也可以接受使用 NGINX 推荐的/usr/share/nginx/
位置)。
我想要的功能是,当我在浏览器中输入“www.<domain_name>.tld”时,我希望能够访问“www.<domain_name>.tld/wp-admin/install.php”,这样我就可以完成我的 WordPress 安装,然后人们只需输入“www.<my_domain_name>.tld”就可以直接进入 WordPress 网站。
我哪里错了?我需要做什么?