【发布时间】:2019-01-13 21:35:50
【问题描述】:
第一次接触这里的一切(DigitalOcean、Laravel、Github 等)。提前为我的无知道歉。
我已经成功地在我的 Ubuntu 16.04 LEMP droplet 上部署了 Marketplacekit 应用程序。在尝试安装 SSL 之前,一切正常。
我一直在使用来自 DigitalOcean 的这些优秀教程的组合。
(1) How To Deploy a Laravel Application with Nginx on Ubuntu 16.04 (2) How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04
我目前正在尝试在我的域中安装 Let's Encypt SSL 证书(教程 (1) 的第 6 步)。
最初在执行第 6 步后出现以下错误:
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
另一个用户使用教程方法遇到了相同的错误,因为文件不存在。所以我尝试使用他们建议的these steps 手动创建文件。
似乎 SSL 工作正常,但 现在我收到 404 Not Found 错误。
这是我启用的配置文件:
sudo nano /etc/nginx/sites-enabled/example.com
--
server {
listen 80;
listen [::]:80;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html/marketplacekit/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
return 301 https://$server_name$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;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
root /var/www/html/quickstart/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
}
【问题讨论】:
-
您按照什么教程来安装 Let's Encrypt?这是我关注的:digitalocean.com/community/tutorials/… 你也可以查看这个:digitalocean.com/community/tutorials/…
-
我在您使用的那个上执行了步骤 1-3。然后跳到我链接的 (1) 教程中的第 6 步。
sudo certbot certonly --webroot --webroot-path=/var/www/html/marketplacekit/public -d example.com -d www.example.com -
您是否为您的域更改了
-d example.com -d www.example.com对吗? -
是的,当我访问该站点时,该站点是安全的,但它给出了 404。所以看起来 SSL 工作正常,只是配置不正确。
标签: php laravel ubuntu nginx lets-encrypt