Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to run a CakePHP app from within a subfolder on Nginx, but the static files are not being found and are instead being passed to the app controller. Here's my current config:

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

        if (-f $request_filename) {
            break;
        }

        if (!-e $request_filename) {
            rewrite ^/uniquetv(.+)$ /uniquetv/webroot/$1 last;
            break;
        }
    }                                        

    location /uniquetv/webroot {
        index index.php;

        if (!-e $request_filename) {
            rewrite ^/uniquetv/webroot/(.+)$ /uniquetv/webroot/index.php?url=$1 last;
            break;
        }
    }

Any ideas? :)

share|improve this question

1 Answer 1

Throlkim, what exactly is being displayed when you browse to the url you want to use? ie are you getting a 504 error message etc

you need to have something similar to this which works for me

server {

    listen   80;
    server_name  yourwebsite.com;

    access_log /path_to_your_logfile/log/access.log;
    error_log /path_to_your_logfile/log/error.log;

    location / {

        root /path_to_cake_root/cake/app/webroot;
        index index.php;

        if (-f $request_filename) {
            break;
        }
        if (!-f $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
            break;
        }

        #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME /path_to_cake_root/cake/app/webroot/index.php;
            #$fastcgi_script_name;
            include        /etc/nginx/fastcgi_params;
        }
    }
}

I asked a similar question which was resolved as per accepted answer and a bit of tweeking cakephp & nginx config/rewrite rules

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.