pastafari2/scripts/system/install_php.py
2025-05-18 23:47:15 +02:00

61 lines
2.5 KiB
Python

#!/usr/bin/python3 -u
# A script for install pzoo user
from subprocess import call
from time import sleep
import distro
linux_distro=distro.id()
print('{"error": 0, "status": 0, "progress": 0, "no_progress":0, "message": "Installing php..."}')
sleep(1)
if linux_distro=='arch':
if call("sudo pacman -S --noconfirm php php-gd php-pgsql php-snmp php-sodium php-sqlite", shell=True) > 0:
print('Error, cannot install php...')
exit(1)
elif linux_distro=='debian' or linux_distro=='ubuntu':
if call('sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y php-fpm php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-redis unzip', shell=True) > 0:
print('Error, cannot install php...')
exit(1)
elif linux_distro=='rocky' or linux_distro=='fedora' or linux_distro=='almalinux':
if linux_distro=='rocky' or linux_distro=='almalinux':
# In fedora, install some extra packages for get modular php packages from remi.
rh_version=distro.version()
"""
dnf config-manager --set-enabled crb
Command to install the EPEL repository configuration package:
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
Command to install the Remi repository configuration package:
dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm
"""
if call("dnf config-manager --set-enabled crb && dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-%s.noarch.rpm && dnf install https://rpms.remirepo.net/enterprise/remi-release-%s.rpm" % (rh_version, rh_version), shell=True) > 0:
print('Error, cannot enable remi repo...')
exit(1)
if linux_distro=='fedora':
# In fedora, install some extra packages for get modular php packages from remi.
fedora_version=distro.version()
if call("dnf -y install https://rpms.remirepo.net/fedora/remi-release-%s.rpm && dnf config-manager setopt remi.enabled=1" % fedora_version, shell=True) > 0:
print('Error, cannot enable remi repo...')
exit(1)
if call("sudo dnf -y install php84 php84-php-gd php84-php-mysqlnd php84-php-imap php84-php-intl php84-php-fpm php84-php-process composer unzip", shell=True) > 0:
print('Error, cannot install php...')
exit(1)