We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Permission Denied Error

Hi,

I am just trying to deploy my phalcon app to production and i faced the follow isses.

PHP message: PHP Warning:  Phalcon\Assets\Manager::output(production/home.js): failed to open stream: Permission denied in /usr/share/nginx/pple/app/views/index.phtml on line 45" while re$
2014/11/05 20:35:34 [crit] 32618#0: *4 stat() "/usr/share/nginx/pple/public/production/init.js" failed (13: Permission denied), client: 121.200.247.178, server: localhost, request: "GET /$
2014/11/05 20:35:34 [crit] 32618#0: *4 stat() "/usr/share/nginx/pple/public/production/init.js" failed (13: Permission denied), client: 121.200.247.178, server: localhost, request: "GET /$
2014/11/05 20:35:34 [crit] 32618#0: *1 stat() "/usr/share/nginx/pple/public/production/home.js" failed (13: Permission denied), client: 121.200.247.178, server: localhost, request: "GET /$
2014/11/05 20:35:34 [crit] 32618#0: *1 stat() "/usr/share/nginx/pple/public/production/home.js" failed (13: Permission denied), client: 121.200.247.178, server: localhost, request: "GET /$
2014/11/05 20:35:34 [error] 32618#0: *4 FastCGI sent in stderr: "PHP message: PHP Warning:  Phalcon\Assets\Manager::output(production/init.js): failed to open stream: Permission denied in $
2014/11/05 20:35:34 [error] 32618#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Phalcon\Assets\Manager::output(production/init.js): failed to open stream: Permission denied in $
2014/11/05 20:35:34 [error] 32618#0: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Phalcon\Assets\Manager::output(production/init.js): failed to open stream: Permission denied in $

This prevent my core javascript in phalcon from running and causes blank pages in my app.

Any assistance deeply appreciated.



58.4k

You must set permisson for it,for example

sudo chown -R nginx:nginx /usr/share/nginx/pple/
sudo chmod -R 777 /usr/share/nginx/pple/


27.8k
edited Nov '14

Hi Duy,

Thanks for the reply.

That's weird, initally i thought is the permission error, but doest seems so now. I set-ed the permission for it.

Now, my app index page is blank. I am not sure if i did anything wrong to the configuration.

This is my configuration

server {

    listen   80;
    server_name localhost;

    index index.php index.html index.htm;
    set $root_path '/usr/share/nginx/pple/public';
    root $root_path;

    try_files $uri $uri/ @rewrite;

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    location ~ \.php {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index /index.php;
        #fastcgi_pass 127.0.0.1:9000;
        include /etc/nginx/fastcgi_params;

        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
        root $root_path;
    }

    location ~ /\.ht {
        deny all;
    }
}


27.8k

i do not received any errors when i access my app now.

sudo nano /var/log/nginx/error.log



58.4k
edited Nov '14

Maybe root web app of you

set $root_path '/usr/share/nginx/pple/public';

Change to be look like below, if it is default when install nginx

set $root_path '/usr/share/nginx/html/pple/public';


27.8k
Accepted
answer
edited Nov '14

Resolved this issue by setting this in nginx configuration. Some weird coding in certain javascript is blocking the request.

charset utf-8;