undefinedfix
Sign in

How can nginx configure a route that can access ThinkPHP?

nasa edited in Sun, 29 May 2022

The local environment I use is: upupw is now configured, but there is an access error, saying that the file cannot be found, and a 404 error is reported. How to configure nginx?

The address is as follows: http://localhost/index.php/ne... So you can visit the middle of what I want index.php Get rid of, but the setting nginx has been invalid, pseudo static settings also according to other people's get, is useless, do a afternoon.

2 Replies
notous
commented on Sun, 29 May 2022
location ~ \.php {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    set $real_script_name $fastcgi_script_name;                                                                                                                                                                                                                       
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {                                                                                                                                                                                                             
        set $real_script_name $1;
        #set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; 
    fastcgi_param SCRIPT_NAME $real_script_name;
    #fastcgi_param PATH_INFO $path_info;
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
    }
}
obidano
commented on Sun, 29 May 2022

Add location / in nginx server{

 try_files $uri $uri/ /index.php?$query_string;

}Rewrite the URL. After writing, restart nginx and pay attention to the port number.

lock This question has been locked and the reply function has been disabled.