【问题标题】:Deployment Laravel 5.4 - DigitalOcean - Nginx LEMP (16.04)部署 Laravel 5.4 - DigitalOcean - Nginx LEMP (16.04)
【发布时间】:2017-05-28 10:54:52
【问题描述】:

我正在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;
        }
}

我按照本教程安装:https://gist.github.com/naveenyagati/5deec8fc40a2faaff20c629362dddf39

其实如果我去104.131.16.82下载一个文件,我不知道为什么,它不能正常工作,也许我的服务器块有错误?或 DNS 记录? 谢谢您的帮助!

【问题讨论】:

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

标签: nginx dns laravel-5.4 digital-ocean


【解决方案1】:

如果您在 Digital Ocean 中使用 ONE CLICK APP INSTALL 进行部署,则必须在“/etc”中编辑名为“digitalocean”的文件/nginx/site-available”目录而不是“default”文件以使更改生效。如果不是,默认的 LEMP 登录页面将在那里显示。

数字海洋中主文件编辑命令一键安装

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

server_name 部分替换为您的 服务器IP或域名

可以在我所做的以下要点中找到进一步的参考 https://gist.github.com/naveenyagati/5deec8fc40a2faaff20c629362dddf39

【讨论】:

    猜你喜欢
    • 2017-04-27
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 2017-09-02
    • 2014-10-19
    相关资源
    最近更新 更多