Configuration Nginx加载css/图像时出现问题
我已经配置了NGINX,现在它可以处理php和html文件。但它无法加载图像、*.js和*.css文件。这是我的NGINX配置文件 这是我的nginx.conf文件Configuration Nginx加载css/图像时出现问题,configuration,nginx,Configuration,Nginx,我已经配置了NGINX,现在它可以处理php和html文件。但它无法加载图像、*.js和*.css文件。这是我的NGINX配置文件 这是我的nginx.conf文件 user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
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;
}
以下是文件default.conf,可位于/etc/nginx/conf.d
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /home/username/www;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/username/www;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
## Images and static content is treated different
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires max;
root /home/username/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/username/www$fastcgi_script_name;
include fastcgi_params;
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_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
upstream backend {
server 127.0.0.1:9000;
}
谢谢!:) 希望它在
error.log
(顺便说一句,即使在我繁忙的服务器上,我也将其设置为notice
)中写入了一些内容。好的,当服务器尝试加载某些内容时,它会说(13:拒绝权限)
。这意味着,权限被拒绝。Nginx无法读取该文件,b/c它没有读取该文件的权限。它说的正是它所说的(惊喜)谢谢你,我已经弄明白了:)@AlexanderAzarov我没有得到任何我的日志。但是你的评论救了我!在过去的两个小时里,我一直在试图弄清楚为什么只加载图像而不加载js/css。因为它没有权限。非常感谢!