Nginx-https错误
我正在尝试在主机上设置nginx HTTPS,但出现错误:Nginx-https错误,nginx,https,nginx-location,Nginx,Https,Nginx Location,我正在尝试在主机上设置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 形态: server { listen 443 ssl; server_
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
形态:
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;
有人知道如何解决这个问题吗?您应该将location放在服务器指令下。试试这个代码
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;
}
}
希望能有帮助