Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mskramst's avatar

Laravel on Digital Ocean

I am seeking to use Laravel for small projects. I work as a teacher/coordinator in a high school and often create small PHP sites for limited purposes. Up til now I've just been doing it without a framework, but became interested in learning Laravel. I'd like to easily deploy a Laravel project to a Digital Ocean droplet, but I've viewed numerous tutorials on getting it to work, but can't get routes to display. It doesn't seem like there are any current tutorials on the topic. I would like to avoid using Forge or Envoyer or other paid sites for these small limited sites. I would just like a simple way to upload a Laravel site to a droplet and have it work.

I am fine with setting up the LAMP or LEMP server on Digital Ocean, but I can't seem to figure out how to config the site to point to the index.php file in the public folder and actually display the routes file (or Welcome Page). Any suggestions or help would be appreciated.

Mike

0 likes
9 replies
Cytus's avatar

Hi... You can use the Framework Laravel in small projects and the installation process is simple. About site Digital Ocean virtual server that you must install on VPS cPanel or DirectAdmin to be able to upload a project that is written with Laravel Framework and Web Raise. Install XAMPP and lamp on YouTube there is enough on the Laravel search. Good luck.

mskramst's avatar

I believe that tutorial (Nginx on Ubuntu 14.04) is out of date. I tried it but got errors regarding the wrong version of PHP. If someone could confirm it works with Laravel 5, I'd try it again. I am envisioning someone one day will make a tutorial showing how to set up a Digital Ocean box with Larave. Maybe Digital Ocean will someday create a one-click App for Laravel. I found Cloudways in my searches and they have a one-click button for creating Laravel apps. I found it easier to set up than Forge, and it's the only solution I found at the moment. If anyone discovers any other info or tips, feel free to share. Ideally, I'd like to create a working Digital Ocean snapshot for a current Laravel project and then clone it when I want to create something new. I dislike CPanel or similar web interfaces for managing my web applications.

colourmill's avatar

@mskramst I'm not sure why you're ending up with Ubuntu 14.04, but from what I'm reading here: https://launchpad.net/ubuntu/trusty/+source/php5, it originally shipped with the exact same version that laravel 5.2 requires.

I usually go with the latest version of a Debian droplet. Debian is less cutting edge than Ubuntu, and should therefore be a bit more stable. Since Ubuntu is a fork of Debian, everything is more or less in the same location, so you shouldn't be having any issues finding things.

That being said, there's a DigitalOcean tutorial to upgrade php to version 7, which is highly recommended for performance sake: https://www.digitalocean.com/community/tutorials/how-to-upgrade-to-php-7-on-ubuntu-14-04

If you're not currently using your droplet, I'd just create a new one with the latest version of either Ubuntu or Debian, that should give you php7 out of the box.

Can you tell us what exactly happens when you try to load the website, and can you paste the vhost you've set up?

mskramst's avatar

Can anyone recommend a good tutorial for setting up the latest version of Laravel on a Digital Ocean droplet? I've walked through several different ones and hit a snag at some point with a particular step in all the ones I've found online (videos/web guides). Either they require some outside service or support an outdated version of something.

mentalist's avatar

Don't know if this will help, but here's my nginx conf file for my working Laravel installation on a LEMP stack on Digital Ocean. Have changed the domain. There's some SSL stuff in there as well.

server {
    listen [::]:80;
    listen 80;
    server_name www.mydomain.com;
    return 301 $scheme://mydomain.com$request_uri;
}

server {

    listen [::]:80;
    listen 80;
    server_name mydomain.com;
    root /usr/share/nginx/mydomain.com/html/laravel/public;
    charset utf-8;

    # SSL configuration
    listen [::]:443 ssl spdy;
    listen 443 ssl spdy;
    include h5bp/directive-only/ssl.conf;
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        includees $uri /etc/nginx/fastcgi_params;
    }

    location ~ /\.ht { SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #deny all;
    }

    include h5bp/basic.conf;
}
fideloper's avatar

@mskramst if you can outline what steps you do (preferably exactly, the commands run, files modified) to setup your server, we can be of more help to nail down a process. I've been through it a million times, hopefully I can find something. (I'm the author of servers for hackers linked above).

Please or to participate in this conversation.