Nginx的不服务器的子文件夹API应用程序(PHP-FPM) [英] Nginx doesn't server subfolder api application (php-fpm)

查看:320
本文介绍了Nginx的不服务器的子文件夹API应用程序(PHP-FPM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have following folder structure for my application

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

这是我的nginx.conf

this is my 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;
        }
}

这是我是不断收到错误

And this is the error i'm keep getting

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资源。
你能家伙帮我我做错了什么?
如果您需要任何额外的信息是,请让我知道,我会提供

Page is displayed correctly i just can reach api resources in sub folder. Can you guy help me out what i'm doing wrong? If you need any additional information's please let me know and i will provide

感谢您

推荐答案

根据用户@ semm0(<一个href=\"http://serverfault.com/questions/761642/nginx-doesnt-server-subfolder-api-application-php-fpm\">link)
这的可能的是一个权限问题,可能通过的AppArmor引起的。请查看这个答案,了解可能的解决方案。我不想偷的答案,因此链接到它。

Based on user @semm0 (link) This might be a permission problem, possibly caused by AppArmor. Please review this answer to see possible solution. I don't want to steal the answer, therefore linking to it.

编辑:现在可能从PHP-FPM配置出现问题。请打开 /etc/php5/fpm/pool.d/www.conf 用你喜欢的编辑器,取消以下行:

the problem might now occur from the php-fpm configuration. Please open /etc/php5/fpm/pool.d/www.conf with your favorite editor and uncomment the following lines:

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

不要忘了重新启动PHP服务器:

and don't forget to restart the php server with:

service php5-fpm restart

这篇关于Nginx的不服务器的子文件夹API应用程序(PHP-FPM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆