NGINX 某些子目录出现错误

NGINX 某些子目录出现错误

几天前我切换到了 NGINX,刚刚开始重新上传我的网页。除了一些子目录之外,几乎所有东西似乎都运行良好。我有一个论坛页面,当我尝试转到该页面时,它显示一条错误消息“HTTP ERROR 500”,我刚刚将之前使用 apache 的所有文件复制到了新文件夹中。

注意到 /forum 出现“HTTP ERROR 500”而 /img 出现 FORBIDDEN 错误,但这可能是其他原因。

站点可用的当前配置我确实在不同的配置文件中安装了翼手龙面板,但我不认为这很重要。


server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html index.php;

        server_name ****.com www.****.com localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                try_files $uri/ $uri /index.php?$query_string;
        }
location /phpmyadmin {
 auth_basic "Admin Login";
 auth_basic_user_file /etc/nginx/pma_pass;
 root /usr/share/;
 index index.php index.html index.htm;
 location ~ ^/phpmyadmin/(.+\.php)$ {
 try_files $uri =404;
 fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

}
 location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
 root /usr/share/;
 }
 }

        location ~ \.php$ {
               # try_files $uri =404;

                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include snippets/fastcgi-php.conf;
        #        include fastcgi_params;
        #        fastcgi_index index.php;

        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


答案1

问题解决了,nginx 试图提供页面索引,但不被允许。在 sites-available/ 中编辑默认值,现在它可以正常工作了。

相关内容