Commit 63205798 authored by root's avatar root Committed by Vitaly Lipatov

add initial php7 creating script

parent 295a5aa7
# OpenVZ
TEMPLATE=etersoft-p8
# Script
PKGPROFILE="apache2-php7"
# PHP
PHP_memory_limit=386M
PHP_max_execution_time=15
# Site
DOMAIN=site.azbyka.ru
#!/bin/bash -x
fatal()
{
echo "$*" >&2
exit 1
}
TASK="$1"
[ -s "$TASK" ] || fatal
. $TASK
tune_php7()
{
local aphp=/etc/php/7.1/apache2-mod_php/php.ini
#[ -s php7.add ] && cat php7.add | st tee -a $aphp
[ -n "$PHP_memory_limit" ] && subst "s|^memory_limit =.*|memory_limit = $PHP_memory_limit|" $aphp
[ -n "$PHP_max_execution_time" ] && subst "s|^max_execution_time = .*|max_execution_time = $PHP_max_execution_time|" $aphp
}
tune_apache2()
{
for i in mod_php7 status mpm_itk remoteip setenvif rewrite session; do
a2enmod $i
done
cat <<EOF > /etc/httpd2/conf/mods-available/remoteip.conf
<IfModule remoteip_module>
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 192.168.3.254/32
</IfModule>
EOF
ln -sr /etc/httpd2/conf/mods-available/remoteip.conf /etc/httpd2/conf/mods-enabled/remoteip.conf
subst "s|^NameVirtualHost.*||g" /etc/httpd2/conf/sites-enabled/$AUSER.conf
subst "s|^<VirtualHost.*|<VirtualHost *:80>|g" /etc/httpd2/conf/sites-enabled/$AUSER.conf
#PORT=$(grep "^<VirtualHost" /etc/httpd2/conf/sites-enabled/$AUSER.conf | sed -e "s|<VirtualHost \*:\([0-9]*\)>.*|\1|")
#"
#[ -n "$PORT" ] || fatal
#subst "s|^Listen .*|Listen $PORT|" /etc/httpd2/conf/ports-enabled/http.conf
subst "s| *\(SetEnvIf.*\)|\n\
<Directory />\n\
Options Indexes FollowSymLinks MultiViews\n\
AllowOverride FileInfo\n\
</Directory>\n\
\n\
<Location /server-status>\n\
SetHandler server-status\n\
#<IfModule authz_host_module>\n\
# Order deny,allow\n\
# Deny from all\n\
# Allow from 91.232.225.0/24\n\
#</IfModule>\n\
</Location>\n\
\n\
\1|" /etc/httpd2/conf/sites-enabled/$AUSER.conf
# fix remoteip
subst 's|LogFormat "%h|LogFormat "%a|g' /etc/httpd2/conf/mods-available/log_config.conf
a2dissite 000-default
a2dissite ports_all
serv httpd2 restart || fatal
}
groupadd $AUSER -g $AGROUPID
useradd -M $AUSER -u $AUSERID -g $AGROUPID #|| fatal
for i in $PKGPROFILE ; do
case $i in
apache2-php7)
epmi --auto --skip-installed apache2-mod_mpm_itk apache2-mod_php7
# opcache zip intl xsl memcache yaml xdebug redis tidy memcached suhosin
epmi --auto --skip-installed php7-mbstring php7-pdo php7-curl php7-fileinfo php7-dom php7-exif \
php7-pdo_mysql php7-mysqli php7-pcntl php7-openssl php7-mcrypt php7-gd2
tune_php7
tune_apache2
;;
apache2-php5)
epmi --auto --skip-installed apache2-mod_mpm_itk apache2-mod_php5 php5-suhosin
epmi --auto --skip-installed php5-opcache php5-mbstring php5-mysql php5-zip php5-pspell php5-pdo php5-intl php5-curl php5-fileinfo php5-dom php5-exif php5-xsl php5-memcache \
php5-pdo_mysql php5-yaml php5-mysqli php5-xdebug php5-redis php5-pcntl php5-tidy php5-openssl php5-memcached php5-mcrypt php5-gd2
;;
esac
done
epm clean
#!/bin/bash -x
fatal()
{
echo "$*" >&2
exit 1
}
# TODO
assure()
{
[ -n "$1" ] || fatal "empty"
}
if [ -s "base.task" ] ; then
. base.task
fi
TASK="$1"
[ -n "$TASK" ] || TASK=php7.task
[ -s "$TASK" ] || fatal
. $TASK
[ -n "$NAME" ] || NAME=$(basename $TASK .task)
# TODO
#STARTVEID=101
#VEID=101
VEIP=192.168.3.$VEID
#VEIDORIG=193
AUSER=azbyka_$NAME
assure $NAME
assure $VEID
if ! vzlist -a | grep $VEIP ; then
vzctl create $VEID --ostemplate=$TEMPLATE
vzctl set $VEID --name $NAME --hostname $NAME.$DOMAIN --onboot yes --ipadd $VEIP --save
vzctl set $VEID --shmpages 300M --physpages 1G --privvmpages 2G --tcprcvbuf unlimited --kmemsize 40M:45M --numproc 512 --dcachesize unlimited --save
fi
if [ ! -s /etc/vz/conf/$VEID.mount ] ; then
cat > /etc/vz/conf/$VEID.mount <<EOF
#!/bin/bash
export VEID=$(basename $0 .mount)
. /etc/vz/vz.conf
#mount --bind /azbyka /var/lib/vz/root/$VEID/home
mkdir -p /var/lib/vz/root/$VEID/home/$AUSER/
mount --bind /azbyka/$AUSER/ /var/lib/vz/root/$VEID/home/$AUSER/
EOF
chmod 0755 /etc/vz/conf/$VEID.mount
fi
if ! vzlist | grep $VEIP ; then
vzctl start $VEID || fatal
fi
# TODO
vzctl exec $VEID update_chrooted conf
vzctl exec $VEID epmI eepm
vzctl exec $VEID epm --auto upgrade
st()
{
vzctl exec $VEID "$@"
}
# TODO
cat /var/lib/vz/root/193/etc/httpd2/conf/sites-enabled/azbyka_$NAME.conf | st tee /etc/httpd2/conf/sites-enabled/azbyka_$NAME.conf
cat /var/lib/vz/root/193/etc/httpd2/conf/include/prepend.php | st tee /etc/httpd2/conf/include/prepend.php
cat createbytask.int.sh | st tee /tmp/createbytask.int.sh
st chmod 0755 /tmp/createbytask.int.sh
ATASK=/tmp/$(basename $TASK)
cat $TASK | st tee $ATASK
echo "NAME=$NAME" | st tee -a $ATASK
echo "AUSER=$AUSER" | st tee -a $ATASK
echo "AUSERID=$(vzctl exec $VEIDORIG id -u $AUSER)" | st tee -a $ATASK
echo "AGROUPID=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK
#echo "WEBMASTER=$(vzctl exec $VEIDORIG id -g $AUSER)" | st tee -a $ATASK
st /tmp/createbytask.int.sh $ATASK || fatal
VEID=102
NAME=crosswords
# use base
PKGPROFILE="apache2-php7"
PHP_memory_limit=386M
PHP_max_execution_time=15
VEID=101
NAME=miloserdie
# use base
PKGPROFILE="apache2-php7"
PHP_memory_limit=386M
PHP_max_execution_time=15
; Lav 24.11.2011: copied from eterhost.ru
suhosin.executor.func.blacklist = dl,system,shell_exec,popen,proc_open,exec,passthru,pcntl_exec
;,set_time_limit
;,error_reporting
suhosin.executor.eval.blacklist = dl,system,shell_exec,popen,proc_open,exec,passthru,pcntl_exec
;,set_time_limit
;,error_reporting
; Не запрещает дальнейшее исполнение кода, в отличие от suhosin.executor
;disable_functions = set_time_limit
; TODO:
;,error_reporting
suhosin.post.max_value_length = 51200000
suhosin.request.max_value_length = 51200000
suhosin.get.max_value_length = 10000
suhosin.post.max_name_length = 256
suhosin.request.max_varname_length = 256
suhosin.cookie.max_name_length = 256
suhosin.get.max_name_length = 256
; Due strange forum admin part at azbyka.ru
suhosin.post.max_vars = 2000
suhosin.request.max_vars = 2000
; configured COOKIE variable limit exceeded - dropped variable '__utmc' - all further COOKIE variables are dropped
suhosin.cookie.max_vars = 2000
suhosin.post.max_array_depth = 1000
suhosin.upload.max_uploads = 200
; Maximum function nesting level.
xdebug.max_nesting_level = 500
; See https://bugs.etersoft.ru/show_bug.cgi?id=10854
suhosin.filter.action = 402
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment