Skip to main content

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 1

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.

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

Popular posts from this blog

Alternatives to the SQLite in Android

At the moment there are several embeddable databases and libraries out there that you can use in a mobile application. In this post, I examine most popular libraries and databases and highlight some of their characteristics. Realm Realm is a mobile platform and a replacement for SQLite & Core Data. According to the website, it has more than 100k active developers. Realm is fully open source and distributes under Apache License. Realm Mobile Database is much faster than an ORM, and often faster than raw SQLite due to zero-copy design. Some of the benefits of Realm are fast queries, safe threading, encryption of data and reactive architecture. You can learn more about Realm by visiting this page . Sugar ORM Sugar ORM is a library that can be used to interact with SQLite database using Object-Relational Mapping. Object-Relational Mapping (ORM) is a technique that used to query and manipulate data from a SQLite database using an object-oriented paradigm. And Sugar ORM tak

Laravel 5.4 Bootstrap row class for every 3 columns

Sometimes you need to show three or four columns in a row using Laravel 5.4 and blade template engine. Here I show how to do it using chunk function in Laravel blade. As the first step let's get products from the database and pass it to the blade view. And let's check our blade file. In the following example,  @ foreach  takes the  $ products array and chuck it. In this example, I split it by three. You can pass any number according to your specification. And you will see the inner @ foreach loop through  $ items. If you have any question please comment it and I will try to solve it.

Mobile Backend As A Service (BaaS) platform for Android

Many mobile apps and games rely on a backend service for things that can’t be done solely on hosted device, such as sharing and processing data from multiple users, or storing large files. Backend as a service (BaaS) provides a centralised database and other features to manage user-generated data and application data. The developer can link applications to the backend service and backend service expose APIs to manage users, integrate push notification and analytics. BaaS is a recent development of cloud computing technology. Using backend services provide developers functionalities to manage users, data and to analyse real-time changes actively. Backend service should be able to handle the offline case gracefully and minimise battery drain. Back in the day developers had to develop custom backend platforms using server-side technologies. And developers had to scale up and down according to the user base and app usage. It was time-consuming in terms of resources and skills. Most mob