서버에서 가끔 500 에러를 뱉어내는데 오류 로그를 살펴보면 다음과 같습니다.

 

1. 오류로그

2017/03/06 02:12:22 [error] 7027#7027: *1760 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Cannot declare class sitemap, because the name is already in use in /home/eond/www/widgets/sitemap/sitemap.class.php on line 0" while reading response header from upstream, client: 119.18.108.21, server: eond.com, request: "GET /tip/19250 HTTP/1.1", upstream: "fastcgi://unix:/run/php/eond.sock:", host: "eond.com", referrer: "http://eond.com/tip/19280"

sitemap 위젯을 사용하는데, 

 

https://www.lesstif.com/pages/viewpage.action?pageId=24444977

위 링크에서 말하길 잘못된 upstream 설정 때문이라고 하는데,

 

늘 그런게 아니라 가끔 어쩌다가 500 에러를 뿜어대서-.-;

원래 에러가 가끔 발생하기도 하는 건가요?

 

2. /etc/nginx/conf.d/eond.com.conf

server {
    listen       80;
    server_name  eond.com www.eond.com xe.eond.com is.eond.com;
    root   /home/eond/www;
 
    access_log /var/log/nginx/eond.com.access.log;
    error_log  /var/log/nginx/eond.com.error.log warn;

    location / {
        index  index.php index.html;
    }

    # Allow Lets Encrypt Domain Validation Program
    location ^~ /.well-known/acme-challenge/ {
        allow all;
    }
 
    # Block dot file (.htaccess .htpasswd .svn .git .env and so on.)
    location ~ /\. {
        deny all;
    }
 
    # Block (log file, binary, certificate, shell script, sql dump file) access.
    location ~* \.(log|binary|pem|enc|crt|conf|cnf|sql|sh|key)$ {
        deny all;
    }
 
    # Block access
    location ~* (composer\.json|contributing\.md|license\.txt|readme\.rst|readme\.md|readme\.txt|copyright|artisan|gulpfile\.js|package\.json|phpunit\.xml)$ {
        deny all;
    }
 
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }
 
    location = /robots.txt {
        log_not_found off;
        access_log off;
    }
 
    # Block .php file inside upload folder. uploads(wp), files(drupal, xe), data(gnuboard).
    location ~* /(?:uploads|data)/.*\.php$ {
        deny all;
    }

    # Add PHP handler
    location ~ [^/]\.(php|html|htm)(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        fastcgi_pass unix:/run/php/eond.sock;
        fastcgi_index index.php;
        include fastcgi_params;

        try_files $uri =404;

    }

    # mod_rewrite
    include /etc/nginx/xe_rewrite.conf;
}

3. /etc/nginx/fastcgi_parm

fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;
 
fastcgi_param   SCRIPT_FILENAME         $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME             $fastcgi_script_name;
fastcgi_param   PATH_INFO               $fastcgi_path_info;
fastcgi_param   PATH_TRANSLATED         $document_root$fastcgi_path_info;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;
 
fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
 
fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;
 
fastcgi_param   HTTPS                   $https;
 
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param   REDIRECT_STATUS         200;

 

  • Lv36

    "사이트맵" 모듈과 "사이트맵" 위젯을 함께 사용하는 바람에 클래스명이 같아서 충돌하는 것으로 보입니다.

    에러메시지에 답이 있습니다. nginx 설정과는 상관없습니다.

  • Lv36 Lv15
    감사합니다. ㅠㅠ;