php/7/scripts/alpine-setup.sh

56 lines
2.6 KiB
Bash

#!/bin/sh
PHP_LIST="bcmath,bz2,calendar,cgi,
ctype,curl,dba,dom,embed,
enchant,exif,fileinfo,ftp,gd,
gettext,gmp,imap,intl,
ldap,opcache,openssl,
pcntl,pdo,pear,posix,
pspell,shmop,snmp,soap,sockets,
sysvmsg,sysvsem,sysvshm,tidy,tokenizer,
xml,xmlreader,xmlrpc,xsl,zip"
PHP_DEPS=""
# apache2 configurations
SERVER_ROOT="/app"
APP_ROOT="$SERVER_ROOT/htdocs"
LOG_LEVEL="info"
if [ "$FLAVOR" == "full" ] then
for i in $(echo $PHP_LIST | tr "," "\n"); do
PHP_DEPS="${PHP_DEPS} php$PHP_VER_SHORT-$i ";
done
/sbin/apk add --update --no-cache $PHP_DEPS;
fi
# Only setup apache with full flavor parameters
if [ "$WITH_APACHE" == "true" ]; then
/usr/sbin/addgroup -g 10001 apache ;
/usr/sbin/adduser -D -u 10001 -G apache -s /bin/sh -h $APP_ROOT apache ;
/sbin/apk add --update --no-cache apache2 php$PHP_VER_SHORT-apache2 ;
sed -i "s|ServerRoot /var/www|ServerRoot ${SERVER_ROOT}|" /etc/apache2/httpd.conf ;
sed -i "s|ServerAdmin you@example.com| ServerAdmin map@sindigilive.com|" /etc/apache2/httpd.conf ;
sed -i "s|DocumentRoot \"/var/www/localhost/htdocs\"|DocumentRoot \"${APP_ROOT}\"|" /etc/apache2/httpd.conf ;
sed -i "s|Directory \"/var/www/localhost/htdocs\"|Directory \"${APP_ROOT}\"|" /etc/apache2/httpd.conf ;
sed -i "s|AllowOverride None|AllowOverride All|" /etc/apache2/httpd.conf ;
sed -i "s|ErrorLog .*|ErrorLog /dev/stderr \nTransferLog /dev/stdout|" /etc/apache2/httpd.conf ;
sed -i "s|CustomLog .* combined|CustomLog /dev/stdout combined|" /etc/apache2/httpd.conf ;
sed -i "s|LogLevel .*|LogLevel ${LOG_LEVEL}|" /etc/apache2/httpd.conf ;
sed -i "s|#LoadModule rewrite_module|LoadModule rewrite_module|" /etc/apache2/httpd.conf ;
sed -i "s|#LoadModule deflate_module|LoadModule deflate_module|" /etc/apache2/httpd.conf ;
sed -i "s|#LoadModule expires_module|LoadModule expires_module|" /etc/apache2/httpd.conf ;
sed -i "s|/var/www/localhost/cgi-bin/|/app/cgi-bin/|" /etc/apache2/httpd.conf ;
sed -i "s|Require host .example.com|#Require host .example.com|" /etc/apache2/conf.d/info.conf ;
sed -i "s|Require ip 127|Require all granted|" /etc/apache2/conf.d/info.conf ;
sed -i "s|/run/apache2/httpd.pid|${SERVER_ROOT}/run/httpd.pid|" /etc/apache2/conf.d/mpm.conf ;
fi
if [ "$WITH_DATABASE" == "postgresql" ]; then
/sbin/apk add --update --no-cache php$PHP_VER_SHORT-pdo php$PHP_VER_SHORT-pdo_pgsql php$PHP_VER_SHORT-pgsql ;
fi
if [ "$WITH_DATABASE" == "mysql" ]; then
/sbin/apk add --update --no-cache php$PHP_VER_SHORT-pdo php$PHP_VER_SHORT-pdo_mysql php$PHP_VER_SHORT-mysql \
php$PHP_VER_SHORT-mysqli php$PHP_VER_SHORT-mysqlnd ;
fi