From 186b09e37e6d19347f2f264ea2ed75ffdd1b0d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Primo=C5=BE=20Poker=C5=BEnik?= Date: Wed, 15 May 2024 10:53:46 +0200 Subject: [PATCH] Add PHP --- PHP/Dockerfile | 13 +++++++++++++ PHP/docker-compose.yml | 22 ++++++++++++++++++++++ PHP/nginx.conf | 29 +++++++++++++++++++++++++++++ PHP/php-logging.conf | 2 ++ 4 files changed, 66 insertions(+) create mode 100644 PHP/Dockerfile create mode 100644 PHP/docker-compose.yml create mode 100644 PHP/nginx.conf create mode 100644 PHP/php-logging.conf diff --git a/PHP/Dockerfile b/PHP/Dockerfile new file mode 100644 index 0000000..98caf22 --- /dev/null +++ b/PHP/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.2-fpm + +RUN apt-get update && \ + apt-get install -y zip curl libcurl3-dev libzip-dev libpng-dev libonig-dev libxml2-dev + +RUN docker-php-ext-install curl gd mbstring mysqli pdo pdo_mysql xml + +RUN apt-get install -y libmagickwand-dev +RUN pecl install imagick +RUN docker-php-ext-enable imagick +RUN apt-get purge -y libmagickwand-dev + +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ No newline at end of file diff --git a/PHP/docker-compose.yml b/PHP/docker-compose.yml new file mode 100644 index 0000000..2c06d73 --- /dev/null +++ b/PHP/docker-compose.yml @@ -0,0 +1,22 @@ +services: + php: + container_name: php + build: + dockerfile: Dockerfile + context: . + volumes: + - './www:/var/www/html' + - './php-logging.conf:/usr/local/etc/php-fpm.d/zz-log.conf' + + nginx: + container_name: nginx + image: nginx:latest + ports: + - '80:80' + links: + - 'php' + volumes: + - './www:/var/www/html' + - './nginx.conf:/etc/nginx/conf.d/nginx.conf' + depends_on: + - php \ No newline at end of file diff --git a/PHP/nginx.conf b/PHP/nginx.conf new file mode 100644 index 0000000..c3fd91f --- /dev/null +++ b/PHP/nginx.conf @@ -0,0 +1,29 @@ +server { + listen 80 default_server; + + server_name localhost; + + root /var/www/html; + index index.php index.html; + + # Support Yii2 pretty URL routing + location / { + try_files $uri $uri/ =404; + if (!-e $request_filename){ + rewrite ^/(.*) /index.php?r=$1 last; + } + } + + location ~* \.php$ { + fastcgi_pass php:9000; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + } + + # Prevent additional headers like TRACE, DELETE, PUSH + if ($request_method !~ ^(GET|HEAD|POST)$ ) + { + return 405; + } +} \ No newline at end of file diff --git a/PHP/php-logging.conf b/PHP/php-logging.conf new file mode 100644 index 0000000..39029d9 --- /dev/null +++ b/PHP/php-logging.conf @@ -0,0 +1,2 @@ +php_admin_flag[log_errors] = on +php_flag[display_errors] = off \ No newline at end of file