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_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 ?

  • Is there anything in nginx's error log?
    – mgorven
    Commented Apr 23, 2012 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:, server: localhost, request: "GET / HTTP/1.1", host: "image-to-html.net"
    – Axiol
    Commented Apr 23, 2012 at 8:09

2 Answers 2


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

  location ~ \.php$ {


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.

  • Edited it, restarted Nginx but I still got the 403.
    – Axiol
    Commented Apr 23, 2012 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
    Commented Apr 23, 2012 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
    Commented Apr 23, 2012 at 10:12
  • Not sure if you're notified when I edit, but added that to the answer
    – Sašo
    Commented Apr 23, 2012 at 10:21
  • Oh sorry missed it... Thanks, it solved the problem :)
    – Axiol
    Commented Apr 23, 2012 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
  • 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
    Commented Apr 23, 2012 at 8:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .