Comments on Dockerizing Laravel with Nginx MySQL and Docker Compose on Ubuntu 18.04 LTS
In this guide, we're going to show you how to Dockerize the Laravel project with PHP-FPM, MySQL database, and the Nginx web server using the Docker Compose on the Ubuntu Server 18.04. We're going to create a new docker image for the Laravel Project, and then create the docker-compose.yml script that contains some services including, the App/Laravel itself, Nginx web server, and MySQL database.
3 Comment(s)
Comments
Thank you very much for the tutorial. It's very straight forward and easy to understand. I've finished all the procedures, no error during the process. The porblem is, I dont have a SSL certificate. It this step, you have mentined
After that, copy your ssl certificate file to the 'nginx/ssl/' directory.
sudo cp /path/to/ssl/fullchain.pem nginx/ssl/sudo cp /path/to/ssl/privkey.pem nginx/ssl/
Now, after putting the URL in the bowser, there is error that "The site can't be reach". Can you please help me out here?
@Rati I am replying you just because this wonderful tutorial helped me to successfuly setup docker with a laravel application.
You need ssl (most time) only when you're dealing with a live website. You don't need an ssl for local development so I will advise that you remove anything related to ssl.
Your docker -compose Nginx setup will endup looking like this:
#Nginx Service nginx: image: nginx:alpine container_name: nginx restart: unless-stopped tty: true ports: - "80:80" # - "443:443" volumes: - ./:/var/www/html - ./nginx/conf.d/:/etc/nginx/conf.d/ # - ./nginx/ssl/:/etc/nginx/ssl/ networks: - laravelAnd in your laravel.conf, you should remove the ssl related part and you're left with something like this:
server { listen 80; error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; root /var/www/html/public; index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; gzip_static on; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass app:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } }PS: I am able to access the Laravel site on port 80, and I have not been able to switch to other port.
Thanks for everything all working good, I have one question for SSL certificate firstly I need generate CSR file can you please tell me I need to generate CSR file inside Nginx container on any other side?