Note: you are reading an outdated version of this guide, which I keep online only for historical purposes. The up-to-date version is here.
This is a guide to deploying a web application with a Laravel backend and a JavaScript-based frontend on a dedicated or virtual private server.
The articles are listed in order below; you can read more meta-information about the guide below the table of contents.
.env
file, database migrations, and a few pre-deployment optimizations.A guide to deploying a web application with a Laravel backend and JavaScript-based frontend (e.g. Vue, React, etc.) on a dedicated or virtual private server. My goal in writing this was to document the process for future reference and help anyone else doing the same thing.
npm run build
script.
The frontend has a relatively minor role in this guide.authorized_keys
file on the server; logging in over SSH).I’ll generally show shell prompts in username@host$
format, and sometimes append the current working directory username@host:cwd$
for clarity:
# You on your development machine
you@dev$ whoami
you
# A shell command issued as root user on the server
root@server$ whoami
root
# A shell command issued as laravel user on the server
laravel@server$ whoami
laravel
# A shell command issued as laravel user from home directory
laravel@server:~$ pwd
/home/laravel
# A shell command issued as laravel user from /var/www
laravel@server:/var/www$ pwd
/var/www
Other conventions:
1.2.3.4
as a server IP address.laravel
as the name of the non-root user on your app’s server.laravel-project
as the name of your project’s root server-side directory.If you have ideas for improving the series, I will quite likely implement them, appreciate your input, and give you a shoutout for your contributions. Feedback is welcome and appreciated.
Shoutouts to readers: many thanks to Nicola Pugliese and Kai Breucker for offering good ideas on how improve this series.
You can reach me by email at [email protected] or by opening an issue or pull request at github.com/ejmastnak/ejmastnak.com).
You could:
Send me an email! Seriously, if this material helped you, it will make my day to know. I love hearing from readers, and you’ll almost certainly get a message back from me.
Contribute financially. Based on reader input, there are in fact people out there interested in compensating me financially for this guide. That’s awesome—thank you! You can Buy Me a Coffee here.
Below is a list of other great guides to deploying a Laravel app that I’ve found online and taken inspiration from. Each covers the material from a slightly different angle, so you’ll probably get something out of reading all of them.
The original writing and media in this series is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.