gpt4 book ai didi

css - nginx 不提供 css/js 图像

转载 作者:行者123 更新时间:2023-12-04 19:36:15 26 4
gpt4 key购买 nike

有时会加载图像,但未显示图标和默认图像图标,我是初学者如何解决此问题,这让我发疯,etc/nginx/conf.d 中没有配置文件,只有我的服务器中的主要 nginx 配置文件在这里找到etc/nginx/nginx.config 我希望有人能帮助我

我的配置文件

    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;
}
}

我感谢任何帮助

最佳答案

你有一个 location将所有请求发送到 PHP。您没有使用 Nginx 提供静态文件(例如 js/css)。

通常的 PHP 配置包含两个 location block 。一种处理以 .php 结尾的 URI一个将其他所有内容作为静态文件处理。

例如:

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;
}

关于css - nginx 不提供 css/js 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60166365/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com