Getting a DigitalOcean Droplet ready for Laravel
I wrote this on Thursday, December 12, 2019
Want a script that does all this for you? Skip to the end for a one-liner that I shamelessly use everytime I need a new enviroment!
When I am out and about, I tend to fire up a DigitalOcean droplet to do all my work on because of dodgy public WIFI - but I always need to play around and configure them manually. Here are my steps I take along with a quick and easy script to automate this!
Firstly - the settings I usually choose for my droplets are the following:
- Choose an image -> LAMP on 18.04
- Plan - Starter
- $20 a month
- London 1 (Because am based in the UK!)
There are a few issues with this droplet for Laravel development - below are what they are, and how we deal with them!
Composer isn't installed by default
This is the easiest one to remedy - go to Composer Download Page and run the command line installation. After installation I will usually make sure composer is available globally by following these extra instructions: Global install.
PHP dependancies missing! 😢
Awesome - composer is done, lets try a
composer install. LOTS of errors! Lets fix that by installing the depencies that Laravel needs:
My URLS don't work?! 😠
Looks like mod_rewrite isn't enabled by default! Lets change that!
I can't connect to MYSQL?! 😡
Makes sense - all we are ever given by the DigitalOcean droplet is the ROOT password, which shouldn't be used by your app. To get round this, we'll need to create a new user, with its own password. MYSQL on the command line is fun - lets create a new user!
Try and login to MYSQL again now with this user, entering your new password in when prompted to:
Are we done now? 🙏
Yeah - apart from a bit of apache vhost stuff of thats what you need! Lets restart APACHE and then you'll be good to go...
You promised us a script! 🐱💻
I did - and after you have read the above you *should* know how everything works! Run the below line and you'll be good to go in a few seconds after the server does the following:
- Installs PHP 7.2
- Sets up PHP dependancies
- Installs Composer
- Creates MYSQL user
- Generates a password for the MYSQL user
- Installs NODEJS
- Sorts out vhost
Good luck 😎
The posts below have been selected based on the post you've just read!