So you have built your amazing Laravel app and now you are ready for the world to see it. There is a variety of ways to host a Laravel app, however, in this post, we are going to run through how to host an app on a VPS using the LEMP technology stack.
The LEMP acronym stands for:
We will not be going into detail about VPS in this post, as it is a whole other topic
There is now a large amount of hosting providers that are offering VPS servers that very low costs. We are going to be using Digital Ocean as it allows for servers to be scaled up or down very easily.
- Create a new account on Digital Ocean
- Click on Create then Droplets
- Choose the Ubuntu image for your server
- Choose the server size
- Choose datacenter destination
- Add your SSH key
- Finally click created new droplet
When accessing your server for the first time you will ask to confirm connection using the SSH key. Check that everything looks correct and continue connecting.
Before we continue we need to update the Apt-Get. This is used to install Linux based programs on your server.
sudo apt-get update
By running the command above we can make sure Apt-Get is updated before we start installing anything.
During this step, we will be installing the E part of our LEMP stack.
Using Apt-Get we can usually install Nginx on our server by running the following command.
sudo apt-get install nginx
MySQL is will satisfy the M within our LEMP stack. Run the following command to install MySQL.
sudo apt-get install mysql-server
Once MySQL has successfully installed on the server, it is best to secure it to remove some of the vulnerabilities associated with MySQL.
To do this run the following command and you will get a series of questions that will help you secure your MySQL install.
Now it is very likely that PHP is already included in your Linux based server. However, we will need to update a few things as we need to set up PHP for processing. To do this run the following command.
sudo apt-get install php-fpm php-mysql php-mbstring
By following the steps above you should now have a LEMP server for your Laravel applications.