0

images are loading sometimes but icon and default images icons not displayed , im beginner how to fix this issue it drives me crazy, there is no config files in etc/nginx/conf.d only my main nginx config file in my server which found here etc/nginx/nginx.config i hope somone can help me please

my config file

    user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    client_max_body_size 50M;

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


    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
        server {
        server_name xxx.com www.xxx.com;
        listen serverip;
        root /home/xxx/public_html;
        index index.html index.htm index.php;
        access_log /var/log/virtualmin/xxx_access_log;
        error_log /var/log/virtualmin/xxx_error_log;
        fastcgi_param GATEWAY_INTERFACE CGI/1.1;
        fastcgi_param SERVER_SOFTWARE nginx;
        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_param SCRIPT_FILENAME /home/xxx/public_html$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param REQUEST_URI $request_uri;
        fastcgi_param DOCUMENT_URI $document_uri;
        fastcgi_param DOCUMENT_ROOT /home/xxx/public_html;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param REMOTE_ADDR $remote_addr;
        fastcgi_param REMOTE_PORT $remote_port;
        fastcgi_param SERVER_ADDR $server_addr;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param HTTPS $https;
        location / {
         try_files $uri $uri/ /index.php?$args;
            index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
            fastcgi_index index.php;
            include fastcgi.conf;
            include fastcgi_params;

            fastcgi_pass unix:/var/php-nginx/xxx.sock/socket;

        }
        listen serverip default ssl;
        ssl_certificate /home/xxx/ssl.cert;
        ssl_certificate_key /home/xxx/ssl.key;
    }
}

i appreciate any help

1 Answer 1

1

You have one location that sends all requests to PHP. You are not serving static files (such as js/css) with Nginx.

The usual PHP configuration contains two location blocks. One to process URIs which end with .php and one to process everything else as a static file.

For example:

location / {
    try_files $uri $uri/ /index.php?$args;
    index index.php index.cgi index.pl index.html index.xhtml index.htm index.shtml;
}
location ~ \.php$ {
    try_files $uri =404;

    include fastcgi.conf;
    include fastcgi_params;

    fastcgi_pass unix:/var/php-nginx/xxx.sock/socket;
}
Sign up to request clarification or add additional context in comments.

3 Comments

thank you so much for the info, when i put location ~ \.php$ { , its says No input file specified on my website, any idea ?
No input file specified usually means that SCRIPT_FILENAME isn't set correctly. My changes shouldn't have materially changed your working PHP configuration, which is why I didn't look too closely at the contents of your include files.
what do you suggest me to do?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.