dtpwra8456 2014-09-06 11:19
浏览 141
已采纳

NGINX- PHP下载index.php而不是执行它

I try to set up my mangeto website with nginx but I don't succeed to do it. I followed this tutorial : http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

Here my configuration :

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

I can access to mydomainname.com but when I tried to launch an install of magento in subfolder mydomainname.com/dev/ it's not working. My webbrowser download the php file instead of execute it. And when I changed root with /var/www/mydomainname/web/dev/ it's working. Do you see why?

  • 写回答

2条回答 默认 最新

  • dongmen9517 2014-09-06 17:52
    关注

    My first problem was an error 502 and after some tests I had the issue expalined above. When I restart my browser it was ok and I succeed to correct the error 502, with a configuration file of php-fpm ! A tutorial here : http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm !

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置