3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

amazon linux2にphp8.1とapacheを入れる方法

Last updated at Posted at 2022-10-16

つまったので、解決方法を共有しておきます

PHP8.1インストール

sudo su

yum update -y
amazon-linux-extras install epel -y
yum-config-manager --enable epel
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum-config-manager --disable 'remi-php*' -y
yum-config-manager --enable remi-php81 -y
yum update -y
yum install php81 -y
yum -y install php81-php-{xml,zip,mysql,mysqlnd,bcmath,ctype,memcached,gd,apcu,pear,devel,json,mbstring,openssl,tokenizer,xml}

phpコマンドが動くようにする
alternatives --install /usr/bin/php php /usr/bin/php81 1

apaceインストール

yum install httpd -y
systemctl start httpd
systemctl enable httpd

php-fpmインストール

yum -y install php81-php-fpm
systemctl start php81-php-fpm.service
systemctl enable php81-php-fpm
vi /etc/httpd/conf.d/virtualhost.conf
下記を追加
<Directory "/var/www/html">
 <FilesMatch \.php$>
 SetHandler "proxy:fcgi://localhost:9000"
 </FilesMatch>
</Directory>

vim /etc/httpd/conf/httpd.conf
DirectoryIndexに、index.phpを追加

文法チェック

apachectl configtest

systemctl restart php81-php-fpm.service
systemctl restart httpd
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?