我在nginx上build立了一个(以前使用apache)magento站点。 现在页面无法正确加载,并且外观目录正在生成错误。
从浏览器中,你可以在控制台中看到这个 – GET http://site/skin/frontend/custom/default/ 403 (Forbidden)
nginx错误日志有这个 – 2015/08/09 14:31:05 [error] 14873#0: *3 directory index of "/var/www/site.com/skin/frontend/custom/default/" is forbidden, client: IPADDRESS, server: site.com, request: "GET /skin/frontend/custom/default/ HTTP/1.1", host: "IPADDRESS", referrer: "http://site/page.html"
在访问日志中进一步详细介绍了这个目录下的实际文件。 例如。
[09/Aug/2015:15:08:25 -0400] "GET /skin/frontend/custom/default/js/lib/jquery-2.1.4.min.js HTTP/1.1" 200 34448 "http://178.62.18.57/index.php/page.html" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36"
访问日志具有相似的特定文件,如304 。
ls -l skin/frontend/custom/default/输出以下内容
drwxr-xr-x 3 www-data www-data 4096 Aug 9 08:33 css drwxr-xr-x 2 www-data www-data 4096 Aug 9 08:33 images drwxr-xr-x 4 www-data www-data 4096 Aug 9 08:33 js drwxr-xr-x 10 www-data www-data 4096 Aug 9 08:33 scss
纠正我,如果我错了,但不应该导致任何问题。 不pipe怎样,它和其他一切一样。
这是我的configuration如下:
server { listen 80; server_name site.com; root /var/www/site.com; index index.php index.html; access_log /var/log/nginx/site.com-access.log; error_log /var/log/nginx/site.com-error.log; location / { try_files $uri $uri/ @handler; expires 30d; } location /app/ { deny all; } location /includes/ { deny all; } location /lib/ { deny all; } location /media/downloadable/ { deny all; } location /pkginfo/ { deny all; } location /report/config.xml { deny all; } location /var/ { deny all; } location /var/export/ { auth_basic "Restricted"; auth_basic_user_file htpasswd; autoindex on; } location @handler { rewrite / /index.php; } location ~ .php/ { rewrite ^(.*.php)/ $1 last; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /lib/minify/ { allow all; } gzip on; #gzip_comp_level 9; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain application/xml text/css text/js application/x-javascript; }
我的nginx.conf是这样的
user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/x- javascript text/xml application/xml application/xml+rss text/javascript; ## # nginx-naxsi config ## # Uncomment it if you installed nginx-naxsi ## #include /etc/nginx/naxsi_core.rules; ## # nginx-passenger config ## # Uncomment it if you installed nginx-passenger ## #passenger_root /usr; #passenger_ruby /usr/bin/ruby; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #}
我现在不知道该怎么做。 如果有人可以发现一些事情,请让我知道。
看看官方的文档说:
Syntax: user user [group]; Default: user nobody nobody; Context: main Defines user and group credentials used by worker processes. If group is omitted, a group whose name equals that of user is used.
所以在你的情况下,用户应该被设置为:
user www-data; server { ... }