我嘗試用nginx設置我的mangeto網站,但我沒有成功做到這一點。我跟着這個教程:http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magentoNGINX- PHP下載index.php而不是執行它
這裏我的配置:
server {
listen 80;
server_name www.mydomainname.com *.mydomainname.com;
root /var/www/mydomainname/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
default_type application/octet-stream;
location/{
try_files $uri $uri/ /app.php?$query_string /index.php?$query_string;
}
location /dev {
auth_basic "Restricted Area";
auth_basic_user_file conf/htpasswd;
try_files $uri $uri/ /dev/index.php;
}
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/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite//index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
我可以訪問mydomainname.com但是當我試圖發動的Magento的子文件夾mydomainname.com/dev/它不工作安裝。我的webbrowser下載php文件而不是執行它。當我用/ var/www/mydomainname/web/dev /更改root時,它正在工作。 你明白爲什麼了嗎?