be-codified
be-codified

Reputation: 6144

Nginx - root folder

When I am accesing page at http://myIP I am seeing files in folder

var/www/html

instead of

var/www/html/src/public

I have set up following setting in /etc/nginx/sites-available/default:

root /var/www/html/src/public;
index index.html index.htm;

and also restarted nginx.

What could be wrong? Thank you in advance.

Upvotes: 2

Views: 8249

Answers (1)

Adam Birds
Adam Birds

Reputation: 434

You need to define your document root in:

/etc/nginx/nginx.conf

Or define it in your virtual host config file in:

/etc/nginx/conf.d/default.conf

Here is an example default.conf file setup:

server {
    listen       80;
    listen       443 ssl;

    ssl on;
    ssl_certificate     /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;

    server_name  adamsawesomewebsite.tk;
    root   /var/www/vhosts/adamsawesomewebsite.tk/httpdocs;
    index  index.php index.html;
    #charset koi8-r;
    #access_log  /var/log/nginx/access.log  main;

    # redirect server error pages to the static page /40x.html
    #
    #error_page  404              /404.html;
    #location = /40x.html {
    #}
    location / {
    try_files $uri $uri/ /index.php?q=$request_uri;
    }
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

Upvotes: 1

Related Questions