【问题标题】:Nginx doesn't server subfolder api application (php-fpm)Nginx 不提供子文件夹 api 应用程序 (php-fpm)
【发布时间】:2016-06-18 14:49:25
【问题描述】:

我的应用程序有以下文件夹结构

- css
- app
- js
- ...
- server (codeigniter)
  -- system
  -- application
  -- index.php
- index.html (angularJS app)

这是我的 nginx.conf

server {
        listen 80;
        listen [::]:80;

        root /var/www/html/myapp.com/public_html;

        index index.html;

        server_name myapp.com www.myapp.com;

        location / {
              index  index.html;
        }

        location /server/ {
                index /server/index.php;
                try_files $uri /server/index.php/$uri;
        }

        location /twitter/ {
                index /twitter/index.php;
                try_files $uri /twitter/index.php/$uri;
        }

        location ~ \.php {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                include fastcgi_params;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }

        #deny access to .htaccess files, if Apache's document root
        #concurs with nginx's one
        location ~ /\.ht {
               deny all;
        }
}

这是我不断遇到的错误

2016/03/04 18:26:02 [error] 4577#0: *4 FastCGI sent in stderr: "Unable to open primary script: /home/valor/development/myapp.com/public_html/server/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: myapp.com, request: "GET /server/api/users/isLoggedIn HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "myapp.com", referrer: "http://myapp.com/"
2016/03/04 18:26:02 [error] 4577#0: *3 FastCGI sent in stderr: "Unable to open primary script: /home/valor/development/myapp.com/public_html/server/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: myapp.com, request: "GET /server/api/categories HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "myapp.com", referrer: "http://myapp.com/"
2016/03/04 18:26:03 [error] 4577#0: *3 FastCGI sent in stderr: "Unable to open primary script: /home/valor/development/myapp.com/public_html/server/index.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: myapp.com, request: "GET /server/api/products/latest/16 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "myapp.com", referrer: "http://myapp.com/"

页面显示正确,我只能访问子文件夹中的 api 资源。 你能帮我解决我做错了什么吗? 如果您需要任何其他信息,请告诉我,我会提供

谢谢

【问题讨论】:

    标签: php angularjs codeigniter nginx


    【解决方案1】:

    基于用户@semm0 (link) 这可能是权限问题,可能由 AppArmor 引起。请查看this answer 以查看可能的解决方案。我不想窃取答案,因此链接到它。

    编辑:问题现在可能来自 php-fpm 配置。请使用您喜欢的编辑器打开/etc/php5/fpm/pool.d/www.conf,并取消注释以下行:

    listen.owner = www-data
    listen.group = www-data
    listen.mode = 0660
    

    别忘了重启 php 服务器:

    service php5-fpm restart
    

    【讨论】:

      猜你喜欢
      • 2016-09-29
      • 1970-01-01
      • 2021-01-17
      • 2020-10-15
      • 1970-01-01
      • 2014-08-04
      • 2019-01-28
      • 2020-06-10
      • 1970-01-01
      相关资源
      最近更新 更多