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've just got a new server and want to try some other things. Like Nginx instead of Apache.

So, installed nginx, got the Welcome page, installed php5-fpm and download a Wordpress to give a try.

But, I still got a 403 Forbidden when I try to go to the address...

Here is the conf file :

server {
  listen   80;
  server_name  localhost;
  access_log  /var/log/nginx/axiol.access.log;
  error_log  /var/log/nginx/axiol.error.log error;

  root  /usr/share/nginx/axiol;

  location ~ .php$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/axiol$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
    fastcgi_intercept_errors        on;
    fastcgi_ignore_client_abort     off;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
  }

  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  try_files $uri $uri/ /index.php?$args;
}

I already checked the chmod of the axiol folder.

Any idea ?

share|improve this question
    
Is there anything in nginx's error log? –  mgorven Apr 23 '12 at 4:39
    
Yep, always the same : 2012/04/23 09:31:37 [error] 4834#0: *42 directory index of "/usr/share/nginx/axiol/" is forbidden, client: 220.181.108.96, server: localhost, request: "GET / HTTP/1.1", host: "image-to-html.net" –  Axiol Apr 23 '12 at 8:09

2 Answers 2

up vote 6 down vote accepted

You've made a mistake in php location. You need to escape . since it's otherwise used in regex.

  location ~ \.php$ {

Edit:

You should also add the following under server:

    index  index.html index.htm index.php;

That is required to automatically pass the index.php (if index.html and index.htm don't exist) if no file is specified.

share|improve this answer
    
Edited it, restarted Nginx but I still got the 403. –  Axiol Apr 23 '12 at 9:28
    
Well at least that was solved before it became a problem. If you try to access a non-php file, does it give the same error? Additionally, could you check under which user php5-fpm and nginx are running? –  Sašo Apr 23 '12 at 9:37
    
I've just noticed something while testing another file : if I go to http://myIP/ I got a 403, but, if I do http://myIP/index.php it works well :/ –  Axiol Apr 23 '12 at 10:12
    
Not sure if you're notified when I edit, but added that to the answer –  Sašo Apr 23 '12 at 10:21
    
Oh sorry missed it... Thanks, it solved the problem :) –  Axiol Apr 23 '12 at 10:25

Check to see what user and group the service is running as and make sure it has read on files and execute on the directories for the nginx folder and everything below it.

You can check to see what user the nginx service is running by executing this command and looking at the first column:

ps aux | grep nginx 

(These are very strict permissions, but secure)

find /usr/share/nginx/ -type f | xargs chmod 444
find /usr/share/nginx/ -type d | xargs chmod 555
share|improve this answer
    
It gives me this : root 3626 0.0 0.0 3840 732 pts/0 S+ 10:10 0:00 grep nginx root 4833 0.0 0.0 4952 672 ? Ss Apr22 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 4834 0.0 0.0 5304 1604 ? S Apr22 0:00 nginx: worker process –  Axiol Apr 23 '12 at 8:12

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.