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

标签 php laravel ubuntu nginx lumen

我正在尝试在 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在 nginx 上创建 SSL 证书。然后,点击 http://ipaddress给了我 Lumen/Laravel 的东西。

关于php - 通过浏览器访问 IP 地址时,在 nginx 上创建新的 Lumen 应用程序会抛出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35779743/

相关文章:

php - 安装 laravel ( sh : 1: composer: not found) error

laravel - 按关系值对集合进行排序

php - 如何在除一个子页面之外的每个子页面上显示一些 html?

Dockerfile : How to set apt mirror based on the ubuntu release

linux - 为什么 apt-get purge 几乎删除了我的整个 ubuntu?

PHP - 完整显示远程页面的内容

php - mysqli_multi_query 命令不同步错误 - 未插入数据库

php - 从另一个站点重定向后如何获取上一页 url?

php - 在搜索引擎上索引多语言网站

c++ - 如何在 Ubuntu 12.0.4 上安装 GCC 2.95?