2

I've just got a new server in DigitalOcean and want to try some other things. I want to start a wordpress site so I follow the first 1-3 steps from here: https://deliciousbrains.com/hosting-wordpress-yourself-nginx-php-mysql/. At first everything goes well and I did managed to get the wordpress installed. Unfortunately I am currently having 403 Forbidden on my site.

I am on Ubuntu 14.04 x64. I already stuck for quite sometimes and still have no ideas on whats going on. I even tried to remove the Nginx and reinstall, still the same.

Here is my conf file:

user sylvia;
worker_processes 1;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 15;
        types_hash_max_size 2048;
        # server_tokens off;
        client_max_body_size 64m;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 2;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

       server {
              listen 80 default_server;
               server_name _;
               return 444;
                    }

Any idea?

Tom
  • 10,886
  • 5
  • 39
  • 62
JennyElf
  • 21
  • 1
  • 2

5 Answers5

1

Most probably it is a permission issue. Give permission to www-data user to access your web root directory. Aur you can also give ownership.

chown -R www-data:www-data /path/to/your/directory
Tim
  • 30,383
  • 6
  • 47
  • 77
0

Forbidden means NGINX is not able to open the directory in which the files are stored.

The NGINX error_logs will give you the exact cause for the problem.

The logs are stored in /var/logs/nginx/error_log. Just open the file and go the the last lines and see what exact error your'e getting.

Ideally, doing a chmod 755 directory will solve the issue.

zealvora
  • 81
  • 1
  • 9
0

I had the a 403 problem as well, which was caused by the mode of directory.

I set the root directory under home,and the default mode for home directory is 600.

Then I found this article https://gist.github.com/jhjguxin/6208474 , and tried to change the root directory to 755, and the problem was solved.

So it seems that the default permissions on user home directories in Ubuntu 12.04 is 700.** Nginx needs to have read permission the files that should be served AND have execute permission in each of the parent directories along the path from the root to the served files.**

You can give your user directory these permissions by running

chmod 701 user_home

You may also use 755, which is the default permission setting on the home directory on many systems.

The directories/files in your web root can belong to the www-data user or your regular personal user as long as the user/group that nginx runs as (as defined in nginx.conf) has READ permission on all files to be served and execute permission on all web root directories.

Kuyo
  • 1
  • 1
0

This case is occur when you run Mamp with the Server Nginx and nginx server needed configuration of each working folder/directory. for the nginx configuration you can go in nginx.conf file on path

C:\MAMP\conf\nginx\nginx.conf

and write this script.

http {
    .....
    server {


    location ~* /test(.*)$ {
    root             C:/MAMP/htdocs/test;
        index            index.php;

        location ~ \.php$ {
            try_files        $uri =404;
            fastcgi_pass     127.0.0.1:9100;
            fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include          fastcgi_params;
        }
    }

  }
}

note: in this script test is my working directory. you can replace this name.

manish1706
  • 101
  • 2
0

If you're simply trying to list directory contents use autoindex on; like:

location /somedir {
       autoindex on;
}
Sukhjinder Singh
  • 1,944
  • 2
  • 8
  • 17