linux - nginx(example.app)中的自定义域无法连接

标签 linux ubuntu nginx

在 LEMP 堆栈的主题下,我们的任务是创建/配置一个名为“thething.app”的网站
here 提供的指南一样,我按照第4步的配置部分。
唯一的区别是该站点将在 web 目录中有一个 php 文件而不是一个 html

<?php
    echo "this is thething.app";
?>
这是我的(原始)配置:
server {
    listen 80;
    server_name thething.app www.thething.app;
    root /home/melonpan/thething.app;

    index index.html index.htm index.php;

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

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

    location ~ /\.ht {
        deny all;
    }

}
通过链接到 Nginx 启用站点的目录中的配置文件激活我的配置后 sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/我用 sudo nginx -t 测试了语法这导致成功,然后我用 sudo systemctl reload nginx 重新启动了 nginx
然后我尝试在浏览器上访问 thething.app,但它显示“无法连接”
thething.app
幸运的是我发现了这个:Setting up nginx to support custom domain name
有类似的问题。
所以我删除了server_name行使我的新配置成为
server {
    listen 80;

    root /home/melonpan/thething.app;

    index index.html index.htm index.php;

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

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

    location ~ /\.ht {
        deny all;
    }

}
在重新链接、测试和重新启动 nginx 之后,我认为它会起作用。 但不是!它仍然无法连接。
我什至编辑了主机文件 sudo nano /etc/hosts并添加了 127.0.1.1 thething.app我们正在使用 ubuntu
编辑:我试过 http://thething.app同样,在 Firefox 中禁用 http only 模式的事件
我究竟做错了什么?

最佳答案

添加 localhost 作为服务器名称并尝试使用它访问您的应用程序。
确保根属性指向文件夹而不是文件,并在末尾添加/。
还要确认您的 PHP 安装工作正常。

关于linux - nginx(example.app)中的自定义域无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69963678/

相关文章:

linux - 使用 node.js 解析 word 文档中的表格

python - 在 python IDE 上正确运行的 linux 终端中运行的 python 应用程序的错误输出

postgresql - 如何在 ubuntu 上安装 Odoo 9?

nginx - 根目录在nginx中显示404

linux - Nginx 将路由定义为服务器名称

linux - 动态库代码 stub 的执行流程

linux - 用户进程、终端和内核之间的通信

python - 如何将 python 放入路径中 - Ubuntu 20 npm 安装失败

ubuntu - 凯特编辑器,关闭/移动当前选项卡的快捷方式

performance - Nginx 性能问题