Setup PHP for NGINX

Install

debian

apt install lsb-release ca-certificates apt-transport-https software-properties-common gnupg1
# gnupg2
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/sury-php.list
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
apt update
apt-cache search --names-only "^php8.*-mongodb"

# as of aug 2022
ver=8.1

one needs FPM

    apt install php$ver php$ver-fpm

and additional modules e.g. for roundcube you might want

    apt install \
    php$ver-xml \
    php$ver-mbstring \
    php$ver-intl \
    php$ver-ldap \
    php$ver-sqlite3 \
    php$ver-mysql \
    php$ver-pspell \
    php$ver-curl \
    php-pear \
    php$ver-gd \
    php$ver-imagick \
    php$ver-zip

# dependent version (unused)
#apt install \
#   php-auth-sasl \
#   php-net-smtp \
#   php-mail-mime \
#   php-guzzlehttp-promises \

Setup

    mv -i /etc/php/$ver/fpm/php.ini /etc/php/$ver/fpm/php.ini.dist
grep -vE '^;|^$' /etc/php/$ver/fpm/php.ini.dist > /etc/php/$ver/fpm/php.ini.clean
grep -vE '^;|^$' /etc/php/$ver/fpm/php.ini.dist > /etc/php/$ver/fpm/php.ini
vi /etc/php/$ver/fpm/php.ini

    cp -pi /etc/php/$ver/fpm/php.ini /etc/php/$ver/fpm/php.ini.dist
    vi /etc/php/$ver/fpm/php.ini

    [PHP]

; legacy behavior still required for roundcube?
    cgi.fix_pathinfo=0

; default was 2M
    upload_max_filesize = 5M

; default is fine
;post_max_size = 8M

[Date]
    date.timezone = Europe/Paris
    date.timezone = Europe/Moscow

apply

    systemctl restart php$ver-fpm
    systemctl status php$ver-fpm # already enabled

    ls -lF /var/run/php/php$ver-fpm.sock

Resources

https://wiki.debian.org/PHP

https://packages.sury.org/php/

https://computingforgeeks.com/how-to-install-php-on-debian-linux/


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun