NGINX/PHP-FPM (with Docker)

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Snyder, Alexander J via PLUG-discuss
Date:  
To: PLUG Distro
CC: Snyder, Alexander J
Subject: NGINX/PHP-FPM (with Docker)
Keith Smith & PLUG (et. al.) --

I'm sorry it took me so long, but y'know -- end of year madness.

Anyhoo -- I had some time free from work and I whipped up a nginx webserver
with PHP-FPM.

I have never worked with NGINX and I have never worked with PHP-FPM. It
took a solid 5 minutes of Docker Compose 'ing to get it working.

Here is the Docker Compose file I used: https://pastebin.com/KdPvG6wD
Here is the NGINX Conf file I used: https://pastebin.com/sC8VkBVQ
Here is the INDEX.php file I used: https://pastebin.com/y5dEjKNS

This is the directory structure of my Docker Compose folder:

--> tree /opt/apps/websitetest/
/opt/apps/websitetest/
├── data
│ ├── html
│ │ └── index.php
│ └── nginx.conf
└── websitetest-compose.yml

2 directories, 3 files

===================

Okay, how here's how you get going on this:

Step 1: Add the Docker CE repo to your computer:
https://download.docker.com/linux/
.... I assume you know how to do that part. Its really simple on RHEL, I
can't speak for Ubuntu or others.

Step 2: Add the packages:

- containerd.io
- docker-buildx-plugin
- docker-ce
- docker-ce-cli
- docker-compose-plugin
- python3-docker


The most important being the "docker-compose-plugin"

Once docker is running and you can successfully do their "Hello World"
test: "docker run --rm docker.io/library/hello-world" (without
double-quotes)

You should get a message that your docker is installed correctly.

Next, create a common proxy network for these services to communicate in:
"docker network create website" (*you can name your network whatever you
want, for simplicity I chose "website", and my files reflect that same name*
).

This proxy network is reflected in my files, so make the appropriate
changes if you name it something else:

----------------------------
networks:
  website:
    external: true


networks:
- website
----------------------------

With the Nginx Conf file and PHP files both staged in the proper
directories (*remember to adjust the path to reflect on your system
properly*)

I am in the working directory that contains my COMPOSE file:
I ran this command: "docker compose -f websitetest-compose.yml up -d"
(*without
double quotes*)

Then, I navigated to my docker host, and put in the host port (3005) that I
mapped to the container port of 80, and I see this:
https://imgur.com/a/Vuajx5z

I'm happy to help anyone trying to get this same proof-of-concept working
for them, but anything beyond a simple POC and I would say I'm probably not
the guy.

This was just meant to show how quick and easy Docker makes development.

Let me know how I can help!

--
Thanks,
Alex.
---------------------------------------------------
PLUG-discuss mailing list:
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss