Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


fortgeschrittene:apache-php

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
fortgeschrittene:apache-php [2016/12/19 00:49]
ingo_wichmann
fortgeschrittene:apache-php [2018/11/12 23:23] (aktuell)
Zeile 1: Zeile 1:
 ====== Apache httpd mit PHP ====== ====== Apache httpd mit PHP ======
 ===== php-cgi ===== ===== php-cgi =====
-//nicht empfohlen// 
  
 Pakete Debian 8: ''​apache2 php5-cgi''​ Pakete Debian 8: ''​apache2 php5-cgi''​
Zeile 8: Zeile 7:
   a2enconf serve-cgi-bin   a2enconf serve-cgi-bin
  
-<file ini /tmp/insecure.ini>+(( Das würde mit den folgenden Ergänzungen schon reichen. Wird aber von php nicht empfohlen. 
 +<file ini /tmp/cgi.force_redirect_no.ini>
 # do not use this in production, see # do not use this in production, see
 # http://​php.net/​manual/​de/​ini.core.php#​ini.cgi.force-redirect # http://​php.net/​manual/​de/​ini.core.php#​ini.cgi.force-redirect
Zeile 17: Zeile 17:
 #!/bin/sh #!/bin/sh
 # just because something works doesn'​t mean it's a good idea ... # just because something works doesn'​t mean it's a good idea ...
-exec /​usr/​bin/​php-cgi -c /tmp/insecure.ini+exec /​usr/​bin/​php-cgi -c /tmp/cgi.force_redirect_no.ini 
 +<?php 
 +# do not use me in production 
 +  phpinfo();​ 
 +  #​phpinfo(INFO_MODULES);​ 
 +?> 
 +</​code>​ 
 +)) 
 +  a2enmod actions 
 + 
 +<file txt /​etc/​apache/​conf-available/​simple-php5-cgi.conf>​ 
 +<​Directory /​usr/​lib/​cgi-bin>​ 
 +  Action php-script /​cgi-bin/​php5 
 +  AddHandler ​  ​php-script .php 
 +</​Directory>​ 
 +</​file>​ 
 + 
 +  a2enconf simple-php5-cgi 
 + 
 +<code php /​usr/​lib/​cgi-bin/​phpinfo.php>​ 
 +<?php 
 +# do not use me in production 
 +  phpinfo();​ 
 +  #​phpinfo(INFO_MODULES);​ 
 +?> 
 +</​code>​ 
 + 
 +===== mod_php ===== 
 +Pakete:  
 +  * Debian (8): libapache2-mod-php5 
 +  * CentOS (7): php 
 + 
 +<code php /​var/​www/​html/​phpinfo.php>​
 <?php <?php
 # do not use me in production # do not use me in production
Zeile 25: Zeile 57:
 </​code>​ </​code>​
  
-===== php-fcgi ​minimal ​=====+===== php-fcgi =====
 Pakete Debian 8: ''​apache2 php5-cgi libapache2-mod-fcgid''​ Pakete Debian 8: ''​apache2 php5-cgi libapache2-mod-fcgid''​
  
Zeile 58: Zeile 90:
 # do not use me in production # do not use me in production
   phpinfo();   phpinfo();
-  phpinfo(INFO_MODULES);​+  ​#phpinfo(INFO_MODULES);​
 ?> ?>
 </​code>​ </​code>​
Zeile 66: Zeile 98:
   service apache2 status   service apache2 status
  
-===== php-fcgi mit vhost und suexec ​===== +===== php-fpm ===== 
-//TODOnoch nicht fertig//+Pakete Debian 8''​apache2 php5-fpm''​
  
-Voraussetzung:​ apache mit vhost+  a2dismod cgi 
 +  a2disconf serve-cgi-bin 
 +  a2enmod proxy_fcgi
  
-  apt-get install ​apache2-suexec ​php5-cgi libapache2-mod-fcgid +<file txt /etc/apache2/conf-available/​php-fpm.conf>​ 
-  ​a2enmod fcgid +<Proxy "​unix:/​var/​run/​php5-fpm.sock|fcgi://​php-fpm">​ 
-  ​a2enmod suexec +  ​# we must declare a (any) parameter in here  
- +  ​# or it won't register the proxy ahead of time 
-<file txt /etc/apache2/conf-available/php-fcgi.conf+  ​ProxySet disablereuse=off 
-# Context ​server config +</Proxy> 
-FcgidMaxProcesses 150 +ScriptAlias ​/cgi-bin/​usr/​lib/​cgi-bin/ 
-# Otherwise php output shall be buffered +<​Directory "/​usr/​lib/​cgi-bin">​ 
-FcgidOutputBufferSize 0+  <​FilesMatch ".+\.php$"​
 +    ​SetHandler proxy:​fcgi://​php-fpm 
 +  </​FilesMatch>​ 
 +  ​AllowOverride None 
 +  ​Require all granted 
 +</​Directory>​
 </​file>​ </​file>​
  
-  a2enconf php-fcgi+  a2enconf php-fpm
  
-  ​mkdir -p /​srv/​phpinfo.linuxhotel.de/​cgi-bin +  ​apachectl configtest 
-  ​useradd -r -d /​srv/​phpinfo.linuxhotel.de/​cgi-bin/​ -s /bin/false phpinfo+  ​apachectl graceful
  
-(( ''​php-cgi''​ needs to be under suexec doc_root, see +<​code ​php /usr/lib/cgi-bin/phpinfo.php> 
-  ​/usr/lib/apache2/​suexec-pristine -V +<?php 
-)) +do not use me in production 
-<code bash /var/www/php-cgi+  ​phpinfo();​ 
-#!/bin/sh +  #​phpinfo(INFO_MODULES);​ 
-export PHPRC="/​etc/​php5/​cgi"​ +?>
-exec /​usr/​bin/​php-cgi+
 </​code>​ </​code>​
-  chmod +x /​var/​www/​php-cgi 
  
-<file txt +  wget -nv -O - http://​localhost/​cgi-bin/​phpinfo.php
  
-<​code ​php /​srv/​phpinfo.linuxhotel.de/cgi-bin/​phpinfo.fcgi>​+  service apache2 status 
 + 
 +===== php-fpm mit anderem Benutzer ===== 
 +Pakete Debian 8: ''​apache2 php5-fpm''​ 
 + 
 +  a2dismod cgi 
 +  a2disconf serve-cgi-bin 
 +  a2enmod proxy_fcgi 
 + 
 +  useradd -r -s /​usr/​sbin/​nologin -d /​srv/​phpinfo ​phpinfo 
 +  mkdir /​srv/​phpinfo 
 +  cp /​etc/​php5/​fpm/​pool.d/​{www,​phpinfo-app}.conf 
 + 
 +<file txt /etc/​php5/​fpm/​pool.d/​phpinfo-app.conf>​ 
 +[phpinfo-app] 
 +… 
 +user = phpinfo 
 +group = phpinfo 
 +… 
 +listen = /var/​run/​php5-fpm-phpinfo.sock 
 +… 
 +</​file>​ 
 + 
 +  service php5-fpm restart 
 + 
 +<file txt /​etc/​apache2/​conf-available/​php-fpm-phpinfo.conf>​ 
 +<Proxy "​unix:/​var/​run/​php5-fpm-phpinfo.sock|fcgi://​php-fpm-phpinfo">​ 
 +  # we must declare a (any) parameter in here  
 +  # or it won't register the proxy ahead of time 
 +  ProxySet disablereuse=off 
 +</​Proxy>​ 
 +ScriptAlias /phpinfo/ /​srv/​phpinfo/​ 
 +<​Directory "/​srv/​phpinfo/">​ 
 +  <​FilesMatch "​.+\.php$">​ 
 +    SetHandler proxy:​fcgi://​php-fpm-phpinfo 
 +  </​FilesMatch>​ 
 +  AllowOverride None 
 +  Require all granted 
 +</​Directory>​ 
 +</​file>​ 
 + 
 +  a2enconf php-fpm-phpinfo 
 + 
 +  apachectl configtest 
 +  apachectl graceful 
 + 
 +<code php /​srv/​phpinfo/​phpinfo.php>
 <?php <?php
 # do not use me in production # do not use me in production
-phpinfo();+  ​phpinfo(); 
 +  phpinfo(INFO_MODULES);
 ?> ?>
 </​code>​ </​code>​
-  ## chmod +x /srv/phpinfo.linuxhotel.de/cgi-bin/phpinfo.fcgi+ 
 +  wget -nv -O - http://localhost/phpinfo/phpinfo.php 
 + 
 +  service apache2 status 
  
fortgeschrittene/apache-php.1482108562.txt.gz · Zuletzt geändert: 2016/12/19 00:49 von ingo_wichmann