Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Servidor Web Docker usando nginx y php

README

Archivos y estructura de directorios necesarios para correr un servidor web con docker usando nginx y php. Esta estructura de archivos y directorio debe estar en el directorio raiz del proyecto.

docker-compose.yml
|_docker
  |_nginx
    |_default.conf
  |_php
    |_custom.php.ini
    |_Dockerfile

Si se usa GIT se debe ignorar esta estructura.

.gitignore

docker-compose.yml
docker/
file_uploads = On
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600
date.timezone=America/Panama
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
server {
listen 80 default_server;
root /var/www/html/;
index index.php index.html index.htm;
server_name localhost;
charset utf-8;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
sendfile on;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png|webp)$ {
expires max;
add_header Cache-Control "public";
try_files $uri$webp_suffix $uri =404;
}
location / {
try_files $uri $uri/ /index.php?$args;
include /etc/nginx/mime.types;
}
location ~ /\.ht {
deny all;
}
}
FROM php:7.3-fpm
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
software-properties-common \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
libfreetype6-dev \
libicu-dev \
libssl-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libedit-dev \
libedit2 \
libpq-dev \
libxslt1-dev \
libzip-dev \
apt-utils \
gnupg \
git \
vim \
wget \
curl \
lynx \
psmisc \
unzip \
tar \
cron \
bash-completion \
&& apt-get clean
RUN docker-php-ext-configure \
gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/; \
docker-php-ext-install \
opcache \
gd \
bcmath \
intl \
mbstring \
soap \
xsl \
zip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo_mysql \
&& docker-php-ext-install json
RUN docker-php-ext-configure intl
RUN chmod 777 -R /var/www \
&& chown -R www-data:www-data /var/www \
&& usermod -u 1000 www-data \
&& chsh -s /bin/bash www-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment