Last active
November 15, 2023 07:16
-
-
Save littlefuntik/5b3e5b8732a36758b412087e1f76b337 to your computer and use it in GitHub Desktop.
alpine linux -- make install -- php-fpm 7.1.1 + geoip-1.1.1 + xdebug-2.5.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Container console commands (Windows: PowerShell) | |
# docker build --no-cache -t php:7.1 | |
# docker run --name test-php -v "${PWD}:/var/www:rw" -p "9001:9000" -d php:7.1 | |
# docker exec -ti php:7.1 /bin/sh | |
# docker rm test-php --force | |
# docker rmi php:7.1 | |
FROM alpine | |
RUN \ | |
addgroup -g 82 -S www-data && adduser -u 82 -D -S -G www-data www-data && \ | |
apk update && \ | |
apk add tzdata && \ | |
cp /usr/share/zoneinfo/Europe/Kiev /etc/localtime && \ | |
echo "Europe/Kiev" > /etc/timezone && \ | |
apk del tzdata && \ | |
apk add ca-certificates && \ | |
update-ca-certificates && \ | |
apk add autoconf file g++ gcc libc-dev make pkgconf re2c openssl curl-dev libmcrypt-dev libxml2-dev libpng-dev libjpeg-turbo-dev && \ | |
export PHP_INI_DIR="/usr/local/etc/php" && \ | |
mkdir -p $PHP_INI_DIR/conf.d \ | |
cd ~ && \ | |
wget -O php-7.1.1.tar.gz http://ua2.php.net/get/php-7.1.1.tar.gz/from/this/mirror && \ | |
tar -zxvf php-7.1.1.tar.gz && \ | |
cd php-7.1.1 && \ | |
export CFLAGS="-fstack-protector-strong -fpic -fpie -O2" && \ | |
export CPPFLAGS="-fstack-protector-strong -fpic -fpie -O2" && \ | |
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie" && \ | |
./configure \ | |
--prefix=/usr/local \ | |
--with-config-file-path="$PHP_INI_DIR" \ | |
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" \ | |
--enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data \ | |
--enable-debug \ | |
--disable-short-tags \ | |
--disable-ipv6 \ | |
--disable-all \ | |
--enable-libxml --enable-xml --enable-soap \ | |
--with-curl \ | |
--enable-mbstring \ | |
--with-mcrypt \ | |
--enable-pcntl \ | |
--enable-zip \ | |
--enable-mysqlnd --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd \ | |
--with-gd \ | |
--with-pear && \ | |
make -j "$(getconf _NPROCESSORS_ONLN)" && \ | |
make install && \ | |
make clean && \ | |
cp php.ini-development /usr/local/etc/php/php.ini && \ | |
pear config-set php_ini $PHP_INI_DIR/php.ini && \ | |
pecl config-set php_ini $PHP_INI_DIR/php.ini && \ | |
apk add geoip-dev && pecl install geoip-1.1.1 xdebug && \ | |
{ \ | |
echo '[global]'; \ | |
echo 'pid = /run/php-fpm.pid'; \ | |
echo 'error_log = /proc/self/fd/2'; \ | |
echo 'daemonize = no'; \ | |
echo 'include=/usr/local/etc/php-fpm.d/*.conf'; \ | |
} | tee /usr/local/etc/php-fpm.conf && \ | |
{ \ | |
echo '[www]'; \ | |
echo '; if we send this to /proc/self/fd/1, it never appears'; \ | |
echo 'listen = 9000'; \ | |
echo 'user = www-data'; \ | |
echo 'group = www-data'; \ | |
echo 'chdir = /var/www'; \ | |
echo 'pm = dynamic'; \ | |
echo 'pm.max_children = 9'; \ | |
echo 'pm.start_servers = 3'; \ | |
echo 'pm.max_spare_servers = 4'; \ | |
echo 'pm.min_spare_servers = 2'; \ | |
echo 'pm.max_requests = 20'; \ | |
echo 'request_terminate_timeout = 0'; \ | |
echo 'request_slowlog_timeout = 1s'; \ | |
echo 'slowlog = /proc/self/fd/2'; \ | |
echo 'catch_workers_output = yes'; \ | |
echo 'access.log = /proc/self/fd/2'; \ | |
echo 'clear_env = no'; \ | |
echo 'php_flag[display_errors] = on'; \ | |
echo 'php_admin_value[memory_limit] = 32M'; \ | |
} | tee /usr/local/etc/php-fpm.d/docker.conf && \ | |
sed -i \ | |
-e "s|upload_max_filesize\s*=.*|upload_max_filesize = 100M|" \ | |
-e "s|max_file_uploads\s*=.*|max_file_uploads = 50|" \ | |
-e "s|post_max_size\s*=.*|post_max_size = 100M|" \ | |
-e "s|;cgi.fix_pathinfo\s*=.*|cgi.fix_pathinfo = 1|" \ | |
-e "s|;date.timezone\s*=.*|date.timezone = Europe/Kiev|" \ | |
/usr/local/etc/php/php.ini && \ | |
mkdir /var/www && \ | |
rm -rf /var/cache/apk/* && \ | |
php -m && \ | |
php -v | |
WORKDIR /var/www | |
EXPOSE 9000 | |
CMD ["php-fpm"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment