cameron1
By:
cameron1

Wordpress & NGINX = 403

February 1, 2014 18.1k views
Hello, I started a fresh install this morning with no control panel. I am now using command line only. So i followed below links to install NGINX on Cent Os and also to create 2 virtual hosts: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-6 https://www.digitalocean.com/community/articles/how-to-set-up-nginx-virtual-hosts-server-blocks-on-centos-6 Then i set up a database for wordpress site. Changed the WP config files for database setting. Went to access site to setup wordpress and am greeted with 403 Forbidden. So then i checked my NGINX logs and this is what it comes up with: 2014/02/01 12:12:33 [error] 2010#0: *12 directory index of "/var/www/broombanklandrovers.com/public_html/" is forbidden, client: 'MYIPADDRESS', server: 'MYDOMAIN.COM', request: "GET / HTTP/1.1", host: '"MYDOMAIN.COM"' Does anyone know why i am getting 403 ?
7 Answers
directory index of "/var/www/broombanklandrovers.com/public_html/" is forbidden,

There it is. That's the error. It says that the directory index of that directory is forbidden, which means that nginx doesn't have any index files to serve. What's the output of ls /var/www/broombanklandrovers.com/public_html/? Can you pastebin the whole virtualhost too?
This is the output :
index.php wp-blog-header.php wp-includes wp-settings.php
license.txt wp-comments-post.php wp-links-opml.php wp-signup.php
readme.html wp-config.php wp-load.php wp-trackback.php
wp-activate.php wp-content wp-login.php xmlrpc.php
wp-admin wp-cron.php

and virtual host is:

#
# A virtual host using mix of IP-, name-, and port-based configuration
#

server {
listen 80;
# listen *:80;
server_name broombanklandrovers.com;

location / {
root /var/www/broombanklandrovers.com/public_html/;
index index.php index.html index.htm;
}
}

server {
listen 80;
# listen *:80;
server_name broombankoffroadadventures.com;

location / {
root /var/www/broombankoffroadadventures.com/public_html/;
index index.php index.html index.htm;
}
}
Anyone got any ideas of what i can do next ?
@Kamal?
Have now started afresh with a new droplet and still came across the same problem. I should have also mentioned that it seems to download a file when i go to the domain.
You need to tell nginx how to process php files. Add this to your server block(s):
location ~ \.php$ {

try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
@Kamal, Still doesnt seem to work :/
This is my whole virtual.conf file at the minute, havnt made a second block untill i get first one working:

server {
listen 80;
# listen *:80;
server_name broombanklandrovers.com www.broombanklandrovers.com;

location / {
root /var/www/broombanklandrovers.com/public_html/;
index index.php index.html index.htm;
}

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}
}
From what i can tell here - http://codex.wordpress.org/Nginx - there seems to be a lot more to getting wordpress set up with NGINX than meets the eye. Maybe i am just reading it wrong?
Also it says that NGINX wont improve performance much
Have another answer? Share your knowledge.