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;

        root /var/www/;
        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:, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: ""

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


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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