{"id":15524083,"url":"https://github.com/congcoi123/docker-php-nginx","last_synced_at":"2025-04-23T07:23:35.974Z","repository":{"id":128949753,"uuid":"227843886","full_name":"congcoi123/docker-php-nginx","owner":"congcoi123","description":"This project helps you quickly create a web development environment with PHP-FPM, Nginx, MySQL, and Redis.","archived":false,"fork":false,"pushed_at":"2020-02-22T08:00:03.000Z","size":592,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T22:41:17.378Z","etag":null,"topics":["docker","docker-compose","mysql","nginx","php","php-fpm","redis","web-development"],"latest_commit_sha":null,"homepage":"https://congcoi123.dev","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/congcoi123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-13T13:15:29.000Z","updated_at":"2023-06-05T13:48:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"3469cb76-fb85-4108-8a33-ec43511227ec","html_url":"https://github.com/congcoi123/docker-php-nginx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/congcoi123%2Fdocker-php-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/congcoi123%2Fdocker-php-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/congcoi123%2Fdocker-php-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/congcoi123%2Fdocker-php-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/congcoi123","download_url":"https://codeload.github.com/congcoi123/docker-php-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250388224,"owners_count":21422290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","mysql","nginx","php","php-fpm","redis","web-development"],"created_at":"2024-10-02T10:49:07.983Z","updated_at":"2025-04-23T07:23:35.965Z","avatar_url":"https://github.com/congcoi123.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\nThis project helps you quickly create a web development environment with [PHP-FPM](https://php-fpm.org/), [Nginx](https://www.nginx.com/), [MySQL](https://www.mysql.com/), and [Redis](https://redis.io/). The environment is based on [Amazon Linux 2](https://aws.amazon.com/amazon-linux-2/?nc1=h_ls).\n\n## Technology\n[Docker](https://www.docker.com/) is a set of the platform as service products that use\nOS-level virtualization to deliver software in packages called\ncontainers. Containers are isolated from one another and bundle\ntheir own software, libraries and configuration files; they can\ncommunicate with each other through well-defined channels.\n\n## Test Environment\n**Host machine**\n- MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)\n- OS: macOS Mojave (10.14.2)\n\n**Docker**\n- Version: 2.1.0.4 (39773)\n- Channel: stable\n- Engine: 19.03.4\n\n## License\nThis project is currently available under the [MIT](https://github.com/congcoi123/docker-php-nginx/blob/master/LICENSE) License.\n\n## Installation\nYou can get the sources:\n```sh\ngit clone https://github.com/congcoi123/docker-php-nginx.git\n```\n\n## Manual\n### Project Structure\n![Project Structure](https://github.com/congcoi123/docker-php-nginx/blob/master/screenshots/project_structure.png)\n#### a. docker/ app cache db web\nInclude all of the environment’s settings by Docker for this project.\n#### b. docker/gen/cache\n\u003e \u003c!--Generated by Docker--\u003e\n\nReference to Redis cache ‘s data. The data in this folder will be removed when the Redis’s container is destroyed.\n#### c. docker/gen/data\n\u003e \u003c!--Generated by Docker--\u003e\n\nReference to MySQL ‘s data. The data in this folder will be removed when MySQL’s container is destroyed.\n#### d. docker/gen/logs\n\u003e \u003c!--Generated by Docker--\u003e\n\nReference to all necessary logs by several services (Nginx, MySQL, PHP-fpm, Redis, Xhprof). The logging data will be removed with the destruction of the reference containers.\n#### e. docker/gen/tmp\n\u003e \u003c!--Generated by Docker--\u003e\n\nReference to the `/tmp` folder in the application container.\n#### f. docker/db/dump\nThis folder can be empty. Hold the dummy database for local testing.\n#### g. docker/startup\nInclude all necessary scripts for setting up a development environment by Docker for this project. **`It must be seen first!`**\n#### h. sample-app\nHold the project’s source code. All the changes here will be updated immediately to all services in containers.\n#### i. .env\nHold the environment variables for the development environment.\n#### j. docker-compose.yml\n\u003e \u003c!--Docker file configuration--\u003e\n\nDefine the services that make up your app. So they can be run together in an isolated environment.\n\n### Scripts\n![Scripts](https://github.com/TenMei/docker-php-nginx/blob/master/screenshots/scripts.png)\n\nSaved in the startup folder. Only `docker_setup.sh` script is necessary for this setup.\n#### a. docker_setup.sh\n\u003e \u003c!--The first script for running--\u003e\n\nAutomatic setup of the development environment. Take about 10 minutes for all processes. You can check the log in your console screen.\n#### b. access_application.sh\n\u003e \u003c!--Call by manual--\u003e\n\nQuick access to the development’s container (`amazon-linux:2`)\n#### c. access_nginx.sh\n\u003e \u003c!--Call by manual--\u003e\n\nQuick access to the web service container (`nginx`)\n#### d. env_setup.sh\n\u003e \u003c!--Call by manual--\u003e\n\nThis script is automatically called in the `docker_setup.sh` process. But you can use it manually for running a composer setting.\n#### e. env_status.sh\n\u003e \u003c!--Call by manual--\u003e\n\nCheck the status of the current containers.\n#### f. get_os_name.sh\n\u003e \u003c!--Call by manual--\u003e\n\nCheck the current OS’s name of your host machine.\n#### g. mysql_migrations\n\u003e \u003c!--Call by manual--\u003e\n\nMigrations all the scripts that hold in `/sample-app/migrations`\n\n![MySQL Migration](https://github.com/TenMei/docker-php-nginx/blob/master/screenshots/sample_migrations.png)\n#### h. restart_application.sh\n\u003e \u003c!--Call by manual--\u003e\n\nRestart the current application service. It can be helpful when you want to change some configurations in `php.ini` or `www.conf` (Please make the changes before restarting)\n\n![Restart Application](https://github.com/TenMei/docker-php-nginx/blob/master/screenshots/restart_application.png)\n#### i. restart_nginx.sh\n\u003e \u003c!--Call by manual--\u003e\n\nRestart the current web service (Nginx). It can be helpful when you want to change some configurations in `nginx.conf` file or any files in `web/conf/` folder\n\n![Restart Nginx](https://github.com/TenMei/docker-php-nginx/blob/master/screenshots/restart_nginx.png)\n#### k. start\n\u003e \u003c!--Call by manual--\u003e\n\nStart all services.\n#### l. stop\n\u003e \u003c!--Call by manual--\u003e\n\nStop all services.\n\n### Environment Variables\nAll the environment is saved in the `.env` file.\n\n![Environment Variables](https://github.com/congcoi123/docker-php-nginx/blob/master/screenshots/environment_setting.png)\n#### COMPOSE_PROJECT_NAME\nThe project’s name and identification. Please do not modify it.\n#### WEB_PORT\nNginx service port, because of the containers and host machine share resources. So you can access the program by your browser. Just use: **`localhost:\u003cport\u003e/`** . In my case, I can use **`localhost:8000/`**\n#### WEB_SSL_PORT\nSame with `WEB_PORT` but for SSL.\n#### DB_PORT\nFor preventing conflict with your in-use port in your host machine, you can change the MySQL’s port.\n- **Step 1:**\nChange the `DB_PORT` definition with your new port.\n- **Step 2:**\nMake the change in `/docker/db/conf/my.cnf` file with the same new port.\n![my.cnf](https://github.com/congcoi123/docker-php-nginx/blob/master/screenshots/db_my_cnf.png)\n\n#### FPM_PORT\nFor preventing conflict with your in-use port in your host machine, you can change the PHP-fpm port. FPM is a process manager to manage the FastCGI SAPI (Server API) in PHP. Basically, it replaces the need for something like SpawnFCGI . It spawns the FastCGI children adaptively (meaning launching more if the current load requires it). Otherwise, there's not much operating difference between it and FastCGI (The request pipeline from the start of the request to end is the same). It's just there to make implementing it easier.\n- **Step 1:**\nChange the `FPM_PORT` definition with your new port.\n- **Step 2:**\nMake the same change in `/docker/app/conf/www.conf` file at listen\ndefinition.\n![www.conf](https://github.com/congcoi123/docker-php-nginx/blob/master/screenshots/fpm_conf.png)\n- **Step 3:**\nMake some changes in `/docker/web/conf/nginx.conf` . All the\n`fastcgi_pass` definition must be set to new pattern **`sample_app:\u003cyour_new_port\u003e;`**\nIn my case is **`fastcgi_pass sample_app:9001;`**\n![nginx.conf](https://github.com/congcoi123/docker-php-nginx/blob/master/screenshots/fpm_nginx.png)\n\n### Start\nRun the following instructions for the starting setup.\n```sh\n$cd /docker-php-nginx/docker/startup\n$bash docker_setup.sh\n```\n\n### Notes\n- When you get errors when running the database container, you can delete the old `docker/gen/data` folder and retry again\nPlease note that the data folder holds your real MySQL backup. But if it’s not important for you, it should be deleted (In some case, that folder make some troubles)\n- Access the URL below for starting:\n`http://localhost:\u003c WEB_PORT \u003e`\n. In my case:\n`http://localhost:8000`\n\n\u003e Happy coding !\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcongcoi123%2Fdocker-php-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcongcoi123%2Fdocker-php-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcongcoi123%2Fdocker-php-nginx/lists"}