Question

Installing Laravel 5.1 with Nginx

Hi Guys, I’ve been trying to install laravel 5.1 with Nginx, I’ve installed the php-fpm, is currently running on /var/run/php5-fpm.sock.

I’ve created my nginx config as follow:

server {
        listen   80;
        server_name api.mydomain.com;

        root /var/www/api.mydomain.com/current/public/;
        index index.php index.html index.htm;
        location / {
             try_files $uri $uri/ /index.php$is_args$args;
        }

        # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

However… when I try access my site I’m getting this error:

2016/02/11 16:25:04 [crit] 6465#0: *48 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: api.mydomain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "api.mydomain.com"

Seems like is a problem with user permissions, can anyone help?

Thanks!

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Run 2 the following command: chown -R www-data:www-data /path/to/laravel/public/forder

chmod +x /var/run/php5-fpm.sock

If you see 502 Bad GateWay error, open /etc/nginx/nginx.conf, at the top of file edit user to www-data, if don’t exist add this line to top of file user www-data; Save and reload Nginx: nginx -s reload Your Laravel Framework should be run