让我们为LEMP Ubuntu 16.04上的Nginx编写Laravel应用程序的Encypt

时间:2018-08-06 21:27:13

标签: php laravel ubuntu nginx lets-encrypt

第一次在这里进行所有操作(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;
            }
    }

2 个答案:

答案 0 :(得分:0)

我想出了使它工作的方法。

  1. 删除/etc/nginx/snippets/ssl-example.com.conf
  2. 删除/etc/nginx/snippets/ssl-params.conf
  3. 删除/etc/ssl/certs/dhparam.pem

按照本教程删除并重新创建启用nginx的配置文件并安装SSL。

https://build.intuit.com/services-config/pipeline-syntax/globals#env

配置文件如下所示,最后一部分是在安装证书时自动创建的。

println env.JOB_NAME

}

答案 1 :(得分:0)

通过提供免费的SSL,我们的加密就像小型初创公司和开发人员的教父一样。如果您在Ubuntu中使用nginx,则无需自己做任何事情。只需安装certbot进行加密,它将自动在启用站点的文件中进行所需的配置。如果您仍然遇到问题,那么我建议您阅读有关如何install let's encrypt on nginx进行拉拉瓦尔的教程