John & Cyber Security

My Name is Ebuka John Onyejegbu, am a nice guy, a Developer, cyber security expert and chef. I work in the tech team of a financial Institution, My website is a sandbox to explore new technologies and document what i learn.

March 24, 2021

How to Run a Laravel application on Azure App Service Free Tier

How to Run a Laravel application on Azure App Service Free Tier

How to Run a Laravel application on Azure App Service Free Tier

Hi, I previously wrote about setting up the Azure App service Free Tier you can read that Here if you need any introductions.

Alright lets dig in.

Step 1: Upload your laravel project to your wwwroot or a folder if you desire to make it a subdirectory.

you can upload your files via FTP.

Step2: Now we will need to ssh into our server (its not a problem if you dont understand linux commands i will try to explain each step). to ssh open your azure portal>>navigate to your app service>>your project.  then click on SSH under Development Tools 

Step 3: The bash interface will be opened from step2.

Now we will need to navigate to our project folder, by default we will be in the home directory just as below

azure app service linux 1.png 

to navigate to our project folder we do: cd /site/wwwroot

This will take us to the root site folder if your project is in folder you will need to navigate to it via

 cd directoryname

follow step 4: if you have successfully navigated to your project folder

Step 4: run the following command :

apt update

it will update any required dependencies

Step 5: run the following command to install mbstring:

apt install curl php-cli php-mbstring git unzip

If it gives you an error, move on to the next step as its probably installed.

Step 6: install composer:

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

Step 7: Make the composer run globally:

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

Step 8: Test that everything is ok by running:

$ composer

Congratulations composer is installed

Now while still in your project directory follow the preceding steps

Step 1: Update your project composer dependencies:

composer update 

Step 2: Create a .env file (from a .env.example file) for your project if it doesnt already exist

cp .example .env

Step 3: Generate token:

php artisan key:generate

Great, your project should have a shape now when accessed via https://yoursite.azurewebsites.net/yourlaravelproject/public

Now we need to create a Mysql/Mariadb database

Step 1: Install MySQL/MariaDB server:

apt install mariadb-server

Step 2: Create a MySQL user:

mysql -u username -p

Replace username with your preferred username then enter preferred password.

Step 3: at this point you will be let into the MySQL interface, now its time to create a user

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Replace username with your preferred username and password with your preferred password, leave the localhost the way it is because the database resides within the local server.

Step 4: Grant ALL PRIVILEDGES to the created user:

GRANT ALL PRIVILEGES ON *.* TO 'database_user'@'localhost';

Step 5: Create a database

CREATE DATABASE myDatabase CHARACTER SET utf8 COLLATE utf8_unicode_ci;

That's it now navigate to your webpage: https://yoursite.azurewebsites.net/yourlaravelproject/public

to fill your database information if the application is flexible or you can enter your created Database details in the .env file manually.

Enjoy!!!!

Your Reaction to this Post?

Currently there are no comments, so be the first!
Fork me on Github