2017-02-24 80 views
0

我正嘗試建立HTTPS nginx的我的主機上,但得到一個錯誤:Nginx的HTTPS錯誤

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/conf.d/default.conf:7 
nginx: configuration file /etc/nginx/nginx.conf test failed 

CONF:

server { 
listen 443 ssl;    
       server_name quickseed.me; 
      ssl_certificate /etc/letsencrypt/live/quickseed.me/fullchain.pem; 
     ssl_certificate_key /etc/letsencrypt/live/quickseed.me/privkey.pem; 
} 
    root /var/www/html/; 
    index index.php index.html index.htm index.nginx-debian.html; 
location /phpmyadmin { 
    root /usr/share/; 
    index index.php; 
    try_files $uri $uri/ =404; 
    location ~ ^/phpmyadmin/(doc|sql|setup)/ { 
    deny all; 
    } 
    location ~ /phpmyadmin/(.+\.php)$ { 
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 

有誰知道如何解決這個問題的任何想法?

回答

0

你應該把位置放在服務器指令下。試試這個代碼。

server { 
     listen 443 ssl;    
     server_name quickseed.me; 
     ssl_certificate /etc/letsencrypt/live/quickseed.me/fullchain.pem; 
     ssl_certificate_key /etc/letsencrypt/live/quickseed.me/privkey.pem; 

     root /var/www/html/; 
     index index.php index.html index.htm index.nginx-debian.html; 
    location /phpmyadmin { 
    root /usr/share/; 
    index index.php; 
    try_files $uri $uri/ =404; 
    } 

    location ~ ^/phpmyadmin/(doc|sql|setup)/ { 
    deny all; 
    } 

    location ~ /phpmyadmin/(.+\.php)$ { 
    fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include fastcgi_params; 
    } 
} 

希望它有幫助。