From bf293caaede913a665d3762e336607311b83a8e9 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 14 Aug 2013 14:11:41 +0200 Subject: userSubGenerate: add php-fpm pools --- userSubGenerate | 177 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 132 insertions(+), 45 deletions(-) diff --git a/userSubGenerate b/userSubGenerate index 1fca4af..c212564 100755 --- a/userSubGenerate +++ b/userSubGenerate @@ -3,7 +3,7 @@ # Ein Skript, das fuer jede Splinenutzerin eine # Subdomain [.userpage].spline[.inf.fu-berlin].de # anlegt. -# 2003-04-09 [stb] +# 2003-04-09 [stb] # 2003-05-25 [yann] Anpassung um Logfiles und cgi-bin # 2005-11-15 [stb] Anpassung an neues Serverlayout # 2005-11-16 [yann] Ergaenzung ohne "userpage" @@ -17,53 +17,113 @@ then fi SPLINEUSERS=$(ldapsearch -LLL -x -b "ou=People,dc=spline,dc=inf,dc=fu-berlin,dc=de" uid | grep "^uid" | cut -d" " -f2 | sort) -TMPFILEDNS=/tmp/cnames$(date -Is) -TMPFILEAPACHE=/tmp/apacheVirtuals$(date -Is) +TMPFILEDNS=$(mktemp /tmp/userSubGenerate-dns.XXXXXX) +TMPFILEAPACHEVHOSTS=$(mktemp /tmp/userSubGenerate-apache-vhosts.XXXXXX) +TMPFILEAPACHEGLOBAL=$(mktemp /tmp/userSubGenerate-apache-global.XXXXXX) +TMPFILEPHP=$(mktemp /tmp/userSubGenerate-php-fpm.XXXXXX) -cat <> $TMPFILEDNS -; -; Diese Datei (USERPAGE_generated) -- bzw. alles, was ab -; hier kommt -- wird automatisch generiert! -; +cat < $TMPFILEDNS +; Diese Datei wird automatisch generiert! ; Eintragungen von Hand sind sinnlos! ; -; Siehe /usr/local/bin/userSubGenerate +; Siehe plonk:/usr/local/bin/userSubGenerate +; ; ; Fuer jede Nutzerin bei spline gibt es eine Subdomain ; [.userpage].spline[.inf.fu-berlin].de, die dann vom ; Apache auf ~ aufgeloest wird. -; EOF -cat <> $TMPFILEAPACHE +cat < $TMPFILEAPACHEVHOSTS +# Diese Datei wird automatisch generiert! +# Eintragungen von Hand sind sinnlos! +# +# Siehe plonk:/usr/local/bin/userSubGenerate +# # Fuer jede Nutzerin bei spline gibt es eine Subdomain # [.userpage].spline[.inf.fu-berlin].de, die vom # Apache auf ~ aufgeloest wird. EOF -echo "Generiere $TMPFILEDNS und $TMPFILEAPACHE ..." >&3 +cat < $TMPFILEAPACHEGLOBAL +# Diese Datei wird automatisch generiert! +# Eintragungen von Hand sind sinnlos! +# +# Siehe plonk:/usr/local/bin/userSubGenerate +# +# +# Für jeden User gibt es hier spezifische Einstellungen, +# die wir im vhost und im /~user/ brauchen. + +AddHandler php-fastcgi .php .php3 .php4 .php5 +DirectoryIndex index.html index.htm index.php + +EOF + +cat < $TMPFILEPHP +; Diese Datei wird automatisch generiert! +; Eintragungen von Hand sind sinnlos! +; +; Siehe plonk:/usr/local/bin/userSubGenerate +; +; +; Hier wird ein php-pool fuer jeden user generiert. + +EOF + +echo "Generiere $TMPFILEDNS, $TMPFILEAPACHEVHOSTS, $TMPFILEAPACHEGLOBAL und $TMPFILEPHP..." >&3 for SPLINEUID in $(echo $SPLINEUSERS) do + echo $SPLINEUID FULLNAME=$(ldapsearch -LLL -x -b "dc=spline,dc=inf,dc=fu-berlin,dc=de" "(uid=$SPLINEUID)" cn | grep "^cn" | cut -d" " -f2-) + + cat <> $TMPFILEDNS ; $SPLINEUID.userpage.spline[.inf.fu-berlin].de fuer $FULLNAME -$SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. -www.$SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. -$SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. -www.$SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. +$SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. +www.$SPLINEUID.userpage IN CNAME userpage.spline.inf.fu-berlin.de. +$SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. +www.$SPLINEUID IN CNAME userpage.spline.inf.fu-berlin.de. EOF - if [[ -d /var/users/$SPLINEUID/public_html ]] - then + if [ -d /var/users/$SPLINEUID/public_html ]; then + + cat <> $TMPFILEAPACHEGLOBAL +# php fuer $SPLINEUID ($FULLNAME) +FastCGIExternalServer /home/$SPLINEUID/php-worker -socket /var/run/php5-fpm/$SPLINEUID.sock +ScriptAlias /home/$SPLINEUID/php-worker.fcgi /home/$SPLINEUID/php-worker + + + Action php-fastcgi /home/$SPLINEUID/php-worker.fcgi + + + + Options ExecCGI + Order allow,deny + Allow from all + + + + AllowOverride All + Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec + + + + Options ExecCGI + Order allow,deny + Allow from all + - cat <> $TMPFILEAPACHE + +EOF + + cat <> $TMPFILEAPACHEVHOSTS # http://$SPLINEUID.userpage.spline[.inf.fu-berlin].de fuer $FULLNAME - - SSLEngine off + ServerAlias $SPLINEUID.userpage.spline.inf.fu-berlin.de ServerAlias $SPLINEUID.userpage.spline.de ServerAlias $SPLINEUID.spline.de @@ -72,40 +132,67 @@ EOF ServerAlias www.$SPLINEUID.userpage.spline.de ServerAlias www.$SPLINEUID.spline.de ServerAlias www.$SPLINEUID.spline.inf.fu-berlin.de - ErrorLog /var/users/$SPLINEUID/public_html/logs/error.log - CustomLog /var/users/$SPLINEUID/public_html/logs/access.log combined - DocumentRoot /var/users/$SPLINEUID/public_html/webroot - ScriptAlias /cgi-bin/ /var/users/$SPLINEUID/public_html/cgi-bin/ - - - AllowOverride All - Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec - - - - Options ExecCGI - Order allow,deny - Allow from all - + ErrorLog /home/$SPLINEUID/public_html/logs/error.log + CustomLog /home/$SPLINEUID/public_html/logs/access.log combined + DocumentRoot /home/$SPLINEUID/public_html/webroot + + SuexecUserGroup $SPLINEUID users + + + SetHandler php-fastcgi-status + Action php-fastcgi-status /home/$SPLINEUID/php-worker.fcgi virtual + EOF - fi + cat <> $TMPFILEPHP +[$SPLINEUID] +user = \$pool +group = nogroup +listen = /var/run/php5-fpm/\$pool.sock + +listen.owner = www-data +listen.group = nogroup +listen.mode = 0600 + +pm = ondemand +pm.max_children = 10 +pm.process_idle_timeout = 10s + +pm.status_path = /php-status +catch_workers_output = yes + +security.limit_extensions = .php .php3 .php4 .php5 + +EOF + + fi # -d /var/users/$SPLINEUID/public_html done -echo "Kopiere $TMPFILEAPACHE nach userpage:/var/www/apache-config-userpage.spline.de ..." >&3 -scp $TMPFILEAPACHE www-data@userpage.spline.inf.fu-berlin.de:apache-config-userpage.spline.de +echo "Kopiere $TMPFILEPHP nach userpage:/etc/php5/fpm/pool.d/users.conf ..." >&3 +scp $TMPFILEPHP www-data@userpage.spline.inf.fu-berlin.de:/etc/php5/fpm/pool.d/users.conf + +echo "Starte den php-fpm auf userpage neu." >&3 +ssh www-data@userpage.spline.inf.fu-berlin.de sudo /etc/init.d/php5-fpm reload + +echo "Kopiere $TMPFILEAPACHEVHOSTS nach userpage:/etc/apache2/user-site.d/user-vhosts.conf ..." >&3 +scp $TMPFILEAPACHEVHOSTS www-data@userpage.spline.inf.fu-berlin.de:/etc/apache2/user-site.d/user-vhosts.conf + +echo "Kopiere $TMPFILEAPACHEGLOBAL nach userpage:/etc/apache2/user-site.d/globals.conf ..." >&3 +scp $TMPFILEAPACHEGLOBAL www-data@userpage.spline.inf.fu-berlin.de:/etc/apache2/user-site.d/globals.conf echo "Starte den Apache auf userpage neu." >&3 -ssh www-data@userpage.spline.inf.fu-berlin.de sudo /usr/sbin/apache2ctl graceful +ssh www-data@userpage.spline.inf.fu-berlin.de sudo /etc/init.d/apache2 reload -echo "Kopiere $TMPFILEDNS nach /etc/bind/dns-sources/USERPAGE_spline" >&3 -cp -f $TMPFILEDNS /etc/bind/dns-sources/USERPAGE_spline +echo "Kopiere $TMPFILEDNS nach beep:/etc/bind/dns-sources/common.userpage" >&3 +scp $TMPFILEDNS wartung@beep.spline.inf.fu-berlin.de:/etc/bind/dns-sources/common.userpage echo "Erstelle die DNS-Eintraege neu" >&3 -cd /etc/bind/dns-sources -make mrproper && make && make serial && make install || echo "Fehler beim Erstellen der neuen DNS-Eintraege." >&3 +ssh wartung@beep.spline.inf.fu-berlin.de sudo /usr/bin/make -C /etc/bind/dns-sources/ install || echo "Fehler beim Erstellen der neuen DNS-Eintraege." >&3 -rm $TMPFILEAPACHE +# cleanup +rm $TMPFILEPHP +rm $TMPFILEAPACHEVHOSTS +rm $TMPFILEAPACHEGLOBAL rm $TMPFILEDNS -- cgit v1.2.3