I wrote this article on Thursday, December 12, 2019
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:
There are a few issues with this droplet for Laravel development - below are what they are, and how we deal with them!
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!
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.
Awesome - composer is done, lets try a
composer install. LOTS of errors! Lets fix that by installing the depencies that Laravel needs:
$ sudo apt-get install php7.2-curl php7.2-xml php7.2-zip php7.2-gd php7.2-mysql php7.2-mbstring -y
Looks like mod_rewrite isn't enabled by default! Lets change that!
$ a2enmod rewrite
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!
$ mysql -u root $ CREATE USER 'app'@'localhost' IDENTIFIED BY 'PUT_YOUR_NEW_PASSWORD_HERE'; $ GRANT ALL PRIVILEGES ON * . * TO 'app'@'localhost'; $ FLUSH PRIVILEGES; $ exit;
Try and login to MYSQL again now with this user, entering your new password in when prompted to:
mysql -u app -p
Yup - apart from a bit of apache vhost stuff of thats what you need!Lets restart APACHE and then you'll be good to go...
$ sudo service apache2 restart
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:
$ wget https://gist.githubusercontent.com/JakePrice86/9086783c681b32465c7d26b8ef4ee41b/raw/5af170b0f920c738ea03bff9ade2761f432da4fb/everything.bash && bash everything.bash