├── .github └── workflows │ ├── build.yml │ ├── manual-build.yml │ └── tests.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── build.sh ├── src ├── default.conf ├── docker │ ├── 7.2 │ │ └── Dockerfile │ ├── 7.3 │ │ └── Dockerfile │ ├── 7.4 │ │ └── Dockerfile │ ├── 8.0 │ │ └── Dockerfile │ └── Dockerfile ├── entrypoint.sh ├── index.php ├── nginx.conf ├── opcache.ini ├── php.ini └── supervisor │ └── supervisord.conf ├── tests └── compose.yaml └── version /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - main 6 | jobs: 7 | docker: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - 11 | name: Set up QEMU 12 | uses: docker/setup-qemu-action@v2 13 | - 14 | name: Set up Docker Buildx 15 | uses: docker/setup-buildx-action@v2 16 | - 17 | name: Login to DockerHub 18 | uses: docker/login-action@v2 19 | with: 20 | username: ${{ secrets.DOCKERHUB_USERNAME }} 21 | password: ${{ secrets.DOCKERHUB_TOKEN }} 22 | - 23 | name: Build and push 8.1 24 | uses: docker/build-push-action@v3 25 | with: 26 | file: "./src/docker/Dockerfile" 27 | push: true 28 | platforms: linux/amd64,linux/arm64 29 | build-args: | 30 | phpVersion=8.1 31 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1" 32 | - 33 | name: Build and push 8.2 34 | uses: docker/build-push-action@v3 35 | with: 36 | file: "./src/docker/Dockerfile" 37 | push: true 38 | platforms: linux/amd64,linux/arm64 39 | build-args: | 40 | phpVersion=8.2 41 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2" 42 | - 43 | name: Build and push 8.3 44 | uses: docker/build-push-action@v3 45 | with: 46 | file: "./src/docker/Dockerfile" 47 | push: true 48 | platforms: linux/amd64,linux/arm64 49 | build-args: | 50 | phpVersion=8.3 51 | tags: | 52 | "${{vars.BUILDKIT_IMAGE}}:8.3" 53 | - 54 | name: Build and push 8.4 55 | uses: docker/build-push-action@v3 56 | with: 57 | file: "./src/docker/Dockerfile" 58 | push: true 59 | platforms: linux/amd64,linux/arm64 60 | build-args: | 61 | phpVersion=8.4 62 | tags: | 63 | "${{vars.BUILDKIT_IMAGE}}:8.4" 64 | "${{vars.BUILDKIT_IMAGE}}:latest" 65 | -------------------------------------------------------------------------------- /.github/workflows/manual-build.yml: -------------------------------------------------------------------------------- 1 | name: Manual-build 2 | on: 3 | # Allows you to run this workflow manually from the Actions tab 4 | workflow_dispatch: 5 | inputs: 6 | docker_tag: 7 | description: 'Docker tag' 8 | required: true 9 | default: 'latest' 10 | type: string 11 | env: 12 | BUILDKIT_IMAGE: jkaninda/nginx-php-fpm 13 | jobs: 14 | docker: 15 | runs-on: ubuntu-latest 16 | steps: 17 | - 18 | name: Set up QEMU 19 | uses: docker/setup-qemu-action@v2 20 | - 21 | name: Set up Docker Buildx 22 | uses: docker/setup-buildx-action@v2 23 | - 24 | name: Login to DockerHub 25 | uses: docker/login-action@v2 26 | with: 27 | username: ${{ secrets.DOCKERHUB_USERNAME }} 28 | password: ${{ secrets.DOCKERHUB_TOKEN }} 29 | - 30 | name: Build and push 7.2 31 | uses: docker/build-push-action@v3 32 | with: 33 | file: "./src/docker/7.2/Dockerfile" 34 | push: true 35 | tags: "${{env.BUILDKIT_IMAGE}}:7.2" 36 | - 37 | name: Build and push 7.3 38 | uses: docker/build-push-action@v3 39 | with: 40 | file: "./src/docker/7.3/Dockerfile" 41 | push: true 42 | tags: "${{env.BUILDKIT_IMAGE}}:7.3" 43 | - 44 | name: Build and push 7.4 45 | uses: docker/build-push-action@v3 46 | with: 47 | file: "./src/docker/7.4/Dockerfile" 48 | push: true 49 | tags: "${{env.BUILDKIT_IMAGE}}:7.4" 50 | - 51 | name: Build and push 8.0 52 | uses: docker/build-push-action@v3 53 | with: 54 | file: "./src/docker/8.0/Dockerfile" 55 | push: true 56 | platforms: linux/amd64,linux/arm64 57 | tags: "${{env.BUILDKIT_IMAGE}}:8.0" 58 | - 59 | name: Build and push 8.1 60 | uses: docker/build-push-action@v3 61 | with: 62 | file: "./src/docker/Dockerfile" 63 | push: true 64 | platforms: linux/amd64,linux/arm64 65 | build-args: | 66 | phpVersion=8.1 67 | tags: "${{ vars.BUILDKIT_IMAGE }}:8.1" 68 | - 69 | name: Build and push 8.2 70 | uses: docker/build-push-action@v3 71 | with: 72 | file: "./src/docker/Dockerfile" 73 | push: true 74 | platforms: linux/amd64,linux/arm64 75 | build-args: | 76 | phpVersion=8.2 77 | tags: "${{vars.BUILDKIT_IMAGE}}:8.2" 78 | - 79 | name: Build and push 8.3 80 | uses: docker/build-push-action@v3 81 | with: 82 | file: "./src/docker/Dockerfile" 83 | push: true 84 | platforms: linux/amd64,linux/arm64 85 | build-args: | 86 | phpVersion=8.3 87 | tags: | 88 | "${{vars.BUILDKIT_IMAGE}}:8.3" 89 | "${{vars.BUILDKIT_IMAGE}}:latest" 90 | - 91 | name: Build and push 8.4 RC 92 | uses: docker/build-push-action@v3 93 | with: 94 | file: "./src/docker/Dockerfile" 95 | push: true 96 | platforms: linux/amd64,linux/arm64 97 | build-args: | 98 | phpVersion=8.4.0RC4 99 | tags: | 100 | "${{vars.BUILDKIT_IMAGE}}:8.4.0RC4" -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | jobs: 5 | integration: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v4 9 | # Build the Docker image 10 | - name: Build Docker Image 11 | run: | 12 | docker buildx build -f src/docker/Dockerfile --build-arg phpVersion=8.4 -t ${{ vars.BUILDKIT_IMAGE }}:latest --load . 13 | - name: Verify Docker images 14 | run: | 15 | docker images 16 | - name: Create Laravel project 17 | run: | 18 | composer create-project laravel/laravel laravel 19 | - name: Fix Permission 20 | run: chmod -R 777 ./laravel/storage 21 | - name: Run docker-compose 22 | run: 23 | cp ./tests/compose.yaml compose.yaml && 24 | docker compose -f "compose.yaml" up -d 25 | - name: Create script.js for K6 test 26 | run: | 27 | touch script.js && cat > script.js < /dev/null ; do 48 | echo "Waiting for database connection..." 49 | sleep 5 50 | done 51 | - name: Laravel database migration test 52 | run: | 53 | docker exec nginx-php-fpm php artisan migrate -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.history 2 | laravel 3 | docker-compose.yml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Jonas Kaninda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_NAME?=jkaninda/nginx-php-fpm 2 | .PHONY: all 3 | all: build 4 | ##@ Build 5 | .PHONY: build 6 | build: build-81 build-82 build-83 build-84 7 | .PHONY: build-80 8 | build-80: 9 | docker build --build-arg phpVersion=8.0 -f src/docker/8.0/Dockerfile -t ${IMAGE_NAME}:8.0 . 10 | .PHONY: build-81 11 | build-81: 12 | docker build --build-arg phpVersion=8.1 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.1 . 13 | .PHONY: build-82 14 | build-82: 15 | docker build --build-arg phpVersion=8.2 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.2 . 16 | .PHONY: build-83 17 | build-83: 18 | docker build --build-arg phpVersion=8.3 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.3 . 19 | .PHONY: build-84 20 | build-84: 21 | docker build --build-arg phpVersion=8.4 -f src/docker/Dockerfile -t ${IMAGE_NAME}:8.4 . 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 🐳 **Docker Image: Nginx PHP-FPM** 2 | 3 | A **ready-to-use container** designed for running PHP-based applications, including Laravel microservices. This Docker image combines **Nginx** and **PHP-FPM**, offering a robust foundation for your projects with built-in support for essential extensions and configurations. 4 | 5 | [![Build](https://github.com/jkaninda/nginx-php-fpm/actions/workflows/build.yml/badge.svg)](https://github.com/jkaninda/nginx-php-fpm/actions/workflows/build.yml) 6 | [![Tests](https://github.com/jkaninda/nginx-php-fpm/actions/workflows/tests.yml/badge.svg)](https://github.com/jkaninda/nginx-php-fpm/actions/workflows/tests.yml) 7 | ![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/jkaninda/nginx-php-fpm?style=flat-square) 8 | ![Docker Pulls](https://img.shields.io/docker/pulls/jkaninda/nginx-php-fpm?style=flat-square) 9 | 10 | 11 | #### **Features** 12 | - **PHP Application Support**: Optimized to run Laravel or any PHP-based applications. 13 | - **Integrated Extensions**: 14 | - **Database**: MySQL and PostgreSQL. 15 | - **Caching**: Redis and Memcached. 16 | - **Messaging**: Kafka for event-driven architecture. 17 | - **Task Scheduling**: Laravel Scheduler and Cron jobs support. 18 | - **Custom Configuration**: Pre-configured with sensible defaults, allowing seamless customization. 19 | - **Event Handling**: Support for advanced event-driven processes. 20 | - **Optimized for Microservices**: Built with modern PHP microservices in mind. 21 | 22 | This image is ideal for developers looking for a streamlined, high-performance solution to deploy PHP applications with essential tools already integrated. 23 | 24 | --- 25 | ## **Links** 26 | - [Docker Hub](https://hub.docker.com/r/jkaninda/nginx-php-fpm) 27 | - [GitHub Repository](https://github.com/jkaninda/nginx-php-fpm) 28 | 29 | ## **Supported PHP Versions** 30 | - 8.4 31 | - 8.3 32 | - 8.2 33 | - 8.1 34 | - 8.0 35 | - 7.4 36 | - 7.2 37 | 38 | ## **Specifications** 39 | This Docker image comes pre-installed with the following: 40 | - **PHP Extensions**: 41 | - Composer 42 | - OpenSSL 43 | - XML 44 | - PDO 45 | - Rdkafka 46 | - Redis 47 | - Mbstring 48 | - PCNTL 49 | - ZIP 50 | - GD 51 | - BCMath 52 | - Memcached 53 | 54 | - **Additional Features**: 55 | - Laravel Cron Jobs & Scheduler 56 | - Supervisord 57 | - Node.js & NPM 58 | 59 | ## **Basic Usage with Docker Compose** 60 | 61 | ### **Example `docker-compose.yml`** 62 | ```yaml 63 | services: 64 | app: 65 | image: jkaninda/nginx-php-fpm:8.3 66 | container_name: app 67 | restart: unless-stopped 68 | user: www-data # Optional for production 69 | volumes: 70 | # Project root 71 | - ./src:/var/www/html 72 | ports: 73 | - "80:80" 74 | networks: 75 | - default 76 | ``` 77 | 78 | ### **Commands** 79 | 80 | #### Start the service: 81 | ```sh 82 | docker compose up -d 83 | ``` 84 | 85 | #### Create a new Laravel project: 86 | ```sh 87 | docker compose exec app composer create-project --prefer-dist laravel/laravel . 88 | ``` 89 | 90 | #### Generate application key: 91 | ```sh 92 | docker compose exec app php artisan key:generate 93 | ``` 94 | 95 | #### Create a storage symlink: 96 | ```sh 97 | docker compose exec app php artisan storage:link 98 | ``` 99 | 100 | #### Fix storage and cache permissions: 101 | ```sh 102 | docker compose exec app chmod -R 777 storage bootstrap/cache 103 | ``` 104 | 105 | #### Run Laravel migrations: 106 | ```sh 107 | docker compose exec app php artisan migrate 108 | ``` 109 | 110 | #### Access the container shell: 111 | ```sh 112 | docker exec -it app bash 113 | ``` 114 | 115 | --- 116 | 117 | ## **Advanced Nginx PHP-FPM Setup** 118 | 119 | ### **Extended `docker-compose.yml` Example** 120 | ```yaml 121 | version: '3' 122 | services: 123 | app: 124 | image: jkaninda/nginx-php-fpm 125 | container_name: app 126 | restart: unless-stopped 127 | ports: 128 | - "80:80" 129 | volumes: 130 | # Project root 131 | - ./:/var/www/html 132 | - ~/.ssh:/root/.ssh # Use private CVS if needed 133 | # Optional custom PHP config 134 | # - ./php.ini:/usr/local/etc/php/conf.d/php.ini 135 | environment: 136 | - APP_ENV=development # or production 137 | - LARAVEL_PROCS_NUMBER=2 # Optional: Queue worker processes 138 | # - CLIENT_MAX_BODY_SIZE=20M # Optional 139 | # - DOMAIN=example.com # Optional 140 | - DOCUMENT_ROOT=/var/www/html # Optional 141 | ``` 142 | 143 | ### **Default Web Root** 144 | ``` 145 | /var/www/html 146 | ``` 147 | 148 | --- 149 | 150 | ## **Custom Build Example** 151 | 152 | ### **Dockerfile** 153 | ```Dockerfile 154 | FROM jkaninda/nginx-php-fpm:8.3 155 | # Copy Laravel project files 156 | COPY . /var/www/html 157 | # Storage Volume 158 | VOLUME /var/www/html/storage 159 | 160 | WORKDIR /var/www/html 161 | 162 | # Fix permissions 163 | RUN chown -R www-data:www-data /var/www/html 164 | 165 | USER www-data 166 | ``` 167 | 168 | --- 169 | 170 | ## **Custom Nginx Configuration** 171 | 172 | To enable custom Nginx configurations, use the following files: 173 | - `/var/www/html/conf/nginx/nginx.conf` 174 | - `/var/www/html/conf/nginx/nginx-site.conf` 175 | 176 | --- 177 | 178 | ## **Supervisord Integration** 179 | 180 | Supervisord can be used to manage tasks or processes within the container. 181 | 182 | ### **Example Configuration for Kafka Consumer** 183 | ```conf 184 | [program:kafkaconsume-worker] 185 | process_name=%(program_name)s_%(process_num)02d 186 | command=php /var/www/html/artisan kafka:consumer 187 | autostart=true 188 | autorestart=true 189 | numprocs=1 190 | user=www-data 191 | redirect_stderr=true 192 | stdout_logfile=/var/www/html/storage/logs/kafka.log 193 | ``` 194 | 195 | --- 196 | 197 | ## **Fixing Storage Permissions** 198 | 199 | If you encounter storage permission issues, run the following commands: 200 | 201 | ```sh 202 | docker compose exec php-fpm /bin/bash 203 | ``` 204 | 205 | Then inside the container: 206 | ```sh 207 | chown -R www-data:www-data /var/www/html/ 208 | chmod -R 775 /var/www/html/storage 209 | ``` 210 | 211 | --- 212 | 213 | ## **Star the Project** 214 | 215 | If you find this project useful, please give it a ⭐️ on GitHub to show your support! 😊 216 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# -eq 0 ] 3 | then 4 | tag='latest' 5 | else 6 | tag=$1 7 | fi 8 | if [ $tag != 'latest' ] 9 | then 10 | echo 'Build from tag' 11 | docker build -f src/docker/${tag}/Dockerfile -t jkaninda/nginx-php-fpm:$tag . 12 | else 13 | echo 'Build latest' 14 | docker build -f src/docker/8.3/Dockerfile -t jkaninda/nginx-php-fpm:$tag . 15 | 16 | fi 17 | docker compose up -d --force-recreate 18 | -------------------------------------------------------------------------------- /src/default.conf: -------------------------------------------------------------------------------- 1 | 2 | server { 3 | listen 80 default_server; 4 | listen [::]:80 default_server; 5 | server_name _; 6 | # Add index.php to setup Nginx, PHP & PHP-FPM config 7 | index index.php index.html index.htm index.nginx-debian.html; error_log /var/log/nginx/error.log; 8 | access_log /var/log/nginx/access.log; 9 | root /var/www/html; 10 | # pass PHP scripts on Nginx to FastCGI (PHP-FPM) server 11 | location ~ \.php$ { 12 | try_files $uri =404; 13 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 14 | # Nginx php-fpm config: 15 | fastcgi_pass 127.0.0.1:9000; 16 | fastcgi_index index.php; 17 | include fastcgi_params; 18 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 19 | fastcgi_param PATH_INFO $fastcgi_path_info; 20 | 21 | } 22 | client_max_body_size 15M; 23 | server_tokens off; 24 | 25 | # Hide PHP headers 26 | fastcgi_hide_header X-Powered-By; 27 | fastcgi_hide_header X-CF-Powered-By; 28 | fastcgi_hide_header X-Runtime; 29 | 30 | location / { 31 | try_files $uri $uri/ /index.php?$query_string; 32 | gzip_static on; 33 | } 34 | # deny access to Apache .htaccess on Nginx with PHP, 35 | # if Apache and Nginx document roots concur 36 | location ~ /\.ht {deny all;} 37 | location ~ /\.svn/ {deny all;} 38 | location ~ /\.git/ {deny all;} 39 | location ~ /\.hg/ {deny all;} 40 | location ~ /\.bzr/ {deny all;} 41 | } -------------------------------------------------------------------------------- /src/docker/7.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV DOMAIN=_ 6 | ENV CLIENT_MAX_BODY_SIZE=15M 7 | ENV NODE_VERSION=17.x 8 | ARG GROUP_ID=1000 9 | ARG USER_ID=1000 10 | ENV USER_NAME=www-data 11 | ARG GROUP_NAME=www-data 12 | # Install system dependencies 13 | RUN apt-get update && apt-get install -y \ 14 | git \ 15 | curl \ 16 | libfreetype6-dev \ 17 | libjpeg62-turbo-dev \ 18 | libmemcached-dev \ 19 | libzip-dev \ 20 | libpng-dev \ 21 | libonig-dev \ 22 | libxml2-dev \ 23 | librdkafka-dev \ 24 | libpq-dev \ 25 | openssh-server \ 26 | zip \ 27 | unzip \ 28 | supervisor \ 29 | sqlite3 \ 30 | nano \ 31 | cron 32 | 33 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 34 | # Install Node 35 | RUN apt-get install -y nodejs 36 | # Install nginx 37 | RUN apt-get update && apt-get install -y nginx 38 | 39 | # Clear cache 40 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 41 | 42 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 43 | RUN docker-php-ext-configure gd 44 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 45 | 46 | # Install Redis and enable it 47 | RUN pecl install redis && docker-php-ext-enable redis 48 | 49 | 50 | 51 | # Install the php memcached extension 52 | RUN pecl install memcached && docker-php-ext-enable memcached 53 | 54 | # Install the PHP pdo_mysql extention 55 | RUN docker-php-ext-install pdo_mysql 56 | 57 | # Install the PHP pdo_pgsql extention 58 | RUN docker-php-ext-install pdo_pgsql 59 | # Install PHP Opcache extention 60 | RUN docker-php-ext-install opcache 61 | 62 | # Install Composer 63 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 64 | 65 | # Set working directory 66 | WORKDIR $WORKDIR 67 | 68 | RUN rm -Rf /var/www/* && \ 69 | mkdir -p /var/www/html 70 | 71 | ADD src/index.php $WORKDIR/index.php 72 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 73 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 74 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 75 | 76 | COPY src/entrypoint.sh /usr/local/bin/ 77 | RUN chmod +x /usr/local/bin/entrypoint.sh 78 | RUN ln -s /usr/local/bin/entrypoint.sh / 79 | 80 | RUN rm -rf /etc/nginx/conf.d/default.conf 81 | RUN rm -rf /etc/nginx/sites-enabled/default 82 | RUN rm -rf /etc/nginx/sites-available/default 83 | 84 | RUN rm -rf /etc/nginx/nginx.conf 85 | 86 | COPY src/nginx.conf /etc/nginx/nginx.conf 87 | COPY src/default.conf /etc/nginx/conf.d/ 88 | 89 | RUN usermod -u ${USER_ID} ${USER_NAME} 90 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 91 | 92 | RUN mkdir -p /var/log/supervisor 93 | RUN mkdir -p /var/log/nginx 94 | RUN mkdir -p /var/cache/nginx 95 | 96 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 97 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 98 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 99 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 100 | touch /var/run/nginx.pid && \ 101 | chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ 102 | chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ 103 | chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ 104 | chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ 105 | chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ 106 | chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ 107 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 108 | 109 | 110 | #USER ${USER_NAME} 111 | EXPOSE 80 112 | ENTRYPOINT ["entrypoint.sh"] -------------------------------------------------------------------------------- /src/docker/7.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.3-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV DOMAIN=_ 6 | ENV CLIENT_MAX_BODY_SIZE=15M 7 | ENV NODE_VERSION=17.x 8 | ARG GROUP_ID=1000 9 | ARG USER_ID=1000 10 | ENV USER_NAME=www-data 11 | ARG GROUP_NAME=www-data 12 | # Install system dependencies 13 | RUN apt-get update && apt-get install -y \ 14 | git \ 15 | curl \ 16 | libfreetype6-dev \ 17 | libjpeg62-turbo-dev \ 18 | libmemcached-dev \ 19 | libzip-dev \ 20 | libpng-dev \ 21 | libonig-dev \ 22 | libxml2-dev \ 23 | librdkafka-dev \ 24 | libpq-dev \ 25 | openssh-server \ 26 | zip \ 27 | unzip \ 28 | supervisor \ 29 | sqlite3 \ 30 | nano \ 31 | cron 32 | 33 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 34 | # Install Node 35 | RUN apt-get install -y nodejs 36 | # Install nginx 37 | RUN apt-get update && apt-get install -y nginx 38 | 39 | # Clear cache 40 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 41 | 42 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 43 | RUN docker-php-ext-configure gd 44 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 45 | 46 | # Install Redis and enable it 47 | RUN pecl install redis && docker-php-ext-enable redis 48 | 49 | 50 | 51 | # Install the php memcached extension 52 | RUN pecl install memcached && docker-php-ext-enable memcached 53 | 54 | # Install the PHP pdo_mysql extention 55 | RUN docker-php-ext-install pdo_mysql 56 | 57 | # Install the PHP pdo_pgsql extention 58 | RUN docker-php-ext-install pdo_pgsql 59 | # Install PHP Opcache extention 60 | RUN docker-php-ext-install opcache 61 | 62 | # Install Composer 63 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 64 | 65 | # Set working directory 66 | WORKDIR $WORKDIR 67 | 68 | RUN rm -Rf /var/www/* && \ 69 | mkdir -p /var/www/html 70 | 71 | ADD src/index.php $WORKDIR/index.php 72 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 73 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 74 | 75 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 76 | 77 | COPY src/entrypoint.sh /usr/local/bin/ 78 | RUN chmod +x /usr/local/bin/entrypoint.sh 79 | RUN ln -s /usr/local/bin/entrypoint.sh / 80 | 81 | RUN rm -rf /etc/nginx/conf.d/default.conf 82 | RUN rm -rf /etc/nginx/sites-enabled/default 83 | RUN rm -rf /etc/nginx/sites-available/default 84 | 85 | RUN rm -rf /etc/nginx/nginx.conf 86 | 87 | COPY src/nginx.conf /etc/nginx/nginx.conf 88 | COPY src/default.conf /etc/nginx/conf.d/ 89 | 90 | RUN usermod -u ${USER_ID} ${USER_NAME} 91 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 92 | 93 | RUN mkdir -p /var/log/supervisor 94 | RUN mkdir -p /var/log/nginx 95 | RUN mkdir -p /var/cache/nginx 96 | 97 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 98 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 99 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 100 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 101 | touch /var/run/nginx.pid && \ 102 | chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ 103 | chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ 104 | chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ 105 | chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ 106 | chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ 107 | chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ 108 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 109 | 110 | 111 | #USER ${USER_NAME} 112 | EXPOSE 80 113 | ENTRYPOINT ["entrypoint.sh"] -------------------------------------------------------------------------------- /src/docker/7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV DOMAIN=_ 6 | ENV CLIENT_MAX_BODY_SIZE=15M 7 | ENV NODE_VERSION=17.x 8 | ARG GROUP_ID=1000 9 | ARG USER_ID=1000 10 | ENV USER_NAME=www-data 11 | ARG GROUP_NAME=www-data 12 | # Install system dependencies 13 | RUN apt-get update && apt-get install -y \ 14 | git \ 15 | curl \ 16 | libfreetype6-dev \ 17 | libjpeg62-turbo-dev \ 18 | libmemcached-dev \ 19 | libzip-dev \ 20 | libpng-dev \ 21 | libonig-dev \ 22 | libxml2-dev \ 23 | librdkafka-dev \ 24 | libpq-dev \ 25 | openssh-server \ 26 | zip \ 27 | unzip \ 28 | supervisor \ 29 | sqlite3 \ 30 | nano \ 31 | cron 32 | 33 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 34 | # Install Node 35 | RUN apt-get install -y nodejs 36 | # Install nginx 37 | RUN apt-get update && apt-get install -y nginx 38 | 39 | # Clear cache 40 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 41 | 42 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 43 | RUN docker-php-ext-configure gd 44 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 45 | 46 | # Install Redis and enable it 47 | RUN pecl install redis && docker-php-ext-enable redis 48 | 49 | 50 | 51 | # Install the php memcached extension 52 | RUN pecl install memcached && docker-php-ext-enable memcached 53 | 54 | # Install the PHP pdo_mysql extention 55 | RUN docker-php-ext-install pdo_mysql 56 | 57 | # Install the PHP pdo_pgsql extention 58 | RUN docker-php-ext-install pdo_pgsql 59 | # Install PHP Opcache extention 60 | RUN docker-php-ext-install opcache 61 | 62 | # Install Composer 63 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 64 | 65 | # Set working directory 66 | WORKDIR $WORKDIR 67 | 68 | RUN rm -Rf /var/www/* && \ 69 | mkdir -p /var/www/html 70 | 71 | ADD src/index.php $WORKDIR/index.php 72 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 73 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 74 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 75 | 76 | COPY src/entrypoint.sh /usr/local/bin/ 77 | RUN chmod +x /usr/local/bin/entrypoint.sh 78 | RUN ln -s /usr/local/bin/entrypoint.sh / 79 | 80 | RUN rm -rf /etc/nginx/conf.d/default.conf 81 | RUN rm -rf /etc/nginx/sites-enabled/default 82 | RUN rm -rf /etc/nginx/sites-available/default 83 | 84 | RUN rm -rf /etc/nginx/nginx.conf 85 | 86 | COPY src/nginx.conf /etc/nginx/nginx.conf 87 | COPY src/default.conf /etc/nginx/conf.d/ 88 | 89 | RUN usermod -u ${USER_ID} ${USER_NAME} 90 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 91 | 92 | RUN mkdir -p /var/log/supervisor 93 | RUN mkdir -p /var/log/nginx 94 | RUN mkdir -p /var/cache/nginx 95 | 96 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 97 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 98 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 99 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 100 | touch /var/run/nginx.pid && \ 101 | chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ 102 | chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ 103 | chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ 104 | chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ 105 | chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ 106 | chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ 107 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 108 | 109 | 110 | #USER ${USER_NAME} 111 | EXPOSE 80 112 | ENTRYPOINT ["entrypoint.sh"] -------------------------------------------------------------------------------- /src/docker/8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0-fpm 2 | ARG WORKDIR=/var/www/html 3 | ENV DOCUMENT_ROOT=${WORKDIR} 4 | ENV LARAVEL_PROCS_NUMBER=1 5 | ENV DOMAIN=_ 6 | ENV CLIENT_MAX_BODY_SIZE=15M 7 | ENV NODE_VERSION=17.x 8 | ARG GROUP_ID=1000 9 | ARG USER_ID=1000 10 | ENV USER_NAME=www-data 11 | ARG GROUP_NAME=www-data 12 | # Install system dependencies 13 | RUN apt-get update && apt-get install -y \ 14 | git \ 15 | curl \ 16 | libfreetype6-dev \ 17 | libjpeg62-turbo-dev \ 18 | libmemcached-dev \ 19 | libzip-dev \ 20 | libpng-dev \ 21 | libonig-dev \ 22 | libxml2-dev \ 23 | librdkafka-dev \ 24 | libpq-dev \ 25 | openssh-server \ 26 | zip \ 27 | unzip \ 28 | supervisor \ 29 | sqlite3 \ 30 | nano \ 31 | cron 32 | 33 | RUN curl -sL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 34 | # Install Node 35 | RUN apt-get install -y nodejs 36 | # Install nginx 37 | RUN apt-get update && apt-get install -y nginx 38 | 39 | # Clear cache 40 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 41 | # Install Kafka 42 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 43 | && cd php-rdkafka \ 44 | && phpize \ 45 | && ./configure \ 46 | && make all -j 5 \ 47 | && make install 48 | 49 | # Install Rdkafka and enable it 50 | RUN docker-php-ext-enable rdkafka \ 51 | && cd .. \ 52 | && rm -rf /php-rdkafka 53 | 54 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 55 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 56 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 57 | 58 | # Install Redis and enable it 59 | RUN pecl install redis && docker-php-ext-enable redis 60 | 61 | 62 | 63 | # Install the php memcached extension 64 | RUN pecl install memcached && docker-php-ext-enable memcached 65 | 66 | # Install the PHP pdo_mysql extention 67 | RUN docker-php-ext-install pdo_mysql 68 | 69 | # Install the PHP pdo_pgsql extention 70 | RUN docker-php-ext-install pdo_pgsql 71 | # Install PHP Opcache extention 72 | RUN docker-php-ext-install opcache 73 | 74 | # Install Composer 75 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 76 | 77 | # Set working directory 78 | WORKDIR $WORKDIR 79 | 80 | RUN rm -Rf /var/www/* && \ 81 | mkdir -p /var/www/html 82 | 83 | ADD src/index.php $WORKDIR/index.php 84 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 85 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 86 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 87 | 88 | COPY src/entrypoint.sh /usr/local/bin/ 89 | RUN chmod +x /usr/local/bin/entrypoint.sh 90 | RUN ln -s /usr/local/bin/entrypoint.sh / 91 | 92 | RUN rm -rf /etc/nginx/conf.d/default.conf 93 | RUN rm -rf /etc/nginx/sites-enabled/default 94 | RUN rm -rf /etc/nginx/sites-available/default 95 | 96 | RUN rm -rf /etc/nginx/nginx.conf 97 | 98 | COPY src/nginx.conf /etc/nginx/nginx.conf 99 | COPY src/default.conf /etc/nginx/conf.d/ 100 | 101 | RUN usermod -u ${USER_ID} ${USER_NAME} 102 | RUN groupmod -g ${USER_ID} ${GROUP_NAME} 103 | 104 | RUN mkdir -p /var/log/supervisor 105 | RUN mkdir -p /var/log/nginx 106 | RUN mkdir -p /var/cache/nginx 107 | 108 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 109 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 110 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 111 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 112 | touch /var/run/nginx.pid && \ 113 | chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ 114 | chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ 115 | chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ 116 | chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ 117 | chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ 118 | chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ 119 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 120 | 121 | 122 | #USER ${USER_NAME} 123 | EXPOSE 80 124 | ENTRYPOINT ["entrypoint.sh"] -------------------------------------------------------------------------------- /src/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG phpVersion=8.3-dev 2 | FROM php:${phpVersion}-fpm 3 | ARG WORKDIR=/var/www/html 4 | ENV DOCUMENT_ROOT=${WORKDIR} 5 | ENV LARAVEL_PROCS_NUMBER=1 6 | ENV DOMAIN=_ 7 | ENV CLIENT_MAX_BODY_SIZE=15M 8 | ENV NODE_VERSION=20.x 9 | ARG GROUP_ID=1000 10 | ARG USER_ID=1000 11 | ENV USER_NAME=www-data 12 | ARG GROUP_NAME=www-data 13 | # Install system dependencies 14 | RUN apt-get update && apt-get install -y \ 15 | git \ 16 | curl \ 17 | libfreetype6-dev \ 18 | libjpeg62-turbo-dev \ 19 | libmemcached-dev \ 20 | libzip-dev \ 21 | libpng-dev \ 22 | libonig-dev \ 23 | libxml2-dev \ 24 | librdkafka-dev \ 25 | libpq-dev \ 26 | openssh-server \ 27 | zip \ 28 | unzip \ 29 | supervisor \ 30 | sqlite3 \ 31 | nano \ 32 | cron 33 | 34 | RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION} | bash - 35 | # Install Node 36 | RUN apt-get install -y nodejs 37 | # Install nginx 38 | RUN apt-get update && apt-get install -y nginx 39 | 40 | # Clear cache 41 | RUN apt-get clean && rm -rf /var/lib/apt/lists/* 42 | # Install Kafka 43 | RUN git clone https://github.com/arnaud-lb/php-rdkafka.git\ 44 | && cd php-rdkafka \ 45 | && phpize \ 46 | && ./configure \ 47 | && make all -j 5 \ 48 | && make install 49 | 50 | # Install Rdkafka and enable it 51 | RUN docker-php-ext-enable rdkafka \ 52 | && cd .. \ 53 | && rm -rf /php-rdkafka 54 | 55 | # Install PHP extensions zip, mbstring, exif, bcmath, intl 56 | RUN docker-php-ext-configure gd --with-freetype --with-jpeg 57 | RUN docker-php-ext-install zip mbstring exif pcntl bcmath -j$(nproc) gd intl 58 | 59 | # Install Redis and enable it 60 | RUN pecl install redis && docker-php-ext-enable redis 61 | 62 | 63 | 64 | # Install the php memcached extension 65 | RUN pecl install memcached && docker-php-ext-enable memcached 66 | 67 | # Install the PHP pdo_mysql extention 68 | RUN docker-php-ext-install pdo_mysql 69 | 70 | # Install the PHP pdo_pgsql extention 71 | RUN docker-php-ext-install pdo_pgsql 72 | 73 | # Install PHP Opcache extention 74 | RUN docker-php-ext-install opcache 75 | 76 | # Install Composer 77 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 78 | 79 | # Set working directory 80 | WORKDIR $WORKDIR 81 | 82 | RUN rm -Rf /var/www/* && \ 83 | mkdir -p /var/www/html 84 | 85 | ADD src/index.php $WORKDIR/index.php 86 | ADD src/php.ini $PHP_INI_DIR/conf.d/ 87 | ADD src/opcache.ini $PHP_INI_DIR/conf.d/ 88 | ADD src/supervisor/supervisord.conf /etc/supervisor/supervisord.conf 89 | 90 | COPY src/entrypoint.sh /usr/local/bin/ 91 | RUN chmod +x /usr/local/bin/entrypoint.sh && \ 92 | ln -s /usr/local/bin/entrypoint.sh / 93 | 94 | RUN rm -rf /etc/nginx/conf.d/default.conf && \ 95 | rm -rf /etc/nginx/sites-enabled/default && \ 96 | rm -rf /etc/nginx/sites-available/default && \ 97 | rm -rf /etc/nginx/nginx.conf 98 | 99 | COPY src/nginx.conf /etc/nginx/nginx.conf 100 | COPY src/default.conf /etc/nginx/conf.d/ 101 | 102 | RUN usermod -u ${USER_ID} ${USER_NAME} && \ 103 | groupmod -g ${USER_ID} ${GROUP_NAME} 104 | 105 | RUN mkdir -p /var/log/supervisor /var/log/nginx /var/cache/nginx 106 | 107 | RUN chown -R ${USER_NAME}:${GROUP_NAME} /var/www && \ 108 | chown -R ${USER_NAME}:${GROUP_NAME} /var/log/ && \ 109 | chown -R ${USER_NAME}:${GROUP_NAME} /etc/supervisor/conf.d/ && \ 110 | chown -R ${USER_NAME}:${GROUP_NAME} $PHP_INI_DIR/conf.d/ && \ 111 | touch /var/run/nginx.pid && \ 112 | chown -R $USER_NAME:$USER_NAME /var/cache/nginx && \ 113 | chown -R $USER_NAME:$USER_NAME /var/lib/nginx/ && \ 114 | chown -R $USER_NAME:$USER_NAME /etc/nginx/nginx.conf && \ 115 | chown -R $USER_NAME:$USER_NAME /var/run/nginx.pid && \ 116 | chown -R $USER_NAME:$USER_NAME /var/log/supervisor && \ 117 | chown -R $USER_NAME:$USER_NAME /etc/nginx/conf.d/ && \ 118 | chown -R ${USER_NAME}:${GROUP_NAME} /tmp 119 | 120 | 121 | #USER ${USER_NAME} 122 | EXPOSE 80 123 | ENTRYPOINT ["entrypoint.sh"] -------------------------------------------------------------------------------- /src/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | echo "" 6 | echo "***********************************************************" 7 | echo " Starting NGINX PHP-FPM Docker Container " 8 | echo "***********************************************************" 9 | 10 | # Logging functions 11 | info() { echo "[INFO] $*"; } 12 | warning() { echo "[WARNING] $*"; } 13 | fatal() { echo "[ERROR] $*" >&2; exit 1; } 14 | 15 | ARTISAN_FILE="/var/www/html/artisan" 16 | SUPERVISOR_CONF_DIR="/etc/supervisor/conf.d" 17 | NGINX_CONF_DIR="/etc/nginx/conf.d" 18 | CUSTOM_NGINX_CONF="/var/www/html/conf/nginx" 19 | CUSTOM_SUPERVISOR_CONF="/var/www/html/conf/worker/supervisor.conf" 20 | DOCUMENT_ROOT="/var/www/html/public" 21 | 22 | # Laravel Supervisor Setup 23 | setup_laravel_supervisor() { 24 | info "Artisan file found, creating Laravel supervisor config" 25 | export DOCUMENT_ROOT 26 | 27 | cat > "$SUPERVISOR_CONF_DIR/laravel-worker.conf" < "$NGINX_CONF_DIR/default.conf" < -------------------------------------------------------------------------------- /src/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes auto; 3 | error_log /var/log/nginx/error.log crit; 4 | pid /var/run/nginx.pid; 5 | include /etc/nginx/modules-enabled/*.conf; 6 | 7 | events { 8 | worker_connections 1024; 9 | use epoll; 10 | multi_accept on; 11 | } 12 | http { 13 | sendfile on; 14 | tcp_nopush on; 15 | tcp_nodelay on; 16 | client_header_timeout 3m; 17 | client_body_timeout 3m; 18 | client_max_body_size 256m; 19 | client_header_buffer_size 4k; 20 | client_body_buffer_size 256k; 21 | large_client_header_buffers 4 32k; 22 | send_timeout 3m; 23 | keepalive_timeout 60 60; 24 | reset_timedout_connection on; 25 | server_names_hash_max_size 1024; 26 | server_names_hash_bucket_size 1024; 27 | ignore_invalid_headers on; 28 | connection_pool_size 256; 29 | request_pool_size 4k; 30 | output_buffers 4 32k; 31 | postpone_output 1460; 32 | 33 | include mime.types; 34 | default_type application/octet-stream; 35 | 36 | 37 | 38 | # Compression gzip 39 | gzip on; 40 | gzip_vary on; 41 | gzip_disable "MSIE [1-6]\."; 42 | gzip_proxied any; 43 | gzip_min_length 512; 44 | gzip_comp_level 6; 45 | gzip_buffers 8 64k; 46 | gzip_types text/plain text/xml text/css text/js application/x-javascript application/xml image/png image/x-icon image/gif image/jpeg image/svg+xml application/xml+rss text/javascript application/atom+xml application/javascript application/json application/x-font-ttf font/opentype; 47 | 48 | # Proxy settings 49 | proxy_redirect off; 50 | proxy_http_version 1.1; 51 | proxy_set_header Host $host; 52 | proxy_set_header X-Real-IP $remote_addr; 53 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 54 | proxy_set_header Upgrade $http_upgrade; 55 | proxy_set_header Connection 'upgrade'; 56 | proxy_cache_bypass $http_upgrade; 57 | proxy_pass_header Set-Cookie; 58 | proxy_connect_timeout 300; 59 | proxy_send_timeout 300; 60 | proxy_read_timeout 300; 61 | proxy_buffers 32 4k; 62 | proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=512m; 63 | proxy_cache_key "$host$request_uri $cookie_user"; 64 | proxy_temp_path /var/cache/nginx/temp; 65 | proxy_ignore_headers Expires Cache-Control; 66 | proxy_cache_use_stale error timeout invalid_header http_502; 67 | proxy_cache_valid any 1d; 68 | server_tokens off; 69 | 70 | 71 | 72 | include /etc/nginx/conf.d/*.conf; 73 | } -------------------------------------------------------------------------------- /src/opcache.ini: -------------------------------------------------------------------------------- 1 | [opcache] 2 | ; Determines if Zend OPCache is enabled 3 | opcache.enable=1 4 | 5 | ; Determines if Zend OPCache is enabled for the CLI version of PHP 6 | ;opcache.enable_cli=1 7 | 8 | ; The OPcache shared memory storage size. 9 | opcache.memory_consumption=512 10 | 11 | ; The amount of memory for interned strings in Mbytes. 12 | opcache.interned_strings_buffer=64 13 | 14 | ; The maximum number of keys (scripts) in the OPcache hash table. 15 | ; Only numbers between 200 and 1000000 are allowed. 16 | ;If you have multiple PHP sites on the server then consider the value 130986 17 | ; for magento 2, keep 65406 18 | opcache.max_accelerated_files=50000 19 | 20 | ; The maximum percentage of "wasted" memory until a restart is scheduled. 21 | opcache.max_wasted_percentage=15 22 | 23 | ; When this directive is enabled, the OPcache appends the current working 24 | ; directory to the script key, thus eliminating possible collisions between 25 | ; files with the same name (basename). Disabling the directive improves 26 | ; performance, but may break existing applications. 27 | ;opcache.use_cwd=1 28 | 29 | ; When disabled, you must reset the OPcache manually or restart the 30 | ; webserver for changes to the filesystem to take effect. 31 | ; For Development / testing, keep 1 32 | ; For performance / production, keep 0 33 | opcache.validate_timestamps=0 34 | 35 | ;opcache.revalidate_freq How often in seconds should the code 36 | ;cache expire and check if your code has changed. 0 means it 37 | ;checks your PHP code every single request IF YOU HAVE 38 | ;opcache.validate_timestamps ENABLED. opcache.validate_timestamps 39 | ;should not be enabled by default, as long as it's disabled then any value for opcache. 40 | ;revalidate_freq will basically be ignored. You should really only ever enable 41 | ;this during development, you don't really want to enable this setting for a production application. 42 | opcache.revalidate_freq=0 43 | 44 | ; Enables or disables file search in include_path optimization 45 | ;opcache.revalidate_path=0 46 | 47 | ; If disabled, all PHPDoc comments are dropped from the code to reduce the 48 | ; size of the optimized code. 49 | opcache.save_comments=1 50 | 51 | ; If enabled, a fast shutdown sequence is used for the accelerated code 52 | ; Depending on the used Memory Manager this may cause some incompatibilities. 53 | opcache.fast_shutdown=1 54 | 55 | ; Allow file existence override (file_exists, etc.) performance feature. 56 | ;opcache.enable_file_override=0 57 | 58 | ; A bitmask, where each bit enables or disables the appropriate OPcache 59 | ; passes 60 | ;opcache.optimization_level=0xffffffff 61 | 62 | ;opcache.inherited_hack=1 63 | ;opcache.dups_fix=0 64 | 65 | ; The location of the OPcache blacklist file (wildcards allowed). 66 | ; Each OPcache blacklist file is a text file that holds the names of files 67 | ; that should not be accelerated. The file format is to add each filename 68 | ; to a new line. The filename may be a full path or just a file prefix 69 | ; (i.e., /var/www/x blacklists all the files and directories in /var/www 70 | ; that start with 'x'). Line starting with a ; are ignored (comments). 71 | ;opcache.blacklist_filename= 72 | 73 | ; Allows exclusion of large files from being cached. By default all files 74 | ; are cached. 75 | ;opcache.max_file_size=0 76 | 77 | ; Check the cache checksum each N requests. 78 | ; The default value of "0" means that the checks are disabled. 79 | ;opcache.consistency_checks=0 80 | 81 | ; How long to wait (in seconds) for a scheduled restart to begin if the cache 82 | ; is not being accessed. 83 | ;opcache.force_restart_timeout=180 84 | 85 | ; OPcache error_log file name. Empty string assumes "stderr". 86 | ;opcache.error_log= 87 | 88 | ; All OPcache errors go to the Web server log. 89 | ; By default, only fatal errors (level 0) or errors (level 1) are logged. 90 | ; You can also enable warnings (level 2), info messages (level 3) or 91 | ; debug messages (level 4). 92 | ;opcache.log_verbosity_level=1 93 | 94 | ; Preferred Shared Memory back-end. Leave empty and let the system decide. 95 | ;opcache.preferred_memory_model= 96 | 97 | ; Protect the shared memory from unexpected writing during script execution. 98 | ; Useful for internal debugging only. 99 | ;opcache.protect_memory=0 100 | 101 | ; Allows calling OPcache API functions only from PHP scripts which path is 102 | ; started from specified string. The default "" means no restriction 103 | ;opcache.restrict_api= 104 | 105 | ; Mapping base of shared memory segments (for Windows only). All the PHP 106 | ; processes have to map shared memory into the same address space. This 107 | ; directive allows to manually fix the "Unable to reattach to base address" 108 | ; errors. 109 | opcache.mmap_base=0x20000000 110 | 111 | ; Enables and sets the second level cache directory. 112 | ; It should improve performance when SHM memory is full, at server restart or 113 | ; SHM reset. The default "" disables file based caching. 114 | ;opcache.file_cache= 115 | 116 | ; Enables or disables opcode caching in shared memory. 117 | ;opcache.file_cache_only=0 118 | 119 | ; Enables or disables checksum validation when script loaded from file cache. 120 | ;opcache.file_cache_consistency_checks=1 121 | 122 | ; Implies opcache.file_cache_only=1 for a certain process that failed to 123 | ; reattach to the shared memory (for Windows only). Explicitly enabled file 124 | ; cache is required. 125 | opcache.file_cache_fallback=1 126 | 127 | ; Enables or disables copying of PHP code (text segment) into HUGE PAGES. 128 | ; This should improve performance, but requires appropriate OS configuration. 129 | ;opcache.huge_code_pages=1 130 | 131 | ; Validate cached file permissions. 132 | ; opcache.validate_permission=0 133 | 134 | ; Prevent name collisions in chroot'ed environment. 135 | ; opcache.validate_root=0 -------------------------------------------------------------------------------- /src/php.ini: -------------------------------------------------------------------------------- 1 | date.timezone=UTC 2 | display_errors=Off 3 | log_errors=On 4 | upload_max_filesize= 80M 5 | post_max_size= 80M 6 | memory_limit = 256M 7 | -------------------------------------------------------------------------------- /src/supervisor/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=www-data 4 | logfile=/var/log/supervisor/supervisord.log 5 | logfile_maxbytes = 50MB 6 | pidfile=/tmp/supervisord.pid 7 | directory = /tmp 8 | 9 | 10 | [program:php-fpm] 11 | command=/usr/local/sbin/php-fpm 12 | numprocs=1 13 | autostart=true 14 | autorestart=true 15 | stderr_logfile=/var/log/supervisor/php-fpm.err.log 16 | stdout_logfile=/var/log/supervisor/php-fpm.out.log 17 | user=www-data 18 | priority=1 19 | 20 | [program:nginx] 21 | command=/usr/sbin/nginx -g "daemon off;" 22 | numprocs=1 23 | autostart=true 24 | autorestart=true 25 | stderr_logfile=/var/log/nginx/nginx.err.log 26 | stdout_logfile=/var/log/nginx/nginx.out.log 27 | logfile_maxbytes = 50MB 28 | user=www-data 29 | priority=2 30 | 31 | [include] 32 | files = /etc/supervisor/conf.d/*.conf -------------------------------------------------------------------------------- /tests/compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mysql: 4 | image: mysql:8.0 5 | container_name: mysql 6 | restart: unless-stopped 7 | environment: 8 | MYSQL_DATABASE: php 9 | MYSQL_ROOT_PASSWORD: password 10 | MYSQL_PASSWORD: password 11 | MYSQL_USER: php 12 | ports: 13 | - 3306:3306 14 | nginx-php-fpm: 15 | image: jkaninda/nginx-php-fpm:latest 16 | container_name: nginx-php-fpm 17 | restart: unless-stopped 18 | depends_on: 19 | - mysql 20 | environment: 21 | DB_HOST: mysql 22 | DB_PORT: 3306 23 | DB_DATABASE: php 24 | DB_USERNAME: php 25 | DB_PASSWORD: password 26 | volumes: 27 | #Project root 28 | - ./laravel:/var/www/html 29 | ports: 30 | - 80:80 31 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jkaninda/nginx-php-fpm/091ebc6b096bc2c3d403146f9dbdc61f02080e7b/version --------------------------------------------------------------------------------