Skip to content

Commit c23385d

Browse files
committed
reconfigure php and mysql
add support for mysql and postgresql
1 parent 819ca31 commit c23385d

File tree

15 files changed

+64
-22
lines changed

15 files changed

+64
-22
lines changed

.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
PG_DB_NAME=testdb
2+
PG_DB_USER=myuser
3+
PG_DB_PASSWORD=mypassword
4+
5+
MY_DB_NAME=testdb
6+
MY_DB_USER=myuser
7+
MY_DB_PASSWORD=mypassword
8+
MY_DB_ROOT_PASSWORD=myrootpassword

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
logs/nginx/*
2+
logs/php/*
3+
mysql/data/*
4+
postgres/data/*

database/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

database/data/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

logs/nginx/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

mysql/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM mysql:8.0.23
2+
EXPOSE 3306
3+
CMD ["mysqld"]

mysql/init.sql

Whitespace-only changes.

nginx/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
FROM nginx:1.18
22
WORKDIR /var/www
3-
CMD ["nginx"]
4-
EXPOSE 80
3+
EXPOSE 80
4+
CMD ["nginx"]

nginx/conf.d/default.conf

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ server {
33
listen [::]:80 default_server ipv6only=on;
44

55
server_name localhost;
6-
root /var/www/;
7-
index index.php index.html index.htm;
6+
7+
root /var/www/public/;
8+
9+
index index.php;
810

911
location ~ /\.ht {
1012
deny all;
1113
}
1214

1315
location / {
16+
# try to serve directly or fallback to index.php
1417
try_files $uri $uri/ /index.php$is_args$args;
1518
}
1619

17-
location ~ \.php$ {
18-
try_files $uri /index.php =404;
20+
location ~ ^/index\.php(/|$) {
21+
1922
fastcgi_pass php-upstream;
20-
fastcgi_index index.php;
21-
fastcgi_buffers 16 16k;
22-
fastcgi_buffer_size 32k;
23-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23+
fastcgi_split_path_info ^(.+\.php)(/.*)$;
2424
fastcgi_read_timeout 600;
2525
include fastcgi_params;
26+
27+
fastcgi_buffers 16 16k;
28+
fastcgi_buffer_size 32k;
29+
30+
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
31+
fastcgi_param DOCUMENT_ROOT $realpath_root;
2632
}
2733

2834
}

php-fpm/Dockerfile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
FROM php:7.4.14-fpm
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
libicu-dev \
6+
libpq-dev \
7+
&& pecl install xdebug \
8+
&& docker-php-ext-enable xdebug \
9+
&& docker-php-ext-install -j$(nproc) intl \
10+
&& docker-php-ext-install -j$(nproc) pgsql \
11+
&& docker-php-ext-install -j$(nproc) pdo_pgsql \
12+
&& docker-php-ext-install -j$(nproc) pdo_mysql
13+
214
WORKDIR /var/www
3-
COPY --from=composer /usr/bin/composer /usr/bin/composer
15+
416
RUN curl -sS https://get.symfony.com/cli/installer | bash
5-
RUN echo "export PATH=\"$HOME/.symfony/bin:$PATH\"" > ~/.bashrc
6-
RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
7-
CMD ["php-fpm"]
8-
EXPOSE 9000
17+
# make symfony command available globally
18+
RUN mv /root/.symfony/bin/symfony /usr/local/bin/symfony
19+
20+
EXPOSE 9000
21+
CMD ["php-fpm"]

0 commit comments

Comments
 (0)