0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHP 8.4 source install on RockyLinux 9.0

Last updated at Posted at 2025-01-17

abstract

  • Rocky Linux 9.0
  • PostgreSQLはコミュニティ版をインストールする(17.X)
  • MySQLはコミュニティ版をインストールする(8.4)
  • PHP 8.4.Xをコンパイルする

prepare

dnf config-manager --set-enabled crb
dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

dnf install autoconf
dnf install g++ make cmake bison re2c libxml2-devel sqlite-devel libicu-devel oniguruma-devel httpd httpd-devel systemd-devel

with PostgreSQL

※psqlインストール手順は公式を見た

dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf module disable postgresql
dnf install postgresql17-server
/usr/pgsql-17/bin/postgresql-17-setup initdb
systemctl enable postgresql-17
systemctl start postgresql-17
dnf install libpq5-devel

with MySQL

dnf localinstall https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm

check repository

dnf repolist enabled | grep mysql.*-community

install 8.4

dnf module disable mysql
dnf install mysql-community-server
systemctl start mysqld.service
systemctl enable mysqld.service

set passwd

grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation

download php source

wget https://github.com/php/php-src/archive/refs/tags/php-8.4.2.tar.gz

compile

tar zxfv php-8.4.2.tar.gz 
cd php-src-php-8.4.2/
./buildconf -f

./configure --help
./configure --enable-fpm --enable-intl --enable-mbstring --enable-calendar \
  --with-apxs2=/usr/bin/apxs --with-fpm-systemd \
  --enable-mysqlnd --with-pdo-mysql \
  --with-pgsql=/usr/pgsql-17 --with-pdo-pgsql=/usr/pgsql-17

httpd(apache)周りのオプションはこちらを参考にした。パッケージhttpd-develを事前に入れていればOKだった。

make

install

make install

post install

php.ini
cp php.ini-production /usr/local/lib/php.ini
php-fpm.service
cp sapi/fpm/php-fpm.service /etc/systemd/system/php-fpm.service
/etc/systemd/system/php-fpm.service
PIDFile=/var/run/php-fpm.pid

php-fpm.conf

php-fpm.conf
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf

daemonizeの行を有効化し、最後の行を微修正した

/usr/local/etc/php-fpm.conf
pid = /php-fpm/php-fpm.pid

error_log = /var/log/php-fpm/error.log

daemonize = yes

include=/usr/local/etc/php-fpm.d/*.conf
www-conf
cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf
/usr/local/etc/php-fpm.d/www.conf
user = apache
group = apache

listen = /run/php-fpm/www.sock

listen.mode = 0666
mkdir /run/php-fpm/
mkdir /var/log/php-fpm/
chown apache /var/log/php-fpm/
systemctl daemon-reload
systemctl start php-fpm

httpd.conf

LoadModuleにphp_moduleが入ることを確認する

/etc/httpd/conf/httpd.conf
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
LoadModule php_module         /usr/lib64/httpd/modules/libphp.so
AddType application/x-httpd-php .php
/etc/httpd/conf.d/php.conf
#
# The following lines prevent .user.ini files from being viewed by Web clients.
#
<Files ".user.ini">
    Require all denied
</Files>

#
# Allow php to handle Multiviews
#
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Redirect to local php-fpm (no mod_php in default configuration)
#
<IfModule !mod_php5.c>
  <IfModule !mod_php7.c>
    # Enable http authorization headers
    SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1

    <FilesMatch \.(php|phar)$>
        SetHandler "proxy:unix:/run/php-fpm/www.sock|fcgi://localhost"
    </FilesMatch>
  </IfModule>
</IfModule>

#
# mod_php is deprecated as FPM is now used by default with httpd in event mode
# mod_php is only used when explicitly enabled or httpd switch to prefork mode
#
# mod_php options
#
<IfModule  mod_php7.c>
    #
    # Cause the PHP interpreter to handle files with a .php extension.
    #
    <FilesMatch \.(php|phar)$>
        SetHandler application/x-httpd-php
    </FilesMatch>

    #
    # Uncomment the following lines to allow PHP to pretty-print .phps
    # files as PHP source code:
    #
    #<FilesMatch \.phps$>
    #    SetHandler application/x-httpd-php-source
    #</FilesMatch>

    #
    # Apache specific PHP configuration options
    # those can be override in each configured vhost
    #
    php_value session.save_handler "files"
    php_value session.save_path    "/var/lib/php/session"
    php_value soap.wsdl_cache_dir  "/var/lib/php/wsdlcache"

    #php_value opcache.file_cache   "/var/lib/php/opcache"
</IfModule>
systemctl restart httpd

check

/var/www/html/phpinfo.php
<?php
  date_default_timezone_set("Asia/Tokyo");
  phpinfo();
?>

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?