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.