Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

Finally: Install Laravel Project

Premium
12 min read

Finally! After all those preparations, we can see our project working in our browser.

Usually, NginX and PHP-FPM service runs as www-data user and it is a system user for services. In the best case scenario, we would like to isolate our web project from any system services and maybe have a different directory for example /home/web/demoproject as opposed to /var/www/html where you need root user explicitly.

  1. To add a new user enter the adduser web command as root. You will be prompted to define a password for a web user add fill in optional details. Make sure to choose a secure password.
root@ip-172-31-44-101:~# adduser web
Adding user `web' ...
Adding new group `web' (1001) ...
Adding new user `web' (1001) with group `web' ...
Creating home directory `/home/web' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for web
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
  1. Now we can log in with a web user and create a structure for how we want our future laravel project served.

The Full Lesson is Only for Premium Members

Want to access all of our courses? (29 h 14 min)

You also get:

54 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

AA
Antonio Anerão ✓ Link copied!

I have a Dockerfile and a Docker Image to help me deploying laravel apps running inside a docker container

Dockerfile: https://github.com/antonioanerao/dockerfile-laravel
Docker Image: https://hub.docker.com/r/antonioanerao/laravel

It's quite simple to run

W
wolfatadfilm ✓ Link copied!

May I ask, Antonio, how do you deal with the database? Do you run a separate container with the database?

AA
Antonio Anerão ✓ Link copied!

@wolfatadfilm if I'm using for some reason a sqlite database I don't mind to use the sqlite file in the same container, however, if I'm using a MySQL/SQL Server database I prefer to keep in a separatede container. In some cases I even use a differente machine for that (in the same network).

I have a few projects here I have a machine for webservers and another one for databases. I keep one docker-compose for each database so I can have more control about everything.

AA
Alanoud Aljubail ✓ Link copied!

I have an error when Itry to open my URL I got 404 Not Found nginx/1.18.0 (Ubuntu)

M
MV ✓ Link copied!

This tutorial ended too quickly. Currently, I need to google how to set up a custom domain name, so my project is accessible via mydomain.com, how to set up supervisord so queue works and mailgun free tier, so my mails are being sent out. For the current price of monthly subscription, I expected more.

PK
Povilas Korop ✓ Link copied!

Thanks for the feedback.

  1. Setting up a domain name: there is a sentence "You may purchase a domain name on one of the providers and add DNS A type record with the value of your public IP address" - if we need to expand on that, we need to chose some domain providers to show and there are hundreds of them, so it would be individual for everyone, that's why we didn't go deeper on this.
  2. Queues are a very deep topic in itself, and there are MANY ways to configure them, including Amazon's own tools, so it would deserve a separate multi-lesson course, maybe in the future, adding to a potential to-do list of content.

Generally, if you're not happy with the content of monthly subscription, feel free to unsubscribe, we're trying to cover a lot of topics but there's only so much time in the day and so many topics we can publish. We're doing our best and looking at what to improve depending on the feedback.

GK
Gavin Kimpson ✓ Link copied!

I think this tutorial was just the right size, it is called "Deploy Laravel Project to AWS EC2: Step-By-Step" which I believe it does that quickly and sufficiently. Setting up a domain is a very individual thing people prefer one company to another and people would complain that the steps are different from their preferred registrar etc

Queues.... did you really ask about queues.... that is a tutorial and a half in itself!

My only criticism would be the RDS - whilst the best way to go a lot of people might be put off by the higher RDS costs for a small database especially for a project. I ended up just installing MySQL 8.x manually and configuring my Laravel app with this instead, which I believe is sufficient for most but that is just my 2 cents :) Great tutorial Povilas!

E
Eidmohd89 ✓ Link copied!

What about frontend pressets like React js?

I have installed nvm and using nvm I installed the node version on the project directory. Using run npm prod I build the js files. Is the the correct way?

DL
David Lun ✓ Link copied!

hi, we did not test front-end presets. if it works for you, what you did is correct way.

L
luvstospooge ✓ Link copied!

I got a 404 error... no clue what's going on. I have a webpack.mix.js file because I'm using React.js in my project so maybe that's why? But I'm not sure. my /etc/nginx/sites-enabled/default is identical to what's posted above (except for demo_project) so I can rule that out.

What could be the issue?

DL
David Lun ✓ Link copied!

it is impossible to tell what the reason of 404 is without seeing more logs or debug info.

L
luvstospooge ✓ Link copied!

Fixed it actually, I forgot to restart nginx and php-fpm

SS
Sanjeet Sagar ✓ Link copied!

This is good article but domain side is remaining like manage domains DNS, SSL etc, what If we need another sub domain in this same instance ;)

PK
Povilas Korop ✓ Link copied!

A topic for the future, thanks. But I think it's way outside of topic of Laravel, it's more about DevOps.

Z
zoki ✓ Link copied!

What about a setup with two or more application servers and a load balancer? How to set that up, and how to make updates to it in the future?

PK
Povilas Korop ✓ Link copied!

We were thinking about a tutorial for load balancer, but it seems to be more of a DevOps topic than developer/Laravel. So, for now, we don't plan to write about it. I recommend you watch these videos on ServersForHackers: https://serversforhackers.com/s/load-balancing-with-nginx

Z
zoki ✓ Link copied!

I understand your point, it's OK. Thanks for the reply and the useful tutorial.

N
nadu ✓ Link copied!

Good article, helps someone go from building and customising a web server all the way through connection and deployment with the source code repo.

Well done team!

GN
Giang Nguyễn ✓ Link copied!

i got error pemission denied when save file nginx/default.conf. Help me thanks

GN
Giang Nguyễn ✓ Link copied!

and i got error 404 not found nginx when root is hom/web/demoproject

GN
Giang Nguyễn ✓ Link copied!

chmod: changing permissions of '/home/web': Operation not permitted in step 5 web@ip-172-31-44-101:~$ chmod 755 /home/web

IA
Ihtisham Ahmad ✓ Link copied!

Hi, Thank you for this nice tutorial. Everything worked like a charm and I deployed laravel app to aws for the first time. Thank you so much.

A
Ariziky ✓ Link copied!

You helped me conquer the myth of AWS. Thanks.

GK
Gavin Kimpson ✓ Link copied!

Finally got an app deployed to AWS - thank you this is a perfect tutorial for EC2!

U
Umayantha ✓ Link copied!

403 Forbidden nginx/1.24.0 (Ubuntu)

i have complete everything but yet i got this error message. i have no idea why nginx stopped running

can you help me with this issue ?

U
Umayantha ✓ Link copied!

403 Forbidden nginx/1.24.0 (Ubuntu)

i have complete everything but yet i got this error message. i have no idea why nginx stopped running