Nginx Environment thinkphp,500 Error

Source: Internet
Author: User
Tags phpinfo server error log codeigniter
today, the site to the Nginx under the CentOS environment, the program is thinkphp3.2, the home can be normal display, the chain is all 500 errors, paste the configuration code and error log, to solve the solution!!

Server {
    Listen 80;
    Server_name here the website domain name;
    Root /usr/local/www/web/go;
 
    Location / {
    Root /usr/local/www/web/go;
    Index index.php index.html index.htm;
        If (!-e $request_filename) {
        Rewrite ^(.*)$ /index.php/$1 last;
        Break;
    }
        Error_page 500 502 503 504 /50x.html;
        Location = /50x.html {
            Root /usr/share/nginx/html;
        }
       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        Location ~ .php$ {
        Root /usr/local/www/web/go;
            Fastcgi_pass 127.0.0.1:9000;
            Fastcgi_index index.php;
            # Define the variable $path_info to store pathinfo information
                Set $path_info "";
                # Define the variable $real_script_name to store the real address
                Set $real_script_name $fastcgi_script_name;
                #if the address matches the regular expression inside the quotes
                If ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                        # Assign the file address to the variable $real_script_name
                        Set $real_script_name $1;
                        # Assign the parameter after the file address to the variable $path_info
                        Set $path_info $2;
                }
                #Configure some parameters of fastcgi
                Fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                Fastcgi_param SCRIPT_NAME $real_script_name;
                Fastcgi_param PATH_INFO $path_info;
                #fastcgi_param SCRIPT_FILENAME /usr/local/www/web/go$fastcgi_script_name;
                Include fastcgi_params;
        }
     }    
}
Nginx log:

[Root@vm_161_64_centos nginx]# 29068#0: *41 rewrite or internal redirection cycle while processing "/index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php//index.php /home/user/register.html ", Client: Here IP, server: Here domain name, 

request:" Get/index.php/home:q



Reply to discussion (solution)


CodeIgniter under Nginx Configuration
should also apply thinkphp, you compare


server {
       listen  80;
       server_name     www.phpno.com;
       root /home/www/www_phpno_com/admin_wwwroot;
       access_log off;
       error_page 404  /404.html;
       location /404.html {
               root /home/www/www_phpno_com/admin_wwwroot;
       }
       location /{
               index index.html index.htm index.php;
               if (-e $request_filename) {
                       break;
               }
               if (!-e $request_filename) {
                       rewrite ^/(.*)$ /index.php/$1 last;
                       break;
               }
       }
  
       location ~ .+\.php($|/) {
           root           /home/www/www_phpno_com/admin_wwwroot;
           fastcgi_index index.php;
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param   PATH_INFO               $fastcgi_path_info;
           fastcgi_param   PATH_TRANSLATED $document_root$fastcgi_path_info;
           fastcgi_pass   127.0.0.1:9000;
       #    fastcgi_index  index.php;
       #    fastcgi_param  SCRIPT_FILENAME  /home/www/www_phpno_com/admin_wwwroot/$fastcgi_script_name;
       #    fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
           include        fastcgi_params;
       }
   }

CodeIgniter under Nginx Configuration

should also apply thinkphp, you compare
[Code=text]server {
Listen 80;
server_name domain name;
Root/usr/local/www/web/go;

Location/{
Index index.php index.html index.htm;
if (-e $request _filename) {
Break
}
if (!-e $request _filename) {
Rewrite ^/(. *) $/index.php/$1 last;
Break
}

Error_page 502 503 504/50x.html;

Location =/50x.html {
root/usr/share/nginx/html;
}

# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
Location ~. php$ {
Root/usr/local/www/web/go;
Fastcgi_index index.php;
Fastcgi_pass 127.0.0.1:9000;

#Configure some parameters of fastcgi

Fastcgi_split_path_info ^ (. +\.php) (. *) $;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Fastcgi_param path_info $fastcgi _path_info;
Fastcgi_param path_translated $document _root$fastcgi_path_info;
Include Fastcgi_params;
}
}
}


Change to this, or 500, need to change where?


It's a positive solution.
Your problem is pseudo-static problem, correct it,and it wil be OK.

Check the server error log

1, the confirmation is not the nginx photo. You can test it with a simple program.
2. Open the error display function of PHP to see if there is any error message output
3, the higher version of the Preg_replace_callback is said to have a serious memory leak problem, and thinkphp3.2 precisely to use



My homepage can show Ah, home is PHP program Ah, opened the right small corner of the debugging, click inside the chain, it is gone. is 500


It's a positive solution.
Your problem is pseudo-static problem, correct it ,and it will be OK.



Where's the point, I'm wrong?


Empty the Runtime directory and try Again
A 500 error indicates a problem with your program (but it may also be something else, but the first thing to check is your program)
You won't be able to turn on the error display, how do you know where the problem is?
Even if it is fortune-telling, do you want your birthday eight?


#rewrite ^ (. *) $/index.php/$1 last;

Rewrite ^/subdir/(. *) $/subdir/index.php/$1;

God, I changed this line. Now 500 becomes 404. = =


Empty the Runtime directory and try Again
A 500 error indicates a problem with your program (but it may also be something else, but the first thing to check is your program)
You won't be able to turn on the error display, how do you know where the problem is?
Even if it is fortune-telling, do you want your birthday eight?



Wait till I find out where PHP is loaded. = =

Phpinfo ()

Don't you see where the php.ini is?



error_reporting = E_error
Display_errors = On
Open these 2 and then service Nginx restart.
or output 404 Ah, no output error, I want to read the log? or restart PHP?


Phpinfo ()

Don't you see where the php.ini is?


[23-jul-2014 08:33:51] PHP notice:undefined index:script_name in/usr/local/www/erp/thinkphp/thinkphp.php on line 82
[23-jul-2014 09:06:15] PHP notice:undefined index:script_name in/usr/local/www/erp/thinkphp/thinkphp.php on line 82
[23-jul-2014 10:05:53] PHP notice:undefined index:script_name in/usr/local/www/erp/thinkphp/thinkphp.php on line 82
[23-jul-2014 10:09:42] PHP notice:undefined index:script_name in/usr/local/www/erp/thinkphp/thinkphp.php on line 82
[23-jul-2014 10:22:08] PHP warning:phpinfo (): It is not safe for rely on the system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected ' asia/chongqing ' for ' cst/8.0/no DST ' instead in/usr/local/www/web/dolanne/go/info.php on line 2
[23-jul-2014 10:28:04] PHP warning:phpinfo (): It is not safe for rely on the system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected ' asia/chongqing ' for ' cst/8.0/no DST ' instead in/usr/local/www/web/dolanne/go/info.php on line 2



PHP notice:undefined index:script_name in/usr/local/www/erp/thinkphp/thinkphp.php on line 82
$_server[' Script_name '] does not exist, do not know how they are tested!
At the beginning of the portal file
$_server[' script_name '] = $_server[' php_self '];

PHP warning:phpinfo (): It is not safe for rely on the system ' s timezone settings. You is *required* to use the Date.timezone setting or the Date_default_timezone_set () function. In case you used any of those methods and you is still getting this warning, your most likely misspelled the timezone Iden Tifier. We selected ' asia/chongqing ' for ' cst/8.0/no DST ' instead in/usr/local/www/web/dolanne/go/info.php on line 2
You don't have to set the time zone, just set it up with his prompt.



500 becomes 404
Not progress, but retrogression!
404 is unable to find the target page, obviously you rewrite the wrong place
500 is a problem with the program being executed and failed to return an error message. So Nginx sends 500 error, which means the application refuses to respond





500 becomes 404
Not progress, but retrogression!
404 is unable to find the target page, obviously you rewrite the wrong place
500 is a problem with the program being executed and failed to return an error message. So Nginx sends 500 error, which means the application refuses to respond


Okay, make it 500, and look at the log.



500 becomes 404
Not progress, but retrogression!
404 is unable to find the target page, obviously you rewrite the wrong place
500 is a problem with the program being executed and failed to return an error message. So Nginx sends 500 error, which means the application refuses to respond



Now back to post the state of the PHP log or those above, NIGNX log is posted on the 0 floor of those, swollen do



500 becomes 404
Not progress, but retrogression!
404 is unable to find the target page, obviously you rewrite the wrong place
500 is a problem with the program being executed and failed to return an error message. So Nginx sends 500 error, which means the application refuses to respond



Haha, I took care of it myself !
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.