【发布时间】: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