Esta web utiliza cookies, puedes ver nuestra política de cookies, aquí Si continuas navegando estás aceptándola

FPM con Apache2.4


Compilamos php con soporte apache2 y fpm:

vi /etc/portage/package.use/php
dev-lang/php apache2 berkdb bzip2 cli crypt ctype curl curlwrappers exif fileinfo filter ftp gd gdbm hash iconv imap intl json mysql mysqli nls odbc pdo phar posix readline session simplexml soap sockets sqlite3 ssl sysvipc threads tokenizer unicode xml xmlreader xmlrpc xmlwriter zip zlib threads fpm cgi truetype bcmath

Configuramos la versión de php:

vi /etc/make.conf
PHP_TARGETS="php5-6"
PHP_INI_VERSION="production"

Compilamos el selector de php con soporte para fpm:

echo "app-eselect/eselect-php fpm" > /etc/portage/package.use/eselect-php

Compilamos php:

emerge -av dev-lang/php

Configuramos el proceso de fpm:

vi /etc/php/fpm-php5.6/php-fpm.conf
[global]
error_log = /var/log/php-fpm.log
include=/etc/php/fpm-php5.6/pool.d/*.conf
mkdir /etc/php/fpm-php5.6/pool.d
vi /etc/php/fpm-php5.6/pool.d/alfaexploit.conf
[alfaexploit]
user = alfaexploit
group = alfaexploit
listen = /var/run/php-fpm_alfaexploit.sock
listen.owner = apache
listen.group = apache
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /status
ping.path = /ping
ping.response = pong
php_admin_value[date.timezone] = Europe/Madrid
php_admin_value[open_basedir] = /var/www/alfaexploit
php_admin_value[expose_php] = Off
php_admin_value[display_errors] = Off

Añadimos el usuario y arrancamos fpm:

useradd alfaexploit
/etc/init.d/php-fpm start
rc-update add php-fpm default

Cambiamos los permisos del document root:

chown -R alfaexploit:alfaexploit /var/www/alfaexploit

Configuramos el vhost:

Listen 80
<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/alfaexploit
        ServerName www.alfaexploit.com
        ErrorLog /var/log/apache2/alfaexploit.error_log
        CustomLog /var/log/apache2/alfaexploit.access_log combined
        DirectoryIndex index.php index.htm index.html

        AddHandler application/x-httpd-php .php .php5 .phtml
        AddHandler application/x-httpd-php-source .phps

        <FilesMatch ".php$">
            SetHandler "proxy:unix:///var/run/php-fpm_alfaexploit.sock|fcgi://localhost/"
        </FilesMatch>
        
        <Proxy fcgi://localhost/ enablereuse=on max=10>
        </Proxy>

        <Directory "/var/www/alfaexploit">
            Options -Indexes +FollowSymLinks
            AllowOverride None
            Require all granted
        </Directory>

</VirtualHost>

Configuramos apache:

vi /etc/conf.d/apache2
APACHE2_OPTS="-D SSL -D LANGUAGE -D PHP5 -D PROXY"

Fixeamos un error en la config:
modules/libphp5.so --> modules/mod_php.so

vi /etc/apache2/modules.d/70_mod_php5.conf
<IfDefine PHP5>
    # Load the module first
    <IfModule !mod_php5.c>
        #LoadModule php5_module    modules/libphp5.so
        LoadModule php5_module    modules/mod_php.so
    </IfModule>

    # Set it to handle the files
    # NOTE: Avoiding AddHandler/AddType for security (bug #538822)
    # NOTE: Please read the related news item!
    <FilesMatch ".(php|php5|phtml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>
    <FilesMatch ".phps$">
        SetHandler application/x-httpd-php-source
    </FilesMatch>

    DirectoryIndex index.php index.phtml
</IfDefine>

Nos aseguramos de tener los módulos mod_unixd,  mod_ssl y mod_proxy cargados:

vi /etc/apache2/httpd.conf

LoadModule unixd_module modules/mod_unixd.so

<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
</IfDefine>

<IfDefine PROXY>
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
</IfDefine>

Comentamos Las siguientes directivas ya que se consideran deprecateds:

#NameVirtualHost *:80
#NameVirtualHost *:443
/etc/init.d/apache2 restart

Autor: Kr0m -- 05/04/2016 23:04:57