部署Laravel 5.4 - DigitalOcean - Nginx LEMP(16.04)

时间:2017-05-28 10:54:52

标签: nginx dns laravel-5.4 digital-ocean

我在digitalocean部署我的laravel项目,实际上我有这种情况:

DNS记录 - GODADDY

My domain in pointed to my IP of dig

digitalocean ip server 104.131.16.82

DNS记录DIGITALOCEAN

[1]: https://i.stack.imgur.com/Y7jiH.png

启用服务器阻止

我在" / 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记录? 谢谢您的帮助!

1 个答案:

答案 0 :(得分:0)

如果您使用数字海洋中的 ONE CLICK APP INSTALL 进行部署,则必须编辑名为" digitalocean 的文件&# 34; in" / etc / nginx / site-available"目录不是" 默认"文件以使更改生效。如果不是,则会显示默认的LEMP登录页面。

在数字海洋ONE CLICK APP INSTALL中编辑主文件的命令

  

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