Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
109 views
in Technique[技术] by (71.8m points)

html - Nginx does not display images on the page

I would need your help.

I have created web page, which I would like to run on subdomain (e.g. subdomain.example.com). I am using nginx server. For now everythiing works fine, only images (png) e.g. logos and favicon does not display on page. All files are stored in /var/www/app/static.

Here is my nginx app.conf file stored in /etc/nginx/conf.d

server {
listen      80;
server_name subdomain.example.com;

root /var/www/app/;
index index.php index.html index.htm;
charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location /static {
    root /var/www/app/static;

}

error_page 404 /index.php;

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

location ~ .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

}

And here is part of index.php code, where image is refering.

<img src="static/image.png" class="center" alt="logo" style="max-width:100%;height:auto;"/>

I tried to change part <img src="static/image.png" .., on a hundred ways, but unfortunately image does not appear.

Please help me, this debugging really frustrating me.

TIA.

question from:https://stackoverflow.com/questions/65893986/nginx-does-not-display-images-on-the-page

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...