Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


admin_grundlagen:apache-php

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.

Link zu der Vergleichsansicht

Nächste Überarbeitung
Vorherige Überarbeitung
admin_grundlagen:apache-php [2016/11/25 15:23] – angelegt ingo_wichmannadmin_grundlagen:apache-php [2018/11/12 23:23] (aktuell) – [mod_php] ingo_wichmann
Zeile 1: Zeile 1:
-Apache mit PHP:+====== Apache httpd mit PHP ====== 
 +===== php-cgi =====
  
-CentOS 7: +Pakete Debian 8: ''apache2 php5-cgi'' 
-    yum install php + 
-<file php /var/www/html/php_info.php>+  a2enmod cgi 
 +  a2enconf serve-cgi-bin 
 + 
 +(( 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 
 +# http://php.net/manual/de/ini.core.php#ini.cgi.force-redirect 
 +cgi.force_redirect = 0 
 +</file> 
 + 
 +<code bash /usr/lib/cgi-bin/phpinfo.php> 
 +#!/bin/sh 
 +# just because something works doesn't mean it's a good idea ... 
 +exec /usr/bin/php-cgi -c /tmp/cgi.force_redirect_no.ini
 <?php <?php
 +# do not use me in production
 +  phpinfo();
 +  #phpinfo(INFO_MODULES);
 +?>
 +</code>
 +))
 +  a2enmod actions
  
-phpinfo();+<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
 +# do not use me in production
 +  phpinfo();
 +  #phpinfo(INFO_MODULES);
 +?>
 +</code>
 +
 +===== php-fcgi =====
 +Pakete Debian 8: ''apache2 php5-cgi libapache2-mod-fcgid''
 +
 +  a2dismod cgi
 +  a2disconf serve-cgi-bin
 +  a2enmod fcgid
 +
 +<file txt /etc/apache2/conf-available/php-fcgi.conf>
 +# Context - server config
 +FcgidMaxProcesses 150
 +# Otherwise php output shall be buffered
 +FcgidOutputBufferSize 0
 +
 +ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 +<Directory "/usr/lib/cgi-bin">
 +  AddHandler fcgid-script .php # may confict with other .php handlers
 +  #FcgidWrapper /usr/local/bin/php-fcgid-wrapper
 +  FcgidWrapper /usr/bin/php-cgi
 +  AllowOverride None
 +  Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 +  Require all granted
 +</Directory>
 </file> </file>
-  service httpd restart + 
-testen: http://localhost/php_info.php +  a2enconf php-fcgi 
-  rm /var/www/html/php_info.php+ 
 +  apachectl configtest 
 +  apachectl graceful 
 + 
 +<code php /usr/lib/cgi-bin/phpinfo.php> 
 +<?php 
 +# do not use me in production 
 +  phpinfo(); 
 +  #phpinfo(INFO_MODULES); 
 +?> 
 +</code> 
 + 
 +  wget -nv -O - http://localhost/cgi-bin/phpinfo.php 
 + 
 +  service apache2 status 
 + 
 +===== php-fpm ===== 
 +Pakete Debian 8: ''apache2 php5-fpm'' 
 + 
 +  a2dismod cgi 
 +  a2disconf serve-cgi-bin 
 +  a2enmod proxy_fcgi 
 + 
 +<file txt /etc/apache2/conf-available/php-fpm.conf> 
 +<Proxy "unix:/var/run/php5-fpm.sock|fcgi://php-fpm"> 
 +  # we must declare a (any) parameter in here  
 +  # or it won't register the proxy ahead of time 
 +  ProxySet disablereuse=off 
 +</Proxy> 
 +ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 
 +<Directory "/usr/lib/cgi-bin"> 
 +  <FilesMatch ".+\.php$"> 
 +    SetHandler proxy:fcgi://php-fpm 
 +  </FilesMatch> 
 +  AllowOverride None 
 +  Require all granted 
 +</Directory> 
 +</file> 
 + 
 +  a2enconf php-fpm 
 + 
 +  apachectl configtest 
 +  apachectl graceful 
 + 
 +<code php /usr/lib/cgi-bin/phpinfo.php> 
 +<?php 
 +# do not use me in production 
 +  phpinfo(); 
 +  #phpinfo(INFO_MODULES); 
 +?> 
 +</code> 
 + 
 +  wget -nv -O - http://localhost/cgi-bin/phpinfo.php 
 + 
 +  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 
 +# do not use me in production 
 +  phpinfo(); 
 +  phpinfo(INFO_MODULES); 
 +?> 
 +</code> 
 + 
 +  wget -nv -O - http://localhost/phpinfo/phpinfo.php 
 + 
 +  service apache2 status 
 + 
admin_grundlagen/apache-php.1480087436.txt.gz · Zuletzt geändert: 2016/11/25 15:23 von ingo_wichmann