通过浏览器访问IP地址时,在Nginx上抛出404的情况下创建新的Lumen应用 [英] Creating new Lumen app on nginx throwing 404 when hiting IP Adress through browser

查看:392
本文介绍了通过浏览器访问IP地址时,在Nginx上抛出404的情况下创建新的Lumen应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Digital Ocean的ngnix服务器上创建一个普通的Lumen应用程序.遵循

I am trying to create a plain Lumen application on ngnix server on Digital Ocean. Following the official documentation for Laravel, I followed everything as it is said until the Laravel Installation bit.

仅此而已

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

我用过

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

当我使用ls时,Lumen文档现在出现在目录中.

The Lumen document seems on the directory now when I use ls.

但是,当我点击IP地址或IPAdress/index.php时,它会显示

However when I hit the IP address, or IPAdress/index.php, it shows

找不到404-nginx/1.4.6(Ubuntu)

404 Not Found - nginx/1.4.6 (Ubuntu)


这也是我对虚拟主机文件(nano /etc/nginx/sites-available/default)的配置:


Also, this is my configuration for Virtual Host file (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;
        }
}


我做错了什么或想念什么?


What am I doing wrong or missing?

此外,如果我尝试使用PhpStorm连接到SSH目录,则会收到错误消息:

Also, if I try connect to the SSH directory with PhpStorm, I received an error:

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

Process finished with exit code 126

还请检查此问题以获取有关此错误的更多信息..

Please also check this question for further info on this error..

我尝试将服务器更改为.

I tried changing my server to..

服务器{ 监听80 default_server; 听[::]:80 default_server ipv6only = on;

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;
}

}

推荐答案

我使用了 http://ipaddress 可以得到Lumen/Laravel的内容.

I used this guide to create an SSL Certificate on nginx. Then, hitting http://ipaddress gives me the Lumen/Laravel stuff.

这篇关于通过浏览器访问IP地址时,在Nginx上抛出404的情况下创建新的Lumen应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆