【问题标题】:NGINX server on Debian not taking my configDebian 上的 NGINX 服务器没有接受我的配置
【发布时间】:2020-06-04 20:15:41
【问题描述】:

我已将我的域 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 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

【问题讨论】:

  • 你也可以发布“ps auxww |grep nginx”吗?
  • @merinoff 已添加到问题中
  • 如果您希望您的问题得到解答,切勿将您的代码或配置文件作为屏幕截图发布。
  • @IvanShatsky 感谢您的建议,我在问题中添加了文字

标签: php nginx debian


【解决方案1】:

根据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 来检查。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-17
    • 1970-01-01
    • 2018-05-03
    • 1970-01-01
    • 2018-01-24
    • 2017-05-12
    • 1970-01-01
    相关资源
    最近更新 更多