0

I have following folder structure for my application, located in map /home/valor/development/mypp.com/public_html/

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

this is my nginx.conf

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

        root /home/valor/development/euro-swap.com/public_html;

        index index.html;

        server_name euro-swap.com www.euro-swap.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/"

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

Thank you

Valor_
  • 125
  • 1
  • 8

1 Answers1

1

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.

EDIT: 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

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

service php5-fpm restart
semm0
  • 248
  • 1
  • 6
  • now i have another problem "/var/www/html/myapp.com/public_html/index.html" is forbidden (13: Permission denied), I added 644 premision on files and 755 premison on folders, also i have change ownership to www-data, etc – Valor_ Mar 04 '16 at 21:58
  • edited my answer. now we see that it can connect but nginx / upstream receives a permission denied as lack of rights. the edit in my answer should solve it. – semm0 Mar 04 '16 at 22:09