laravel(6.2) project installation on aws ec2 instance ami (amazon machine image) ubuntu 18.04

Ziaur Rahman
Nov 1 · 3 min read

Introduction:
Laravel is an enriched, well featured, reputed web application framework. If you want to develop a system, you can choose laravel easily because of it’s expressive, elegant syntax, secured, emerged platform, template, mvc pattern and much more. There are lot of reasons to choose this web application framework.

Tech Details:
aws ec2, amazon machine image ubuntu 18.04, Nginx(1.14), php(7.3), composer(1.9.0), git(2.17.1), laravel(6.2)

Requirement:
1. aws account access
2. running ec2 instance
3. accessing the ec2 instance, if not created to create please visit blogspot or medium
4. nginx installation, if not installed please visit blogspot or medium
5. php installed. if not, to install follow the tutorial visit blogspot or medium
6. composer installed. if not, to install follow the tutorial visit blogspot or medium

Installation procedure:
Step1: making user the owner of the directory /var/www/ by running the command. By default directory permission is not been given. So, you can’t download or make any directory here. That’s why we need to change the ownership of the directory as user. This step is very important if you don’t edit it carefully you may get the “502 bad gateway in nginx”

$ sudo chown -R ubuntu /var/www/ (press enter)

Now you can install laravel project inside /var/www/ direcotory.

Step2: go to /var/www/ directory by running the cd command.

$ cd /var/www/ (press enter)

Step3: Now run composer command to install laravel project with your preferable project name. Here, I am using blog as project name.

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

The laravel project installation has been completed. Now time to execute on your browser. For this, we have make this /blog directory as default server directory. And this is the most important part of all the steps. It’s very easy to do so.

Step4: Now open /etc/nginx/sites-available/default file to edit. to do so run the command.

$ sudo nano /etc/nginx/sites-available/default (press enter)

Step5: Now change the root directory from ‘/var/www/html’ to ‘/var/www/blog/public’, include index.php on index section and change try_files $uri $uri/ =404 to try_files $uri $uri/ /index.php?$query_string. Press ‘cltr + x’ and ‘shift + Y’ to save. This step is very important if you don’t edit it carefully you may get the “403 forbidden in nginx”

/etc/nginx/sites-available/default page

Step6: check the nginx configuration file, is it ok by running the command

$ sudo nginx -t (press enter)

Step7: reload and restart the nginx server to run the laravel project on your browser.

$ sudo systemctl reload nginx (press enter)

Step8: give your laravel storage directory public access by running the command

$ sudo chmod -R 777 /var/www/blog/storage (press enter)

Output: Now copy your ec2 instance’s public ip from ‘Description’ tab and paste it on your browser. you can see your expected laravel project

Comment: Go to your project directory by running the command $ cd /var/www/blog , press enter and play with it like you are playing on your local pc I mean composer, git, artisan, auth, migration, db seeding anything that you want. If you want to write your code on aws that article is coming soon……..

…………………….BUUUUUUUUUURRRRRRRRRSSSSSSSSSSSSSSSTTTTTTTTT…………………….


Originally published at http://zrshishir.blogspot.com.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade