Skip to content

Commit 55d3742

Browse files
committed
build: apache with PHP and SSL are working again
1 parent fef5311 commit 55d3742

File tree

2 files changed

+138
-9
lines changed

2 files changed

+138
-9
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#! /bin/sh
2+
3+
# Exit on error
4+
set -e
5+
6+
#=== Set folder permissions ===
7+
folders="content/core/config content/core/data content/core/logs content/user/attachments content/user/images"
8+
9+
mkdir -vp $folders
10+
11+
{
12+
if [ -f "$APACHE_ENVVARS" ]; then
13+
. "$APACHE_ENVVARS"
14+
chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" $folders
15+
else
16+
chown -R www-data:www-data $folders
17+
fi
18+
chmod 775 $folders
19+
}
20+
21+
##=== Check database vars ===
22+
#=== DB host ===
23+
if [ -z "$PMF_DB_HOST" -a ! -e "./content/core/config/database.php" ]; then
24+
echo >&2 'WARN: missing PMF_DB_HOST environment variable'
25+
echo >&2 ' Did you forget to --link some_mysql_container:db ?'
26+
else
27+
#=== DB user and pass ===
28+
: ${PMF_DB_USER:=root}
29+
if [ "$PMF_DB_USER" = 'root' ]; then
30+
: ${PMF_DB_PASS:=$DB_ENV_MYSQL_ROOT_PASSWORD}
31+
fi
32+
33+
if [ -z "$PMF_DB_PASS" ]; then
34+
echo >&2 'ERROR: missing required PMF_DB_PASS environment variable'
35+
echo >&2 ' Did you forget to -e PMF_DB_PASS=... ?'
36+
echo >&2
37+
echo >&2 ' (Also of interest might be PMF_DB_USER and PMF_DB_NAME.)'
38+
exit 1
39+
#=== Setup database if needed ===
40+
elif [ 0 -eq 1 ]; then # TODO : Add something like: php setup/maintenance.php --vars...
41+
{
42+
echo "<?php"
43+
echo "\$DB['server'] = '$PMF_DB_HOST';"
44+
echo "\$DB['user'] = '$PMF_DB_USER';"
45+
echo "\$DB['password'] = '$PMF_DB_PASS';"
46+
echo "\$DB['db'] = '${PMF_DB_NAME:-phpmyfaq}';"
47+
echo "\$DB['prefix'] = '${PMF_DB_PREFIX}';"
48+
echo "\$DB['type'] = '${PMF_DB_TYPE:-mysqli}';"
49+
} | tee ./config/database.php
50+
fi
51+
fi
52+
53+
if [ -f "$APACHE_ENVVARS" ]; then
54+
#=== Enable htaccess for search engine optimisations ===
55+
if [ "x${DISABLE_HTACCESS}" = "x" ]; then
56+
a2enmod rewrite headers
57+
sed -ri .htaccess \
58+
-e "s~RewriteBase /phpmyfaq/~RewriteBase /~"
59+
# Enabling permissions override
60+
sed -ri ${APACHE_CONFDIR}/conf-available/*.conf \
61+
-e "s~(.*AllowOverride).*~\1 All~g"
62+
else
63+
rm .htaccess
64+
# Disabling permissions override
65+
sed -ri ${APACHE_CONFDIR}/conf-available/*.conf \
66+
-e "s~(.*AllowOverride).*~\1 none~g"
67+
fi
68+
fi
69+
70+
#=== Configure php.ini ===
71+
{
72+
echo "# PHP settings:"
73+
echo "register_globals = Off"
74+
echo "safe_mode = Off"
75+
echo "log_errors = $PHP_LOG_ERRORS"
76+
echo "error_reporting = $PHP_ERROR_REPORTING"
77+
echo "date.timezone = $PMF_TIMEZONE"
78+
echo "memory_limit = $PMF_MEMORY_LIMIT"
79+
echo "file_upload = $PMF_ENABLE_UPLOADS"
80+
echo "post_max_size = $PHP_POST_MAX_SIZE"
81+
echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE"
82+
} | tee $PHP_INI_DIR/conf.d/php.ini
83+
84+
#=== Set recommended opcache settings ===
85+
# see https://secure.php.net/manual/en/opcache.installation.php
86+
{
87+
echo "# OPCache settings:"
88+
echo "opcache.enable=1"
89+
echo "; 0 means it will check on every request"
90+
echo "; 0 is irrelevant if opcache.validate_timestamps=0 which is desirable in production"
91+
echo "opcache.revalidate_freq=0"
92+
echo "opcache.validate_timestamps=1"
93+
echo "opcache.max_accelerated_files=10000"
94+
echo "opcache.memory_consumption=192"
95+
echo "opcache.max_wasted_percentage=10"
96+
echo "opcache.interned_strings_buffer=16"
97+
echo "opcache.fast_shutdown=1"
98+
} | tee $PHP_INI_DIR/conf.d/opcache-recommended.ini
99+
100+
docker-php-entrypoint "$@"

docker-compose.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,48 @@ services:
3636
# SA_PASSWORD: 'phpMyFAQ-4.0'
3737
# ACCEPT_EULA: 'Y'
3838

39-
nginx:
40-
image: nginx:latest
39+
apache:
40+
build:
41+
context: .
42+
dockerfile: .docker/apache/Dockerfile
4143
restart: always
44+
stdin_open: true
45+
environment:
46+
- PMF_DB_HOST=db
47+
- PMF_DB_NAME=phpmyfaq
48+
- PMF_DB_USER=phpmyfaq
49+
- PMF_DB_PASS=phpmyfaq
50+
- PMF_DISABLE_HTACCESS=""
51+
- PMF_TIMEZONE="Europe/Berlin"
52+
- PMF_ENABLE_UPLOADS="On"
53+
- PMF_MEMORY_LIMIT="2048M" # only for development
54+
- PHP_LOG_ERRORS="On"
55+
- PHP_ERROR_REPORTING="E_ALL & E_DEPRECATED" # Production Value: E_ALL & ~E_DEPRECATED
4256
links:
43-
- php-fpm
44-
volumes:
45-
- ./phpmyfaq:/var/www/html
46-
- ./.docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
47-
- ./.docker/cert.pem:/etc/ssl/cert.pem
48-
- ./.docker/cert-key.pem:/etc/ssl/cert-key.pem
57+
- mariadb:db
58+
- postgres
59+
- elasticsearch
4960
ports:
50-
- '80:80'
61+
- '8080:80'
5162
- '443:443'
63+
volumes:
64+
- ./phpmyfaq:/var/www/html
65+
depends_on:
66+
- pnpm
67+
68+
# nginx:
69+
# image: nginx:latest
70+
# restart: always
71+
# links:
72+
# - php-fpm
73+
# volumes:
74+
# - ./phpmyfaq:/var/www/html
75+
# - ./.docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
76+
# - ./.docker/cert.pem:/etc/ssl/cert.pem
77+
# - ./.docker/cert-key.pem:/etc/ssl/cert-key.pem
78+
# ports:
79+
# - '80:80'
80+
# - '443:443'
5281

5382
php-fpm:
5483
build: .docker/php-fpm

0 commit comments

Comments
 (0)