Published 3 years ago 3599 Views

Login into your digital ocean account. If you haven't account still then you can create new one from my referral link & you will get $100 free credit for 60 days.


Step 1 : Create New Droplet

Click on 'Create' drop down & select 'Droplets'.

  • Select Ubuntu 18 LTS OS.
  • Choose your plan as per your project requirement.
  • Select data center region like Bangalore.
  • Create root password.
  • Enable backups if your project require.
  • Now click on 'Create Droplet' button.

It will take some time to setup droplet or server.

After droplet successfully created, IP will be assigned to it.

Step 2 : Connect to droplet

Now you have droplet IP, so use it for connect via ssh in terminal.

Connection will be establish via username of your droplet, by default username is 'root'

Connect by following command :

ssh root@

Enter droplet password & you ready to go.

Step 3 : Install Apache

Need to update ubuntu system

sudo apt update

Install apache package from ubuntu repository by following command :

sudo apt install apache2

Check server home page by placing IP in browser

Step 4 : Install MySQL

Need to update ubuntu system

sudo apt update

Install MySQL package from ubuntu repository by following command :

sudo apt install mysql-server

Step 5 : Install phpMyAdmin

Need to update ubuntu system

sudo apt update

Install some php extension along with phpMyAdmin package from ubuntu repository by following command :

sudo apt install phpmyadmin php-mbstring php-gettext

While installing this you will be asked for choose some options.

Enable some php extension by following command :

sudo phpenmod mbstring

Restart apache server

sudo systemctl restart apache2

Installation is done, but we are not able to access phpMyadmin, for that need to do some configuration.

Need to allow phpMyAdmin in apache config. Open config file with nano editor.

sudo nano /etc/apache2/apache2.conf

Now add following line at the end of file, that allow phpMyAdmin to run.

Include /etc/phpmyadmin/apache.conf

Restart apache server

sudo systemctl restart apache2

Run phpMyAdmin by following url in browser

Step 6 : Create MySQL user for phpMyAdmin

Need to set root user credential for login into phpMyAdmin. For that login into mysql with command line

sudo mysql

First check list of existing users in MySQL by following syntax :

SELECT user,authentication_string,plugin,host FROM mysql.user;

This will list all user with credential string.

By default root user has not any credential / password is set, default is blank, check it with new password so we can add extra layer of security to our database.

Change password by following syntax :

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';

Now reload all table privileges by following syntax :


Once again check list of user & verify root user has new credentials or not by following :

SELECT user,authentication_string,plugin,host FROM mysql.user;

Allow root user to all table, options, etc by following syntax :


Exit MySQL by this :


Check your credential is working or not in phpMyAdmin, login & try to create new database with root user

Step 7 : Install Composer

Check ubuntu for latest update

sudo apt update

Need to install php extension like curl, mbstring, zip for the installation of composer

sudo apt install curl php-cli php-mbstring git unzip

Change terminal current directory to root

cd ~

Get composer installation file from official website by following command :

curl -sS https://getcomposer.org/installer -o composer-setup.php

Get security hash key (check sum) from following website https://composer.github.io/pubkeys.html for installation of composer file.

Copy that key & run in terminal with HASH command :


Verify security key for secure installation.

php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installation file verified.'; } else { echo 'Installation file corrupt.'; unlink('composer-setup.php'); } echo PHP_EOL;"

You will see the output : Installation file verified.

Finally install composer in bin directory with this command :

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Check composer is successfully installed or not by running this command :


Step 8 : Setup SWAP memory

In digital ocean servers by default swap memory is not configure, check by this command :

free -m

If you see 0 in swap memory then we need to configure that for laravel installation.

Run following command one by one to setup.

sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

After that once again check swap memory by this :

free -m

Step 9 : Install Laravel / Clone project

If you have existing project git repository then you can clone it.

But if you need to setup fresh copy of laravel then follow this.

Change directory to html

cd /var/www/html

Remove existing files / folder in html directory if you not need them or create new directory for laravel project.

Now download installation files of laravel package by following composer command :

composer global require laravel/installer

Create new laravel project by this, you can change you project name by replacing blog.

composer create-project --prefer-dist laravel/laravel blog

Now configure apache to run directly from your project directory.

Go to apache sites config folder

cd /etc/apache2/sites-available/

Open default config file by using nano editor.

sudo nano 000-default.conf

Change document root to project public directory

DocumentRoot /var/www/html/blog/public/

Save changes & exit editor by ctrl + x, type yes/y if needed.

Restart apache server

sudo systemctl restart apache2

Change laravel project storage folder permission otherwise it will not log error, cache files, etc.

sudo chmod -R 0777 /var/www/html/blog/storage

You can refresh your current browser page & check your laravel project is now running.

All done here.


Subscribe and get my latest blog post in your inbox.

Install & configure laravel project into live digital ocean server.


Laravel push notification for devices with FCM


Install Composer on MacOS