Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung |
wiki:centos:mehrere_php_versionen [2019/02/02 22:09] – wikiadmin | wiki:centos:mehrere_php_versionen [2020/04/15 11:37] (aktuell) – wikiadmin |
---|
Je nach dem, welche PHP-Version man möchte, heißen die Pakete jetzt: php<Version>-php-<modul> | Je nach dem, welche PHP-Version man möchte, heißen die Pakete jetzt: php<Version>-php-<modul> |
| |
| ==== PHP 5.4 ==== |
| <file>yum install php54-php php54-php-bcmath php54-php-cli php54-php-common php54-php-devel php54-php-gd php54-php-gmp.x86_64 php54-php-intl.x86_64 php54-php-json.x86_64 php54-php-mbstring.x86_64 php54-php-mcrypt.x86_64 php54-php-mysqlnd.x86_64 php54-php-opcache.x86_64 php54-php-pdo.x86_64 php54-php-process.x86_64 php54-php-tidy.x86_64 php54-php-xml.x86_64 php54-php-pecl-apcu.x86_64 php54-php-pecl-geoip.x86_64 php54-php-pecl-igbinary.x86_64 php54-php-pecl-imagick.x86_64 php54-php-pecl-memcached.x86_64 php54-php-pecl-msgpack.x86_64 php54-php-pecl-zip.x86_64</file> |
| |
| ==== PHP 5.5 ==== |
| |
| <file>yum install php55-php php55-php-bcmath php55-php-cli php55-php-common php55-php-devel php55-php-gd php55-php-gmp.x86_64 php55-php-intl.x86_64 php55-php-json.x86_64 php55-php-mbstring.x86_64 php55-php-mcrypt.x86_64 php55-php-mysqlnd.x86_64 php55-php-opcache.x86_64 php55-php-pdo.x86_64 php55-php-process.x86_64 php55-php-tidy.x86_64 php55-php-xml.x86_64 php55-php-pecl-apcu.x86_64 php55-php-pecl-geoip.x86_64 php55-php-pecl-igbinary.x86_64 php55-php-pecl-imagick.x86_64 php55-php-pecl-memcached.x86_64 php55-php-pecl-msgpack.x86_64 php55-php-pecl-zip.x86_64</file> |
| |
| ==== PHP 5.6 ==== |
| |
| <file>yum install php56-php php56-php-bcmath php56-php-cli php56-php-common php56-php-devel php56-php-gd php56-php-gmp.x86_64 php56-php-intl.x86_64 php56-php-json.x86_64 php56-php-mbstring.x86_64 php56-php-mcrypt.x86_64 php56-php-mysqlnd.x86_64 php56-php-opcache.x86_64 php56-php-pdo.x86_64 php56-php-process.x86_64 php56-php-tidy.x86_64 php56-php-xml.x86_64 php56-php-pecl-apcu.x86_64 php56-php-pecl-geoip.x86_64 php56-php-pecl-igbinary.x86_64 php56-php-pecl-imagick.x86_64 php56-php-pecl-memcached.x86_64 php56-php-pecl-msgpack.x86_64 php56-php-pecl-zip.x86_64</file> |
| |
| <note>__Notiz:__ |
| |
| Ab hier wird nur noch auf die PHP-Versionen 7.x eingegangen. PHP in der Version 5.x sollte nicht mehr verwendet werden, wird der vollständigkeit halber aber aufgelistet</note> |
==== PHP 7.0 ==== | ==== PHP 7.0 ==== |
| |
==== PHP 7.3 ==== | ==== PHP 7.3 ==== |
<file>yum install php73-php php73-php-bcmath php73-php-cli php73-php-common php73-php-devel php73-php-gd php73-php-gmp.x86_64 php73-php-intl.x86_64 php73-php-json.x86_64 php73-php-mbstring.x86_64 php73-php-mcrypt.x86_64 php73-php-mysqlnd.x86_64 php73-php-opcache.x86_64 php73-php-pdo.x86_64 php73-php-process.x86_64 php73-php-tidy.x86_64 php73-php-xml.x86_64 php73-php-pecl-apcu.x86_64 php73-php-pecl-geoip.x86_64 php73-php-pecl-igbinary.x86_64 php73-php-pecl-imagick.x86_64 php73-php-pecl-memcached.x86_64 php73-php-pecl-msgpack.x86_64 php73-php-pecl-zip.x86_64</file> | <file>yum install php73-php php73-php-bcmath php73-php-cli php73-php-common php73-php-devel php73-php-gd php73-php-gmp.x86_64 php73-php-intl.x86_64 php73-php-json.x86_64 php73-php-mbstring.x86_64 php73-php-mcrypt.x86_64 php73-php-mysqlnd.x86_64 php73-php-opcache.x86_64 php73-php-pdo.x86_64 php73-php-process.x86_64 php73-php-tidy.x86_64 php73-php-xml.x86_64 php73-php-pecl-apcu.x86_64 php73-php-pecl-geoip.x86_64 php73-php-pecl-igbinary.x86_64 php73-php-pecl-imagick.x86_64 php73-php-pecl-memcached.x86_64 php73-php-pecl-msgpack.x86_64 php73-php-pecl-zip.x86_64</file> |
| ==== PHP 7.4 ==== |
| <file>yum install $(yum list installed "php??-*" | awk '{print $1}' | egrep -v "Installed|Loaded" | cut -d "-" -f 2- | cut -d "." -f 1 | sort | uniq | egrep -v "php7|runtime" | sed -e 's/^/php74-/')</file> |
| |
===== PHP FastCGI Process Manager ===== | ===== PHP FastCGI Process Manager ===== |
==== Paketinstallation ==== | ==== Paketinstallation ==== |
| |
<file>yum install php70-php-fpm.x86_64 php71-php-fpm.x86_64 php72-php-fpm.x86_64 php73-php-fpm.x86_64</file> | <file>yum install php70-php-fpm.x86_64 php71-php-fpm.x86_64 php72-php-fpm.x86_64 php73-php-fpm.x86_64 php74-php-fpm.x86_64</file> |
| |
==== Prozesse stoppen ==== | ==== Prozesse stoppen ==== |
| |
<file>systemctl stop php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service</file> | <file>systemctl stop php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service php74-php-fpm.x86_64</file> |
| |
Wenn man mehrere FastCGI Process Manager installiert hat, kann es in de Prozessansicht ziemlich unübersichtlich werden, da jeder mit einem Pool namens www arbeitet. Deshalb werden die Pool's umbenannt. | Wenn man mehrere FastCGI Process Manager installiert hat, kann es in de Prozessansicht ziemlich unübersichtlich werden, da jeder mit einem Pool namens www arbeitet. Deshalb werden die Pool's umbenannt. |
| 7.2 | www-php72 | 60072 | | | 7.2 | www-php72 | 60072 | |
| 7.3 | www-php73 | 60073 | | | 7.3 | www-php73 | 60073 | |
| | 7.4 | www-php74 | 60074 | |
| |
| |
==== Pool-Namen umbenennen ==== | ==== Pool-Namen umbenennen ==== |
| |
<file>sed -e 's/\[www\]/\[www-php70\]/' -i /etc/opt/remi/php70/php-fpm.d/www.conf | <file>sed -e 's/\[www\]/\[www-php7.0\]/' -i /etc/opt/remi/php70/php-fpm.d/www.conf |
sed -e 's/\[www\]/\[www-php71\]/' -i /etc/opt/remi/php71/php-fpm.d/www.conf | sed -e 's/\[www\]/\[www-php7.1\]/' -i /etc/opt/remi/php71/php-fpm.d/www.conf |
sed -e 's/\[www\]/\[www-php72\]/' -i /etc/opt/remi/php72/php-fpm.d/www.conf | sed -e 's/\[www\]/\[www-php7.2\]/' -i /etc/opt/remi/php72/php-fpm.d/www.conf |
sed -e 's/\[www\]/\[www-php73\]/' -i /etc/opt/remi/php73/php-fpm.d/www.conf</file> | sed -e 's/\[www\]/\[www-php7.3\]/' -i /etc/opt/remi/php73/php-fpm.d/www.conf |
| sed -e 's/\[www\]/\[www-php7.4\]/' -i /etc/opt/remi/php74/php-fpm.d/www.conf</file> |
| |
==== Port's umbenennen ==== | ==== Port's umbenennen ==== |
sed -e 's/\:9000/\:60071/' -i /etc/opt/remi/php71/php-fpm.d/www.conf | sed -e 's/\:9000/\:60071/' -i /etc/opt/remi/php71/php-fpm.d/www.conf |
sed -e 's/\:9000/\:60072/' -i /etc/opt/remi/php72/php-fpm.d/www.conf | sed -e 's/\:9000/\:60072/' -i /etc/opt/remi/php72/php-fpm.d/www.conf |
sed -e 's/\:9000/\:60073/' -i /etc/opt/remi/php73/php-fpm.d/www.conf</file> | sed -e 's/\:9000/\:60073/' -i /etc/opt/remi/php73/php-fpm.d/www.conf |
| sed -e 's/\:9000/\:60074/' -i /etc/opt/remi/php74/php-fpm.d/www.conf</file> |
| |
==== Zeitzonen einer Jeden PHP-Version umbennenen ==== | ==== Zeitzonen einer Jeden PHP-Version umbennenen ==== |
sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php71/php.ini | sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php71/php.ini |
sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php72/php.ini | sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php72/php.ini |
sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php73/php.ini</file> | sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php73/php.ini |
| sed -e 's/;date.timezone =/;date.timezone =\ndate.timezone = Europe\/Berlin/' -i /etc/opt/remi/php75/php.ini</file> |
| |
==== Startverhalten ändern ==== | ==== Startverhalten ändern ==== |
| |
Es gibt die Option, den pool "on demand" zu starten | Es gibt die Option, den pool "on demand" zu starten |
<note important>__Achtung:__ | |
| |
ondemand ist ein Test für mich. Mal schauen, ob ich dadurch Performance-Einbußen oder -Gewinne habe</note> | <note> |
| __Nachtrag:__ |
| |
| Nach mehreren Test war ondemand 15% - 25% schneller als dynamisch</note> |
| |
<file>sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php70/php-fpm.d/www.conf | <file>sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php70/php-fpm.d/www.conf |
sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php71/php-fpm.d/www.conf | sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php71/php-fpm.d/www.conf |
sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php72/php-fpm.d/www.conf | sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php72/php-fpm.d/www.conf |
sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php73/php-fpm.d/www.conf</file> | sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php73/php-fpm.d/www.conf |
| sed -e 's/pm = dynamic/;pm = dynamic\npm = ondemand/' -i /etc/opt/remi/php74/php-fpm.d/www.conf</file> |
| |
==== SELinux ==== | ==== SELinux ==== |
semanage port -a -t http_port_t -p tcp 60072 | semanage port -a -t http_port_t -p tcp 60072 |
semanage port -a -t http_port_t -p tcp 60073 | semanage port -a -t http_port_t -p tcp 60073 |
| semanage port -a -t http_port_t -p tcp 60074 |
</file> | </file> |
| |
Jetzt noch alle Prozessmanager starten und beim boot aktivieren | Jetzt noch alle Prozessmanager starten und beim boot aktivieren |
| |
<file>systemctl start php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service | <file>systemctl start php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service php74-php-fpm.x86_64 |
systemctl enable php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service</file> | systemctl enable php70-php-fpm.service php71-php-fpm.service php72-php-fpm.service php73-php-fpm.service php74-php-fpm.x86_64</file> |
| |
===== Benutzung ===== | ===== Benutzung ===== |
__Lösung:__ Alle php-Versionen sind verfügbar und können über php70, php71, php72, php73 aufgerufen werden. Es handelt sich hier um symbolische Links | __Lösung:__ Alle php-Versionen sind verfügbar und können über php70, php71, php72, php73 aufgerufen werden. Es handelt sich hier um symbolische Links |
<file> | <file> |
ls -la /bin/php70 /bin/php71 /bin/php72 /bin/php73 | ls -la /bin/php?? |
lrwxrwxrwx 1 root root 32 Jan 30 14:40 /bin/php70 -> /opt/remi/php70/root/usr/bin/php | lrwxrwxrwx 1 root root 32 Jan 30 14:40 /bin/php70 -> /opt/remi/php70/root/usr/bin/php |
lrwxrwxrwx 1 root root 32 Jan 30 14:35 /bin/php71 -> /opt/remi/php71/root/usr/bin/php | lrwxrwxrwx 1 root root 32 Jan 30 14:35 /bin/php71 -> /opt/remi/php71/root/usr/bin/php |
lrwxrwxrwx 1 root root 32 Jan 30 14:36 /bin/php72 -> /opt/remi/php72/root/usr/bin/php | lrwxrwxrwx 1 root root 32 Jan 30 14:36 /bin/php72 -> /opt/remi/php72/root/usr/bin/php |
lrwxrwxrwx 1 root root 32 Jan 30 14:41 /bin/php73 -> /opt/remi/php73/root/usr/bin/php | lrwxrwxrwx 1 root root 32 Jan 30 14:41 /bin/php73 -> /opt/remi/php73/root/usr/bin/php |
| lrwxrwxrwx 1 root root 32 Apr 15 11:24 /bin/php74 -> /opt/remi/php74/root/usr/bin/php |
| |
</file> | </file> |
| |
All diese Pakete kann man bedenkenlos deinstallieren | All diese Pakete kann man bedenkenlos deinstallieren |
| |
| |
| ====== Quellen ====== |
| |
| * [[https://developers.redhat.com/blog/2017/10/25/php-configuration-tips/|PHP Configuration Tips]] |
| * [[https://wiki.centos.org/HowTos/php7/|Using PHP 7.x on CentOS 7.4]] |
| * [[https://developers.redhat.com/blog/2014/04/08/apache-with-various-php-versions-using-scl/|Apache with various PHP versions, using SCL]] |
| * [[https://blog.remirepo.net/post/2016/04/16/My-PHP-Workstation]] |
| * [[https://www.dotcom-tools.com/website-speed-test.aspx|Website Speed test]] |