This blog post teaches you how to set up Laravel onto a virtual private server (VPS) using LEMP stack (DigitalOcean). LEMP is an acronym that stands for Linux, Nginx (Engine-X), MySQL and PHP. The reason I chose to use LEMP with Laravel is that it seems to be the preferred stack among the Laravel community. You can use LAMP stack as well, but when running smaller server instances like we are (with 512mb RAM), it has shown that Nginx performs better with limited resources.
You can host it any VPS server that you wish. In this tutorial, I set up the server through SSH into VPS instance. But there are few reasons to choose DigitalOcean such as simple UI and minimalistic approach, SSD-based virtual machines, comprehensive documentation, affordable pricing and community & ecosystem Support. I have used DigitalOcean in production, and it works great. If you would like to sign up using Busy Programmer's Guide, you will get $10 to get started, absolutely free.
Go to the DigitalOcean website and log in to your account.
Let's create a new droplet using Create Droplet button.
And the wizard will redirect you to the create droplet page. First of all, you need to select a distribution. Currently, there are six distributions. For this tutorial, I choose Ubuntu 17.04 x64 as my operating system.
Select the size of the droplet. I have chosen 512MB/ 1 CPU.
It is time to choose the physical location of the droplet. In general, it is best to choose a location closest to your users. So even if you are (as the developer) located in Sri Lanka, if your users are from the USA, you should create a droplet-based in the USA. This makes your server fast for your most active users.
On some locations, there will be multiple servers at one place. You can choose a number at random, and it won’t make much difference. I have left other options as it is. If you need optional add-ons, you can activate.
Enter a descriptive hostname as your droplet name. If you have multiple droplets, this will help you to identify which droplet you are working.
Click the Create button (long green button), and DigitalOcean will create the droplet to your specifications.
And you will see the generated droplet in the Droplets page in DigitalOcean.
Go to your email account, the email address you chose to sign up with DigitalOcean. And you will receive an email with login details to the droplet.
Following sections shows how to SSH into the server. In this tutorial, I use Linux (Ubuntu) operating system as the local system. If you are using Linux (on your local machine) or MacOS, then you will have SSH capabilities by default. If your client machine is Windows you need to download SSH client such as Putty, Bitvise SSH Client or WinSCP.
Open the terminal and type as follows. Replace 196.0.0.1 with the IP address of your server.
ssh root@196.0.0.1
The first time you boot into your server, you will get a message asking if you want to trust this IP address. Just type yes and click the enter button.
Now type the password you received in the email. And you will be prompted to enter the current password again. Enter the same password again. After that enter the new password.
We can now install new programs, change preferences, and manage files via the SSH terminal window.
In next blog post I will continue this tutorial.
Why DigitalOcean?
You can host it any VPS server that you wish. In this tutorial, I set up the server through SSH into VPS instance. But there are few reasons to choose DigitalOcean such as simple UI and minimalistic approach, SSD-based virtual machines, comprehensive documentation, affordable pricing and community & ecosystem Support. I have used DigitalOcean in production, and it works great. If you would like to sign up using Busy Programmer's Guide, you will get $10 to get started, absolutely free.
Set Up Your VPS
Go to the DigitalOcean website and log in to your account.
Let's create a new droplet using Create Droplet button.
And the wizard will redirect you to the create droplet page. First of all, you need to select a distribution. Currently, there are six distributions. For this tutorial, I choose Ubuntu 17.04 x64 as my operating system.
Select the size of the droplet. I have chosen 512MB/ 1 CPU.
It is time to choose the physical location of the droplet. In general, it is best to choose a location closest to your users. So even if you are (as the developer) located in Sri Lanka, if your users are from the USA, you should create a droplet-based in the USA. This makes your server fast for your most active users.
On some locations, there will be multiple servers at one place. You can choose a number at random, and it won’t make much difference. I have left other options as it is. If you need optional add-ons, you can activate.
Enter a descriptive hostname as your droplet name. If you have multiple droplets, this will help you to identify which droplet you are working.
Click the Create button (long green button), and DigitalOcean will create the droplet to your specifications.
And you will see the generated droplet in the Droplets page in DigitalOcean.
Go to your email account, the email address you chose to sign up with DigitalOcean. And you will receive an email with login details to the droplet.
Log-In via SSH
Following sections shows how to SSH into the server. In this tutorial, I use Linux (Ubuntu) operating system as the local system. If you are using Linux (on your local machine) or MacOS, then you will have SSH capabilities by default. If your client machine is Windows you need to download SSH client such as Putty, Bitvise SSH Client or WinSCP.
Open the terminal and type as follows. Replace 196.0.0.1 with the IP address of your server.
ssh root@196.0.0.1
The first time you boot into your server, you will get a message asking if you want to trust this IP address. Just type yes and click the enter button.
Now type the password you received in the email. And you will be prompted to enter the current password again. Enter the same password again. After that enter the new password.
We can now install new programs, change preferences, and manage files via the SSH terminal window.
In next blog post I will continue this tutorial.
Comments
Post a Comment