How to install Laravel 5 on Ubuntu/Nginx server

May 27, 2015 12.1k views
Nginx PHP Frameworks Ubuntu


I have been trying to get Laravel 5 installed in my Ubuntu/Nginx server but not luck. I followed this tutorial but I keep getting the following error "502 Bad Gateway nginx/1.4.6 (Ubuntu)".

Any idea what could be happening here? Have any one see this error after following this tutorial tutorial?

Is there any other tutorial that I could follow to install Laravel 5?


  • Seams that something is wrong with the php-fpm service.

    Check your nginx and php-fpm logs.

    tail -f /var/log/nginx/* /var/log/php*

    This article should help you more.

  • Thank you for your reply.

    Here is what I get when I run sudo tail -f /var/log/php*

    [27-May-2015 07:38:19] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

    And here is what I get when I runsudo tail -f /var/log/nginx/*
    tail: cannot open ‘/var/log/nginx/*’ for reading: No such file or director

    This is what I see when I open sudo vi /var/log/nginx/

  • Check if php5fpm process exist :

    sudo ps aux | grep php5

    Would it possible to paste your nginx config here. you can replace domain and sensitive info first

  • This is what I got when I typed sudo ps aux | grep php5

    root      11842  0.0  1.4  79088  7524 ?        Ss   May27   0:04 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
    username  13085  0.0  0.1  11740   932 pts/0    S+   07:27   0:00 grep --color=auto php5

    I hope non of this info compromises my server.


  • Any suggestion? I don't want to give up that easy.

  • Here is what I got running sudo vi /var/log/nginx/error.log

    2015/05/28 15:12:01 [crit] 13205#0: *72 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 888.888.888.88, server: mydomain.com, request: "GET / HTTP/1.1", upstream: " fastcgi://unix:/var/run/php5-fpm.sock:", host: "mydomain.com"


  • I ran into a similar issue that was solved by fixing my permissions and nginx.conf file.

    This guide helped me alot: http://laravel-recipes.com/recipes/26/creating-a-nginx-virtualhost

1 Answer

Problem solved, added user www-data; to file sudo vi /etc/nginx/nginx.conf and it did the trick.

Have another answer? Share your knowledge.