(1) Install Nginx Server

sudo apt-get update
sudo apt-get install nginx-extras

# Update timezone
sudo dpkg-reconfigure tzdata

(2) Install Composer and PHP

sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install composer unzip zip

sudo apt-get install php7.3-fpm php7.3-mysql php7.3-mbstring php7.3-xml php7.3-common php7.3-dom

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

(3) Setting Up SSH key pair for Bitbucket.

cat .ssh/id_rsa.pub

(4) Download Application

git clone -b master --single-branch git@bitbucket.org:company/app.git

(5) Install Dependencies

cd path/to/app
composer install

(6) Setup environment variables

cp .env.example .env
pico .env (E.g. set DB credentials)

(7) Generate application key

php artisan key:generate

(8) Perform Database migration

php artisan migrate

(9) Execute seed queries

php artisan db:seed

(10) Set application owner to www-data

sudo chown -R www-data:www-data ./app

(11) Add application to Nginx

server {
        listen 80;
        listen [::]:80;

        root /path/to/app/public;
        index index.php index.html index.htm index.nginx-debian.html;

        server_name my-app.com;

        add_header "X-Frame-Options" "SAMEORIGIN" always;
        add_header "X-XSS-Protection" "1; mode=block" always;
        add_header "X-Content-Type-Options" "nosniff" always;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

        location / {
                try_files $uri $uri/ /index.php?$query_string;

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.3-fpm.sock;

        location ~ /\.ht {
                deny all;

(12) Reload Nginx.