OneinStack中LNMP环境给Nginx开启pathinfo

项目上服务器,写ajax的时候路径写成index.php/home/Login/Index这种形式的了(用的Thinkphp框架),环境用Nginx没开pathinfo,无法正常访问.

找到你的虚拟站点的Nginx的配置文件(一般在/usr/local/nginx/conf/vhost 下面可以找到)
打开之后:

server {
  listen 80;
  server_name ct.dcmagcn.com;
  access_log off;
  index index.html index.htm index.php;
  include /usr/local/nginx/conf/rewrite/thinkphp.conf;
  root /data/wwwroot/ct.dcmagcn.com;
  error_page 404 = /404.html;
  error_page 502 = /502.html;


  location ~ \.php {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    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;#去掉这一行的注释

把代码中的两行注释给去掉,重启一下Nginx就可以了,亲测可用.

你可能感兴趣的:(php,linux)