Nginx Showing Welcome Page instead of homepage

Posted July 2, 2019 34.3k views

Nginx shows welcome page, its picking up from


But not from:


In Directory:


2 Configurations Files:



default.conf file output

# Main Local

server {
        listen 80;
        server_name localhost;
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;

        location / {
                try_files $uri $uri/ =404;

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;

        location ~ \.php$ {
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;


virtual.conf file output:

server {

            listen   80;
            rewrite ^/(.*)$1 permanent;

            location / {

                        root   /home/nginx/domains/;
                        index  index.html;



nginx.conf file in /etc/nginx/nginx.conf output

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/;

events {
    worker_connections  1024;

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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;

All Directories with permissions.

ls -la /home/nginx/domains/

drwxr-s--- 6 root root 4096 Jul  1 12:54 .
drwxr-xr-x 3 root root 4096 Jul  2 14:44 ..
drwxr-s--- 2 root root 4096 Jun 30 15:58 backup
drwxr-s--- 2 root root 4096 Jun 30 15:58 log
drwxr-s--- 2 root root 4096 Jun 30 15:58 private
drwxr-sr-x 2 root root 4096 Jul  2 15:01 public

I have tried modifying default.php and virtual.conf file

Can Anyone can help me what’s wrong in this? I am really confused and have wasted a whole day on this.
I did reviewd other similar questions, google, etc.. but this seems weird.

  • I tried changing

    defaulttype application/octet-stream;
    type text/html;

  • Hello,

    Exactly, do not run your web servers as root. It’s better to change the permissions and the ownership of the files and folders at /home/nginx/domains/ to the nginx default user.

    You can do that with the chown command:

    chown -R your_nginx_user:your_nginx_user /home/nginx/domains/

    Hope that this helps!

  • I always get
    403 Forbidden

    On Changing user to nginx

    I did that to all the directories:

    sudo chown -R nginx:nginx /home/nginx/*
    sudo chown -R 0755 /home/nginx/*
    sudo chown -R nginx:nginx /home/nginx/domains/*
    sudo chown -R 0755 /home/nginx/domains/*
    sudo chown -R nginx:nginx /home/nginx/domains/*
    sudo chown -R 0755 /home/nginx/domains/*

    On tail

    tail -f /var/log/nginx/error.log

    2019/07/03 10:25:12 [error] 26313#26313: *3 "/home/nginx/domains/" is forbidden (13: Permission denied), client: 142.111.2xx.1xx, server:, request: "GET / HTTP/1.1", host: ""

    Checking /etc/passwd
    nginx:x:498:498:nginx user:/var/cache/nginx:/sbin/nologin

    Is something wrong in here?

  • I think that in this case it would be SELinux that’s causing the issue as you are running the website from /home rather than the default /var/www.

    Can you try running this command:

    setenforce permissive

    Let me know how it goes!

  • Show 4 more comments

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

This question was answered by @noors:


setenforce: SELinux is disabled
Still, its behaving same.


Bobby, I transferred all the domain files into


and changed .conf file root directory accordingly.

Now it is working fine.
Is there anything else, I can/should/must do?

Thanks for everything.

View the original comment