打印/下载
安装&配置

软件仓库

# PHP7.4
dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

安装PHP7

# PHP7.4
dnf install php74-php-fpm php74-php-cli php74-php-gd php74-php-pdo php74-php-mbstring -y
# PHP8.0
dnf install php80-php-fpm php80-php-cli php80-php-gd php80-php-pdo php80-php-mbstring -y
# 开机启动
systemctl enable php74-php-fpm
# systemctl enable php80-php-fpm

扩展

# Phalcon
dnf install php74-php-phalcon4 -y
# Swoole
dnf install php74-php-pecl-swoole4 -y
dnf install php80-php-pecl-swoole4 -y
# Redis
dnf install redis php74-php-pecl-redis5 -y
dnf install redis php80-php-pecl-redis5 -y
# 开机启动
systemctl enable redis

启动

systemctl start redis
systemctl start php74-php-fpm

PHP配置

vi /etc/opt/remi/php74/php.ini
  • date.timezone = "Asia/Shanghai"
  • session.save_path = "/tmp"

PHP-FPM配置

vi /etc/opt/remi/php74/php-fpm.d/www.conf
  • user = nginx
  • group = nginx
  • listen = /var/opt/remi/php74/run/php-fpm/www.sock

Session问题

chmod -R 777 /var/opt/remi/php74/lib/php/session

PHP环境

# 探针
echo '<?php phpinfo(); ?>' > /home/www/phpinfo.php
chmod -R 777 /home/www/phpinfo.php

Nginx调用PHP-FPM

vi /home/vhosts/default.conf

    # PHP-FPM
    location ~ \.php$ {
        #fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass   unix:/var/opt/remi/php74/run/php-fpm/www.sock;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

重启

systemctl restart nginx
{{copy}}