首页 文章

让我们在LEMP Ubuntu 16.04上使用Nginx进行Laravel应用程序的Encypt

提问于
浏览
0

第一次来到这里(DigitalOcean,Laravel,Github等) . 提前抱歉我的无知 .

我已经成功地在我的Ubuntu 16.04 LEMP Droplet上部署了Marketplacekit app . 在尝试安装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的Encypt SSL证书(教程(1)的第6步) .

最初在执行第6步之后,我遇到了以下错误:

include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;

另一个用户具有与使用教程方法不存在的文件相同的错误 . 所以我尝试使用他们建议的these steps手动创建文件 .

似乎SSL工作正常,但 now I am getting 404 Not Found error.

这是我启用的配置文件:

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

1 回答

  • 0

    我想出了如何让它发挥作用 .

    • 删除/etc/nginx/snippets/ssl-example.com.conf

    • 删除/etc/nginx/snippets/ssl-params.conf

    • 删除/etc/ssl/certs/dhparam.pem

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

    Follow this tutorial instead

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

    server {
    
        # 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;
    
    
        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;
        #}
    
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    

    }

相关问题