nginx + php-fpm - index.php下载但直接访问时可以正常工作

时间:2014-05-30 20:08:51

标签: nginx php

我正在尝试将PHPIPAM与Nginx而不是Apache一起使用。但是,当我访问ipam.website.com时,它会提示我下载index.php。如果我直接进入ipam.website.com/index.php它处理正常,网站的其余部分工作正常。我的配置中缺少什么?

server {
        listen 80;
        root /srv/webapps/phpipam/;
        server_name ipam.website.com;
        index index.php;

        access_log /srv/webapps/phpipam/log/phpipam_access.log;
        error_log /srv/webapps/phpipam/log/phpipam_error.log;

        location / {
              rewrite ^/error/(.*)/$ /index.php?page=error&eid=$1 last;
              rewrite ^/login$ /login/ redirect;
              rewrite ^/login/$ /index.php?page=login;
              rewrite ^/logout$ /logout/ redirect;
              rewrite ^/logout/$ /index.php?page=logout;
              rewrite ^/request_ip$ /request_ip/ redirect;
              rewrite ^/request_ip/$ /index.php?page=request_ip;
              rewrite ^/login/dashboard/$ /dashboard/ redirect;
              rewrite ^/logout/dashboard/$ /dashboard/ redirect;
              rewrite ^/upgrade$ /upgrade/ redirect;
              rewrite ^/upgrade/$ /index.php?page=upgrade;
              rewrite ^/install$ /install/ redirect;
              rewrite ^/install/$ /index.php?page=install;
              rewrite ^/dashboard/$ /index.php?page=dashboard;
              rewrite ^/widgets/(.*)/$ /index.php?page=widgets&subpage=$1;
              rewrite ^/subnets/(.*)/(.*)/ipdetails/(.*)/$ /index.php?page=subnets&section=$1&subnetId=$2&ipaddrid=$3 last;
              rewrite ^/subnets/(.*)/(.*)/changelog/$ /index.php?page=subnets&section=$1&subnetId=$2&sPage=changelog last;
              rewrite ^/subnets/(.*)/(.*)/(.*)/$ /index.php?page=subnets&section=$1&subnetId=$2&sPage=$3 last;
              rewrite ^/subnets/(.*)/(.*)/$ /index.php?page=subnets&section=$1&subnetId=$2 last;
              rewrite ^/subnets/(.*)/$ /index.php?page=subnets&section=$1 last;
              rewrite ^/folder/(.*)/(.*)/$ /index.php?page=folder&section=$1&subnetId=$2 last;
              rewrite ^/folder/(.*)/$ /index.php?page=folder&section=$1 last;
              rewrite ^/vlan/(.*)/(.*)/$ /index.php?page=vlan&section=$1&vlanId=$2 last;
              rewrite ^/vrf/(.*)/(.*)/$ /index.php?page=vrf&section=$1&vrfId=$2 last;
              rewrite ^/tools/changelog/(.*)/(.*)/$ /index.php?page=tools&toolsId=changelog&cfilter=$1&climit=$2 last;
              rewrite ^/tools/changelog/(.*)/$ /index.php?page=tools&toolsId=changelog&climit=$1 last;
              rewrite ^/tools/search/(.*)$ /index.php?page=tools&toolsId=search&ip=$1 last;
              rewrite ^/tools/devices/hosts/(.*)$ /index.php?page=tools&toolsId=devices&deviceid=$1 last;
              rewrite ^/tools/(.*)/$ /index.php?page=tools&toolsId=$1 last;
              rewrite ^/tools/$ /index.php?page=tools&toolsId=showAll last;
              rewrite ^/administration/manageSection/sectionChangelog/(.*)/$ /index.php?page=administration&adminId=sectionChangelog&sectionId=$1 last;
              rewrite ^/administration/(.*)/$ /index.php?page=administration&adminId=$1 last;
              rewrite ^/administration/$ /index.php?page=administration&adminId=showAll;
        }

        location ~ \.php$ {
                  try_files $uri =404;
                  fastcgi_split_path_info ^(.+\.php)(/.+)$;
                  # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                  # With php5-cgi alone:
                  #fastcgi_pass 127.0.0.1:9000;
                  # With php5-fpm:
                  fastcgi_pass unix:/var/run/php5-fpm.sock;
                  fastcgi_index index.php;
                  include fastcgi_params;
          }

  }

1 个答案:

答案 0 :(得分:0)

事实证明这只是一个浏览器问题,在我清除缓存等之后它运行正常。该死..