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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…