Debian 上的 NGINX 服务器没有采用我的配置

NGINX server on Debian not taking my config

我已将我的域 rohanpatra.ga 指向我的服务器并安装了 nginx。我目前 运行 服务器上有两个域,rohanpatra.ga 和 meetsecured.tk。 MeetSecured是一个基于Jitsi Meet的区块链视频会议平台,貌似运行还行。但是,当我转到 rohanpatra.ga 时,它只会转到默认的 nginx 页面。

我已经创建了配置文件:

sites-available directory config file content

server {
    listen 80;
    listen [::]:80;

    root /var/www/rohanpatra.ga;
    index index.php index.html index.htm;

    server_name your_domain;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}

并将文件符号链接到 sites-enabled 文件夹:

sites-enabled directory

这里是网站的根目录和一个文件的内容index.php:

/var/www/rohanpatra.ga directory

index.php

<?php
  phpinfo();
?>

根据要求:

root@debian-8gb-hel1-1:~# ps auxww |grep nginx

reponse

root      5874  0.0  0.1  70944  9032 ?        Ss   May30   0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  9129  0.0  0.1  71228  9516 ?        S    21:52   0:00 nginx: worker process
www-data  9130  0.0  0.0  71228  6344 ?        S    21:52   0:00 nginx: worker process
www-data  9131  0.0  0.0  71228  6344 ?        S    21:52   0:00 nginx: worker process
www-data  9132  0.0  0.0  71228  6344 ?        S    21:52   0:00 nginx: worker process
root     10356  0.0  0.0   6144   888 pts/0    S+   22:29   0:00 grep nginx

根据 Nginx documentation,您在配置中错误配置了 server_name 参数。

正确的配置应该如下所示:

server {
    listen 80;
    server_name rohanpatra.ga;

    root /var/www/rohanpatra.ga;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}

并确保此 FQDN rohanpatra.ga 在服务器本身上正确解析。

您可以通过在服务器控制台键入:nslookup rohanpatra.ga 进行检查。