Skip to content

Simple setup for Docker configuration with nginx, php 8 and mysql via Windows and virtual Host

Notifications You must be signed in to change notification settings

tbachvarova/docker-nginx-php-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Docker configuration - PHP + Nginx + MySQL

under Windows

I try to make a simple Docker configuration with:

  • nginx
  • PHP 8.1
  • MySQL
  • & virtual host

Setup Virtual Host in Windows

http://docker-app.test/

  1. Open Notepad or any other text editor with administrative privileges.
  2. From the File menu, select Open, and browse to C:\Windows\System32\drivers\etc.
  3. In the "Open" dialog box, change the file type filter to "All Files (.)" to view all files.
  4. Select the hosts file and click Open.
  5. Add the following line to the end of the file:

127.0.0.1 docker-app.test

Setup Project Dir = docker-app

  1. Install Docker Desktop on your Windows machine.
  2. Create a new directory named "docker-app" at the root of your C drive. Inside the "docker-app" directory, create two subdirectories named "public", where is my index.php file, and mysql.
  3. Create a new file named "docker-compose.yml" inside the "docker-app" directory and add the code in docker-compose.yml

docker-compose.yml is a file that describes the configuration of one or more Docker containers. docker-compose is a command-line tool that is used to run and manage these containers.

When you run docker-compose with the up command, it will read the configuration in docker-compose.yml and create the necessary containers, networks, and volumes specified in the file. It will also start and stop the containers as needed based on their dependencies and configuration.

  1. Create a new directory named "nginx-conf" inside the "docker-app" directory. Inside the "nginx-conf" directory, create a new file named "default.conf" and add the code.

  2. Create a "Dockerfile.php" with php configuration in it. The "Dockerfile-php" specifies the instructions for building a custom Docker image for the PHP service.

  3. Open the Windows command prompt or PowerShell and navigate to the "docker-app" directory. Or do this in Terminal of your editor IDE.

  4. Run the following command to start the Docker containers:

    docker-compose up -d

    This will build the Docker containers and start them in detached mode.

  5. To access the website, open your web browser and navigate to "http://docker-app.test:8080". You should see the default PHP page.

  6. To access MySQL remotely, you can find the IP address of the MySQL container by running the following command in the Windows command prompt or PowerShell:

docker inspect docker-app_db_1 | Select-String -Pattern "IPAddress"

About

Simple setup for Docker configuration with nginx, php 8 and mysql via Windows and virtual Host

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages