简体   繁体   中英

Nginx php5.6 fpm show blank page

I want to run node along with php on domain.com/api. My nginx configuration is as below

server {
    listen       80;
    server_name  domain.com;
    return       301 http://domain.com$request_uri;
}
server {
    listen 80;
    server_name domain.com;
    location / {
        proxy_pass  http://domain.com:8080;
        proxy_redirect off;
        proxy_set_header        X-Forwarded-For $remote_addr;
        location ~* \.(html|css|jpg|gif|ico|js)$ {
                proxy_cache          cache;
                proxy_cache_key      $host$uri$is_args$args;
                proxy_cache_valid    200 301 302 30m;
                expires              30m;
                proxy_pass  http://domain.com:8080;
        }
    }
    location ^~ /api {
        alias /var/www/html/testphp/api;
        try_files $uri $uri/ @api;
        location ~* \.php {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/run/php/php5.6-fpm.sock;
            fastcgi_index index.php;
        }
    }
    location @api {
        rewrite ^/api/(.*)$ /api/index.php/$1 last;
    }
}

But when I run file domain.com/api/test.php it gives blank page? How to solve this

I got this configuration working fully. I am running code-igniter, its working correctly.

server {
listen 80;
server_name www.domain.com;
root /var/www/html/testphp/api;
location / {
    proxy_pass  http://www.domain.com:8080;
    proxy_redirect off;
    proxy_set_header        X-Forwarded-For $remote_addr;
    location ~* \.(html|css|jpg|gif|ico|js)$ {
        proxy_cache          cache;
        proxy_cache_key      $host$uri$is_args$args;
        proxy_cache_valid    200 301 302 30m;
        expires              30m;
        proxy_pass  http://www.domain.com:8080;
    }
}

location  /api/ {
alias /var/www/html/testphp/api/;
try_files $uri $uri/ /api/index.php;
location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_index index.php;
    fastcgi_pass unix:/run/php/php5.6-fpm.sock;
    fastcgi_param   SCRIPT_FILENAME $request_filename;
    }
}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM