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

I'm trying to setup a cakephp development enviroment with nginx. The nginx + php was successful instaled since I get the right response from phpinfo(); But when I try to setup a virtual host located inside my home dir the nginx returns 404 response.

Take a look at virtual host conf:

server {
  listen 80;
  server_name www.camisa10_cake.com;

  rewrite ^/(.*) http://camisa10_cake.com/$1 permanent;
}

server {
      listen 80;
      server_name camisa10_cake.com;

      location / {
              root   /home/pedro/dev/pessoais/camisa10_cake;
              index  index.php index.html index.htm;

          # this code is to make pretty url, cakephp needs.
          if (!-e $request_filename) {
            rewrite ^/(.+)$ /index.php?url=$1 last;
        break;
          }

    }

      location ~ \.php$ {
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME   /home/pedro/dev/pessoais/camisa10_cake$fastcgi_script_name;
              include        fastcgi_params;
      }
  }

Like you can see, my app is located at /home/pedro/dev/pessoais/camisa10_cake/. The response that I get look likes:

"GET / HTTP/1.1" 404 31 "-" "Mozilla/5.0 (Ubuntu; X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0"

I think that would be a permission issue inside my home dir, but I didn't have find it out.

share|improve this question
    
There is a good chance that nginx really can't find the file (i.e. it is looking in the wrong place). Firstly, set your root outside the location blocks (i.e. the line below server_name - FastCGI needs this to work properly. If the problem persists, increase the verbosity of your error_log (possibly to 'info') and turn on fastcgi_intercept_errors. –  cyberx86 Dec 26 '11 at 17:07
    
Just to make sure it has nothing to do with permissions, can you cat the file when logged in as the user nginx runs as? –  minaev Dec 27 '11 at 9:50
    
cyberx86, thank you for your comment. Just adding the server_name outside the location block solved the issue. –  Pedro Fernandes Steimbruch Dec 27 '11 at 15:14
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.