部署Laravel 5.4-数字海洋-Nginx LEMP(16.04)

部署Laravel 5.4-数字海洋-Nginx LEMP(16.04),nginx,dns,laravel-5.4,digital-ocean,Nginx,Dns,Laravel 5.4,Digital Ocean,我正在digitalocean部署我的laravel项目,实际上我遇到了这样的情况: DNS记录-GODADDY digitalocean ip服务器104.131.16.82 DNS记录DIGITALOCEAN 服务器块已启用 我在“/etc/nginx/sites available/default”中启用了默认服务器块,并在“/etc/nginx/sites enabled/default”中创建了如下链接: server { listen 80 default_server;

我正在digitalocean部署我的laravel项目,实际上我遇到了这样的情况:

DNS记录-GODADDY

digitalocean ip服务器104.131.16.82

DNS记录DIGITALOCEAN

服务器块已启用

我在“/etc/nginx/sites available/default”中启用了默认服务器块,并在“/etc/nginx/sites enabled/default”中创建了如下链接:

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

    root /var/www/mysite-test.com/public;
        index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name localhost;
        return 301 $scheme://mysite-test.com$request_uri;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php?$query_string;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }
        location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php7-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
}
我按照本教程安装:

实际上,如果我去104.131.16.82下载一个文件,我不知道为什么,它不能很好地工作,也许我在服务器块中有错误?还是DNS记录?
谢谢你的帮助

如果您在数字海洋中使用一键式应用程序安装部署,您必须编辑“/etc/nginx/site available”目录中名为“数字海洋”的文件,而不是“默认”文件,以使更改生效。如果没有,默认的LEMP登录页将显示在那里

命令编辑主文件,在digital ocean中单击一次应用程序安装

sudo nano/etc/nginx/sites available/digitalocean

现在用以下代码替换文件的内容

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

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

        # Make site accessible from http://localhost/
        server_name <Your Domain name / Public IP Address>;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}
服务器{
监听80个默认_服务器;
侦听[:]:80默认_服务器ipv6only=on;
root/var/www/laravel/public;
index.php index.html index.htm;
#使站点可以从http://localhost/
服务器名称;
地点/{
#首先尝试将请求作为文件提供,然后
#作为目录,然后返回显示404。
try_files$uri$uri//index.php?$query_string;
#取消注释以在此位置启用naxsi
#include/etc/nginx/naxsi.rules
}
位置~\.php${
try_files$uri=404;
fastcgi\u split\u path\u info^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index.php;
fastcgi\参数脚本\文件名$document\根$fastcgi\脚本\名称;
包括fastcgi_参数;
}
}
服务器\u名称部分替换为您的 服务器IP或域名

我在下面的要点中可以找到进一步的参考

此语句将导致重定向到其他服务器:
return301$scheme://dixart.com$request_uri。它下面的
位置
块将不会被查询。dixart.com是我的网站,让我更新代码
返回301
将导致重定向循环。你应该移除它。