Sometimes to build a web app you need to store and retrieve the information from users. Or do some data manipulations for them, save files, send emails etc. In that case it's useful to have a backend server and a backend application that will do the work for you. Usually it consists of:
- Webserver (Nginx, Apache, etc.)
- Database (MySQL, Postgree, etc.)
- Your web application (with supported interpreter)
- Some additional features that you might have to install i.e. caching system such as Redis
We choose to use Laravel as our main web application builder for its features, user materials across the internet, guides and plugins. But it might to be hard to start with so we want to give you step-by-step installation guide.
Please note that all commands on Laravel documentation supposed to be called on Linux environment. If you use Mac or Windows you need to install Docker desktop (based on your machine). In Docker desktop enable option "Use the WSL 2 based engine" in General tab and check "WSL integration" in Resources tab - you need to enable integration with your distro to make Docker working inside your Linux virtual machine. If wsl is not installed yet please follow the official Microsoft guide. This should allow you to use "wsl" command in command line interface (CLI)/terminal.
Ubuntu image. For Windows machine you can get Ubuntu image from Microsoft Store.
To get into your Linux machine just call "ubuntu" from CLI or PowerShell.
Bonus: you can set Ubuntu image as a default image by using command "wsl -s <DistributionName>". Then you can call "wsl" and it will open your Ubuntu image.
Setup environment. Start a new Linux session if you haven't started yet.
Update your package repositories by calling:
sudo apt-get update
sudo apt-get upgrade
Install required packages:
sudo apt-get install docker.io curl composer
You can add additional packages to this list such as npm if you're planning to use them
Laravel installation. Go to a directory where you want to create a new project. Call:
curl -s https://laravel.build/<ProjectName> | bash
Replace <ProjectName> with your actual project name and wait until it downloads the distribution. Go inside this new directory and call:
This should start your project. First call of this command will take several minutes to launch while next ones will be much faster.
Congratulations! You're ready to create your own application now.
Take a look at localhost as it should contain basic Laravel page
Additional configuration. If you already have some docker images that take required ports (80 for app, 3306 for database, 6379 for redis, etc.) you can change this configuration in docker-compose.yml file.
All common configuration such as database connection stored in .env file
Application configuration located in config directory but it usually refers to .env file as well