通过浏览器访问 IP 地址时在 nginx 上创建新的 Lumen 应用程序抛出 404

Creating new Lumen app on nginx throwing 404 when hiting IP Adress through browser

我正在尝试在 Digital Ocean 的 Nginx 服务器上创建一个普通的 Lumen 应用程序。在 official documentation for Laravel 之后,我按照所说的一切进行操作,直到 Laravel 安装位。

只是代替这个

composer create-project laravel/laravel /var/www/lumen/ 4.1

我用过

composer create-project --prefer-dist laravel/lumen blog` instead.

当我使用 ls.

时,Lumen 文档现在出现在目录中

然而,当我输入 IP 地址或 IPAdress/index.php 时,它显示

404 Not Found - nginx/1.4.6 (Ubuntu)


此外,这是我的虚拟主机配置文件 (nano /etc/nginx/sites-available/default)`:

server {
        listen   80 default_server;

        root /var/www/laravel/public/;
        index index.php index.html index.htm;

        location / {
             try_files $uri $uri/ /index.php$is_args$args;
        }

        # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

我做错了什么或遗漏了什么?


此外,如果我尝试使用 PhpStorm 连接到 SSH 目录,我收到一个错误:

ssh://root@46.101.172.134:22null /usr/bin/php
env: /var/www/Lumen: Permission denied

Process finished with exit code 126

另请检查 this question 以获取有关此错误的更多信息..


编辑 2:

我尝试将我的服务器更改为..

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    listen 443 ssl;
    
    root /var/www/lumen/public;
    index index.php index.html index.htm;

    server_name IPAddress;
    ssl_certificate /etc/nginx/ssl/nginx.crt;    // I didn't set this
    ssl_certificate_key /etc/nginx/ssl/nginx.key;  //  and this

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

我用 this guide to create an SSL Certificate on nginx. Then, hitting http://ipaddress 给了我 Lumen/Laravel 东西。