SLES‐15‐Frontend‐Preparations - hbz/to.science GitHub Wiki

Install php56 and php56-fpm

Add software repositories for php56:
PHP 5.6 for SLES 15.3 from here
PHP 5.6 for SLES 15.4 from here
PHP 5.6 for SLES 15.5 from here
Achtung ! Für SLES 15.6 wird PHP5 von zippy nicht mehr unterstützt.

php56-fpm = fastcgi process manager for php.

Use YaST2 to install:
php56, php56-curl, php56-devel, php56-dom, php56-fastcgi, php56-fpm, php56-gd, php56-intl, php56-json, php56-mbstring, php56-mysql, php56-openssl, php56-pdo .

Configure php56-fastcgi (fpm):

sudo systemctl stop apache2

Install php56-fpm as an independent service

sudo cp /etc/php56/fpm/php-fpm.conf.default /etc/php56/fpm/php-fpm.conf
Make the following changes to php-fpm.conf in a production setting:

diff php-fpm.conf.default php-fpm.conf
149,150c149,152
< user = nobody
< group = nobody
---
> ;user = toscience
> ;group = users
> user = wwwrun
> group = wwwrun
164c166
< listen = 127.0.0.1:9000
---
> listen = 127.0.0.1:10000
176a179,180
> listen.owner = wwwrun
> listen.group = wwwrun
230c235
< ;pm = statuc
---
> pm = dynamic
241c246
< pm.max_children = 5
---
> pm.max_children = 256
246c251
< pm.start_servers = 2
---
> pm.start_servers = 56
251c256
< pm.min_spare_servers = 1
---
> pm.min_spare_servers = 32
256c261
< pm.max_spare_servers = 3
---
> pm.max_spare_servers = 128
261c266
< ;pm.process_idle_timeout = 10s;
---
> pm.process_idle_timeout = 10s;
366c371
< ;pm.status_path = /status
---
> pm.status_path = /status

Create init file

cd /etc/php56/conf.d
cp dom.ini fpm.ini
vim fpm.ini
extension=fpm.so
wq

Also configure /etc/php56/fpm/php.ini properly. Especially increase the following values to

output_buffering = 4096
max_execution_time = 1800
memory_limit = 4096M
post_max_size = 1024M
upload_max_filesize = 2048M
max_file_uploads = 20

Install start script:

cd /etc/systemd/system

mv /usr/lib/systemd/system/php56-fpm.service .

sudo systemctl daemon-reload

sudo systemctl start php56-fpm.service

sudo systemctl enable —now php56-fpm

Is the service listening to port 10000 ?
ss -lnpt | grep 10000

Configure Apache2 to work with the PHP56 FastCGI Process Manager (FPM)

sudo zypper install apache2-event
sudo zypper install apache2-mod_fcgid
sudo zypper remove apache2-prefork
sudo zypper remove apache2-mod_php56

vim /etc/sysconfig/apache2

  APACHE_MODULES="setenvif proxy  proxy_fcgi fcgid" # those must be included
   APACHE_MPM="event"

Edit mod_fcgid.conf
Edit /etc/apache2/conf.d/mod_fcgid.conf
Add the following content at the end:

   <IfModule fcgid_module>

    DirectoryIndex index.php
    <FilesMatch "\.php$">
        SetHandler "proxy:fcgi://127.0.0.1:10000/"
        #CGIPassAuth on
    </FilesMatch>
    </IfModule>

Enable Modules and Restart Services

sudo a2enmod proxy_http
sudo a2enmod proxy
sudo a2enmod proxy_fcgi
sudo a2enmod setenvif
sudo a2enmod fcgid
sudo a2enmod rewrite

If not already running, start mariadb

sudo systemctl start mariadb

Restart services

sudo systemctl restart php56-fpm

sudo systemctl restart apache2

Test PHP5 and the apache configuration of PHP5

Let apache point to drupal

In /etc/apache2/vhosts.d/ create a file site.conf or site.ssl.conf, if not yet present.
Add the following contents:

<VirtualHost *:80>
    ServerName localhost
    ServerAdmin admin@localhost
    DocumentRoot /opt/toscience/drupal

    ErrorLog /var/log/apache2/localhost-error_log
    CustomLog /var/log/apache2/localhost-access_log combined

    <Directory "/">
        Options FollowSymLinks
        AllowOverride None
    </Directory>

    <Directory "/opt/toscience/drupal">
        Options Indexes FollowSymLinks
        AllowOverride All
        RewriteCond %{REQUEST_URI} !^server_status
        Require all granted
    </Directory>

</VirtualHost>

Create a file /opt/toscience/drupal/info.php with the following content:

<?php phpinfo(); ?>

Restart apache2

systemctl restart apache2

Point your browser to http://localhost/info.php . You should reach a page “PHP Version 5.6.40” with precise installation details.

⚠️ **GitHub.com Fallback** ⚠️