戻る
■Apache+PHP8
CentOS7とAmazon Linux 2でPHP8の利用を検証 2022年3月時点では、Amazon Linux 2のExtraリポジトリにPHP8.1は無い PHP8.1を利用したければ、remiリポジトリからインストールする必要があるようだが、そう遠くないうちにExtraリポジトリから利用できるかも …だったが、2022年12月時点ではPHP8.1が利用できるようになっていた Amazon Linux2にPHP8.1を入れる https://zenn.dev/saxsir/scraps/d4815afb346582 ■CentOS7(Vagrant)での検証 # setenforce 0 # getenforce Permissive # vi /etc/sysconfig/selinux
#SELINUX=enforcing SELINUX=disabled
# localedef -f UTF-8 -i ja_JP ja_JP # localectl set-locale LANG=ja_JP.UTF-8 # localectl status # timedatectl set-timezone Asia/Tokyo # timedatectl status # yum -y install httpd # vi /etc/httpd/conf/httpd.conf
ServerName www.example.com:80
# systemctl start httpd # chkconfig httpd on # vi /var/www/html/index.html
test
# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm # yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm # yum -y install yum-utils # yum-config-manager --disable 'remi-php*' # yum-config-manager --enable remi-php81 # yum -y install php81 # php81 -v PHP 8.1.3 (cli) (built: Feb 16 2022 01:00:24) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.1.3, Copyright (c) Zend Technologies Apacheで使用する方法は引き続き以下などを参照する PHP8 を CentOS7 と CentOS8 にインストールする http://var.blog.jp/archives/84744240.html # yum -y install httpd php81-php-fpm # vi /etc/httpd/conf.d/php.conf
<FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>
# systemctl start php81-php-fpm # chkconfig php81-php-fpm on # systemctl restart httpd # vi /var/www/html/phpinfo.php
<?php phpinfo() ?>
# ln /usr/bin/php81 /usr/bin/php # php -v PHP 8.1.3 (cli) (built: Feb 16 2022 01:00:24) (NTS gcc x86_64) Copyright (c) The PHP Group Zend Engine v4.1.3, Copyright (c) Zend Technologies ■Amazon Linux 2 での検証 # localedef -f UTF-8 -i ja_JP ja_JP # localectl set-locale LANG=ja_JP.UTF-8 # localectl status # timedatectl set-timezone Asia/Tokyo # timedatectl status # yum -y install httpd # vi /etc/httpd/conf/httpd.conf
ServerName www.example.com:80
# systemctl restart httpd # chkconfig httpd on # vi /var/www/html/index.html
test
# amazon-linux-extras list | grep php 15 php7.2 available \ 17 lamp-mariadb10.2-php7.2 available \ 31 php7.3 available \ 42 php7.4 available [ =stable ] 51 php8.0 available [ =stable ] # amazon-linux-extras install php8.0 -y # yum -y install php-cli php-common php-devel php-fpm php-gd php-mbstring php-mysqlnd php-pdo php-xml # systemctl restart httpd # php -v PHP 8.0.13 (cli) (built: Dec 17 2021 17:28:11) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.13, Copyright (c) Zend Technologies # vi /var/www/html/phpinfo.php
<?php phpinfo() ?>