php7.2とphp7.4 MySQL拡張phpを同時インストール

***************************************************************************************************
 
[root@falcon21 ~]# yum remove php-*
 
[root@falcon21 ~]# dnf module reset php 
[root@virtual ~]# for v in 72 74 ; do yum -y install php$v php$v-php-{gd,xml,mbstring,mysqlnd}; done インストール済み: php74-1.0-3.el8.remi.x86_64 php74-php-cli-7.4.14-1.el8.remi.x86_64 php74-php-common-7.4.14-1.el8.remi.x86_64 php74-php-gd-7.4.14-1.el8.remi.x86_64 php74-php-json-7.4.14-1.el8.remi.x86_64 php74-php-mbstring-7.4.14-1.el8.remi.x86_64 php74-php-mysqlnd-7.4.14-1.el8.remi.x86_64 php74-php-pdo-7.4.14-1.el8.remi.x86_64 php74-php-xml-7.4.14-1.el8.remi.x86_64 php74-runtime-1.0-3.el8.remi.x86_64 完了しました! ---------------------------------------------------- [root@virtual ~]# for v in 72 74 ; do yum -y install php$v-php-{mysql,mysqli,zlib,ssh2,ftp,simplexml}; done インストール済み: php74-php-pecl-mysql-1.0.0-0.23.20190415.d7643af.el8.remi.x86_64 php74-php-pecl-ssh2-1.2-2.el8.remi.x86_64 完了しました! ------------------------------------------------------ phpバージョンの確認  [root@virtual ~]# for v in 72 74 ; do php$v -v ; echo \ ; done PHP 7.2.34 (cli) (built: Sep 30 2020 05:15:50) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies PHP 7.4.14 (cli) (built: Jan 5 2021 10:45:06) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies ---------------- [root@virtual ~]# php -v PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies -----------------------------------------------------  php.ini 配置確認 [root@virtual ~]# for v in 72 74 ; do php$v --ini | grep Loaded | awk '{print $1}' ; done Loaded Loaded --------------------------------------------------- 複数php-fpmインストール [root@virtual ~]# for v in 72 74 ; do yum -y install php$v-php-fpm ; done インストール済み: php72-php-fpm-7.2.34-2.el8.remi.x86_64 インストール済み: php74-php-fpm-7.4.14-1.el8.remi.x86_64 完了しました! ----------------------------------------------- php-fpm 設定 プロセスマネージャーの変更 [root@virtual ~]# for v in 72 74 ; do sed -i '/pm = /s/dynamic/ondemand/' /etc/opt/remi/php$v/php-fpm.d /www.conf ; done プロセス確認 [root@virtual ~]# for v in 72 74 ; do grep 'pm = ondemand' /etc/opt/remi/php$v/php-fpm.d/www.conf ; done pm = ondemand pm = ondemand php-fpm listenポート指定 [root@virtual ~]# for v in 74 ; do sed -i "s/9000/90$v/" /etc/opt/remi/php$v/php-fpm.d/www.conf ; done ----------php72のリッスンポートをデフォルト9000にする--------------          /etc/opt/remi/php7.2/php-fpm.d/www.conf php74のリッスンポートを 9074 にする

    確認
[root@virtual ~]# for v in 74 ; do grep 'listen = 127' /etc/opt/remi/php$v/php-fpm.d/www.conf ; done
                  /etc/opt/remi/php7.4/php-fpm.d/www.conf



  Apache php72-php.confの設定(バーチャルホスト)設定
[root@virtual ~]# vi /etc/httpd/conf.d/php72-php.conf
      1 #
      2 # The following lines prevent .user.ini files from being viewed by Web clients.
      3 # 次の行は、.user.iniファイルがWebクライアントによって表示されないようにします。
      4 #<Files ".user.ini">
      5 <Files ".php7.2.ini">
      6     <IfModule mod_authz_core.c>
      7         Require all denied
      8     </IfModule>
      9     <IfModule !mod_authz_core.c>
     10         Order allow,deny
     11         Deny from all
     12         Satisfy All
     13     </IfModule>
     14 </Files>


  Apache php74-php.confの設定(バーチャルホスト)設定
[root@virtual ~]# vi /etc/httpd/conf.d/php74-php.conf 1 # 2 # The following lines prevent .user.ini files from being viewed by Web clients. 3 # 次の行は、.user.iniファイルがWebクライアントによって表示されないようにします。 4 #<Files ".user.ini"> 5 <Files ".php7.4.ini"> 6 <IfModule mod_authz_core.c> 7 Require all denied 8 </IfModule> 9 <IfModule !mod_authz_core.c> 10 Order allow,deny 11 Deny from all 12 Satisfy All 13 </IfModule> 14 </Files> remi.conf 新規作成 php72 をデフォルト設定 [root@virtual ~]# vi /etc/httpd/conf.d/remi.conf <VirtualHost *:80> ServerName php74 <FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9074" </FilesMatch> </VirtualHost> <VirtualHost *:80> ServerName php72 <FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch> </VirtualHost> ~ ------------------------------ php-fpm の起動 [root@virtual ~]# for v in 72 74 ; do systemctl start php$v-php-fpm ; systemctl enable php$v-php-fpm ; done Created symlink /etc/systemd/system/multi-user.target.wants/php72-php-fpm.service → /usr/lib/systemd/system/php72-php-fpm.service. Created symlink /etc/systemd/system/multi-user.target.wants/php74-php-fpm.service → /usr/lib/systemd/system/php74-php-fpm.service. 起動詳細確認 [root@virtual ~]# for v in 72 74 ; do systemctl status php$v-php-fpm ; systemctl status php$v-php-fpm ; done php72-php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php72-php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2021-01-10 20:21:54 JST; 11min ago Main PID: 11820 (php-fpm) Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 1 (limit: 146109) Memory: 7.0M CGroup: /system.slice/php72-php-fpm.service └─11820 php-fpm: master process (/etc/opt/remi/php72/php-fpm.conf) 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Starting The PHP FastCGI Process Manager... 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Started The PHP FastCGI Process Manager. php72-php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php72-php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2021-01-10 20:21:54 JST; 11min ago Main PID: 11820 (php-fpm) Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 1 (limit: 146109) Memory: 7.0M CGroup: /system.slice/php72-php-fpm.service └─11820 php-fpm: master process (/etc/opt/remi/php72/php-fpm.conf) 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Starting The PHP FastCGI Process Manager... 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Started The PHP FastCGI Process Manager. php74-php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php74-php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2021-01-10 20:21:54 JST; 11min ago Main PID: 11853 (php-fpm) Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 1 (limit: 146109) Memory: 7.0M CGroup: /system.slice/php74-php-fpm.service └─11853 php-fpm: master process (/etc/opt/remi/php74/php-fpm.conf) 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Starting The PHP FastCGI Process Manager... 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Started The PHP FastCGI Process Manager. php74-php-fpm.service - The PHP FastCGI Process Manager Loaded: loaded (/usr/lib/systemd/system/php74-php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2021-01-10 20:21:54 JST; 11min ago Main PID: 11853 (php-fpm) Status: "Processes active: 0, idle: 0, Requests: 0, slow: 0, Traffic: 0req/sec" Tasks: 1 (limit: 146109) Memory: 7.0M CGroup: /system.slice/php74-php-fpm.service └─11853 php-fpm: master process (/etc/opt/remi/php74/php-fpm.conf) 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Starting The PHP FastCGI Process Manager... 1月 10 20:21:54 virtual.falcon21.space systemd[1]: Started The PHP FastCGI Process Manager. ---------------------------------- httpd.conf 編集 [root@virtual ~]# vi /etc/httpd/conf/httpd.conf # LoadModule foo_module modules/mod_foo.so # #LoadModule modules/mod_*.so Include conf.modules.d/*.conf #Include conf.d/*.conf  Apache vhost.conf編集
[root@virtual ~]# vi /etc/httpd/conf.d/vhost.conf
    <VirtualHost *:80>
        DocumentRoot "/var/www/html"
        ServerName php72
        <FilesMatch \.php72>
            SetHandler "proxy:fcgi://127.0.0.1:9000"
        </FilesMatch>
        <Directory "/var/www/html">
             AllowOverride All
             Options +ExecCGI
             AddHandler cgi-script .pl .cgi
             Require method GET POST OPTIONS
             AllowOverride FileInfo AuthConfig Limit Indexes
             Require method GET POST OPTIONS
        </Directory>
    </VirtualHost>
 
<VirtualHost *:80> DocumentRoot "/home/anpachi/html" ServerName php74 <FilesMatch \.php74> SetHandler "proxy:fcgi://127.0.0.1:9074" </FilesMatch> <Directory "/home/anpachi/html"> AllowOverride All Options +ExecCGI AddHandler cgi-script .pl .cgi Require method GET POST OPTIONS AllowOverride FileInfo AuthConfig Limit Indexes Require method GET POST OPTIONS </Directory> </VirtualHost>
 php,ini 設定 php72用にデフォルトphp.ini設定 [root@virtual ~]# vi /etc/php.ini 171 user_ini.filename = ".php72.ini" 177 user_ini.cache_ttl = 300 185 engine = On 198 short_open_tag = Off 202 precision = 14 226 output_buffering = 4096 270 zlib.output_compression = Off 288 implicit_flush = Off 296 unserialize_callback_func = 304 serialize_precision = -1 316 disable_functions = 321 disable_classes = 354 zend.enable_gc = On 377 expose_php = On 386 max_execution_time = 30 396 max_input_time = 60 407 memory_limit = 128M 463 error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT 480 display_errors = Off 491 display_startup_errors = Off 501 log_errors = On 506 log_errors_max_len = 1024 511 ignore_repeated_errors = Off 517 ignore_repeated_source = Off 523 report_memleaks = On 553 html_errors = On 624 variables_order = "GPCS" 637 request_order = "GP" 652 register_argc_argv = Off 660 auto_globals_jit = On 675 post_max_size = 2000M 679 auto_prepend_file = 683 auto_append_file = 690 default_mimetype = "text/html" 694 default_charset = "UTF-8" 731 doc_root = 736 user_dir = 752 enable_dl = Off 819 file_uploads = On 828 upload_max_filesize = 2000M 831 max_file_uploads = 20 839 allow_url_fopen = On 843 allow_url_include = Off 856 default_socket_timeout = 60 900 cli_server.color = On 987 pcre.jit=0 999 pdo_mysql.cache_size = 2000 1004 pdo_mysql.default_socket= 1018 sendmail_path = /usr/sbin/sendmail -t -i 1026 mail.add_x_header = Off 1050 odbc.allow_persistent = On 1054 odbc.check_persistent = On 1058 odbc.max_persistent = -1 1062 odbc.max_links = -1 1067 odbc.defaultlrl = 4096 1073 odbc.defaultbinmode = 1 1079 ibase.allow_persistent = 1 1082 ibase.max_persistent = -1 1085 ibase.max_links = -1 1100 ibase.timestampformat = "%Y-%m-%d %H:%M:%S" 1103 ibase.dateformat = "%Y-%m-%d" 1106 ibase.timeformat = "%H:%M:%S" 1112 mysqli.max_persistent = -1 1120 mysqli.allow_persistent = On 1124 mysqli.max_links = -1 1128 mysqli.cache_size = 2000 1135 mysqli.default_port = 3306 1140 mysqli.default_socket = 1144 mysqli.default_host = 1148 mysqli.default_user = 1156 mysqli.default_pw = 1159 mysqli.reconnect = Off 1165 mysqlnd.collect_statistics = On 1170 mysqlnd.collect_memory_statistics = Off 1206 pgsql.allow_persistent = On 1211 pgsql.auto_reset_persistent = Off 1215 pgsql.max_persistent = -1 1219 pgsql.max_links = -1 1224 pgsql.ignore_notice = 0 1229 pgsql.log_notice = 0 1234 bcmath.scale = 1 1243 session.save_handler = files 1284 session.use_strict_mode = 0 1288 session.use_cookies = 1 1298 session.use_only_cookies = 1 1302 session.name = PHPSESSID 1306 session.auto_start = 0 1310 session.cookie_lifetime = 0 1314 session.cookie_path = / 1318 session.cookie_domain = 1322 session.cookie_httponly = 1326 session.serialize_handler = php 1338 session.gc_probability = 1 1352 session.gc_divisor = 1000 1357 session.gc_maxlifetime = 1440 1371 session.referer_check = 1376 session.cache_limiter = nocache 1380 session.cache_expire = 180 1392 session.use_trans_sid = 0 1401 session.sid_length = 26 1413 session.trans_sid_tags = "a=href,area=href,frame=src,form=" 1438 session.sid_bits_per_character = 5 1499 zend.assertions = -1 1530 mbstring.language = Japanese 1537 mbstring.internal_encoding = UTF-8 1545 mbstring.http_input = UTF-8 1555 mbstring.http_output = pass 1563 mbstring.encoding_translation = On 1568 mbstring.detect_order = auto 1573 mbstring.substitute_character = none 1635 tidy.clean_output = Off 1640 soap.wsdl_cache_enabled=1 1648 soap.wsdl_cache_dir="/tmp" 1653 soap.wsdl_cache_ttl=86400 1656 soap.wsdl_cache_limit = 5 1664 ldap.max_links = -1 php74用にphp74.ini設定 [root@virtual ~]# vi /etc/php74.ini 171 user_ini.filename = ".php74.ini" 後は上記php.in に準ずる php72/php-fpm.conf 編集 [root@virtual ~]# vi /etc/opt/remi/php72/php-fpm.conf 11 include=/etc/opt/remi/php72/php-fpm.d/*.conf 20 pid = /var/opt/remi/php72/run/php-fpm/php-fpm.pid 26 error_log = /var/opt/remi/php72/log/php-fpm/error.log 33 syslog.facility = daemon 39 syslog.ident = php-fpm 44 log_level = notice 50 emergency_restart_threshold = 0 58 emergency_restart_interval = 0 64 process_control_timeout = 0 71 process.max = 128 79 process.priority = -19 83 daemonize = yes 87 rlimit_files = 1024 92 rlimit_core = 0 99 events.mechanism = epoll 107 systemd_interval = 10 php72/php-fpm.d/www.conf 編集 [root@virtual ~]# vi /etc/opt/remi/php72/php-fpm.d/www.conf 24 user = apache 26 group = apache 38 listen = /var/opt/remi/php72/run/php-fpm/www.sock 42 listen.backlog = 511 50 listen.mode = 0660 55 listen.acl_users = apache 56 listen.acl_groups = apache 64 listen.allowed_clients = 127.0.0.1 78 process.dumpable = no 104 pm = ondemand 115 pm.max_children = 50 120 pm.start_servers = 5 125 pm.min_spare_servers = 5 130 pm.max_spare_servers = 2 135 pm.process_idle_timeout = 10s; 141 pm.max_requests = 500 257 ping.response = pong 320 access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 325 slowlog = /var/opt/remi/php72/log/php-fpm/www-slow.log 331 request_slowlog_timeout = 0 338 request_terminate_timeout = 0 342 rlimit_files = 1024 347 rlimit_core = 0 364 chdir = /var/www/html 365 chdir = /home/blender/html 372 catch_workers_output = no 381 clear_env = yes 389 security.limit_extensions = .php .php7 394 env[HOSTNAME] = $HOSTNAME 395 env[PATH] = /usr/local/bin:/usr/bin:/bin 396 env[TMP] = /tmp 397 env[TMPDIR] = /tmp 398 env[TEMP] = /tmp 419 php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@virtual.falcon21.space 420 php_flag[display_errors] = off 421 php_admin_value[error_log] = /var/opt/remi/php72/log/php-fpm/www-error.log 422 php_admin_flag[log_errors] = on 423 php_admin_value[memory_limit] = 128M 433 php_value[session.save_handler] = files 434 php_value[session.save_path] = /var/opt/remi/php72/lib/php/session 435 php_value[soap.wsdl_cache_dir] = /var/opt/remi/php72/lib/php/wsdlcache 436 php_value[opcache.file_cache] = /var/opt/remi/php72/lib/php/opcache [root@virtual ~]# vi /etc/opt/remi/php72/php.ini -------------- /etc/php.iniをコピー --------------
   /php74/php-fpm.conf 編集
[root@virtual ~]# vi /etc/opt/remi/php74/php-fpm.conf
     11 include=/etc/opt/remi/php74/php-fpm.d/*.conf
     20 pid = /var/opt/remi/php74/run/php-fpm/php-fpm.pid
     26 error_log = /var/opt/remi/php74/log/php-fpm/error.log
-- 後は、/etc/opt/remi/php72/php-fpm.confに準ずる ------- /php74/php-fpm.d/www.conf 編集 [root@virtual ~]# vi /etc/opt/remi/php74/php-fpm.d/www.conf 24 user = apache 26 group = apache 38 listen = /var/opt/remi/php74/run/php-fpm/www.sock --- 後は、/etc/opt/remi/php72/php-fpm.d/www.confに準ずる ------- [root@virtual ~]# vi /etc/opt/remi/php74/php74.ini ------- /etc/php74.ini をコピー -----------  Apache mysql の起動 [root@falcon21 ~]# for v in 72 74 ; do systemctl restart php$v-php-fpm ; done [root@virtual ~]# systemctl restart httpd mariadb php72利用ページ php74利用ページへアクセス確認
 
 
投票数:20 平均点:10.00

 
Back to Top