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.
- To add a new user enter the
adduser webcommand 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 webAdding 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 successfullyChanging the user information for webEnter 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
- Now we can log in with a
webuser and create a structure for how we want our future laravel project served.
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
May I ask, Antonio, how do you deal with the database? Do you run a separate container with the database?
@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.
I have an error when Itry to open my URL I got 404 Not Found nginx/1.18.0 (Ubuntu)
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.
Thanks for the feedback.
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.
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!
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 prodI build the js files. Is the the correct way?hi, we did not test front-end presets. if it works for you, what you did is correct way.
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?
it is impossible to tell what the reason of 404 is without seeing more logs or debug info.
Fixed it actually, I forgot to restart nginx and php-fpm
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 ;)
A topic for the future, thanks. But I think it's way outside of topic of Laravel, it's more about DevOps.
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?
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
I understand your point, it's OK. Thanks for the reply and the useful tutorial.
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!
i got error pemission denied when save file nginx/default.conf. Help me thanks
and i got error 404 not found nginx when root is hom/web/demoproject
chmod: changing permissions of '/home/web': Operation not permitted in step 5 web@ip-172-31-44-101:~$ chmod 755 /home/web
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.
You helped me conquer the myth of AWS. Thanks.
Finally got an app deployed to AWS - thank you this is a perfect tutorial for EC2!
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 ?
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