XAMPP for Windows 7.2.0

2018.01.06

WindowsにもMacと似た開発環境を念のため用意しておこうと思い久しぶりにXAMPPをインストールした時の備忘録。

必要な環境としてはPHP7.2、Apache2.4、MySQL5.7.9~(utf8mb4を同様に使用できれば可)といった辺りが条件。

 

XAMPP 7.2.0 は以下のようなバージョン構成。

  • PHP 7.2.0
  • Apache 2.4.29
  • MariaDB 10.1.29
  • OpenSSL 1.0.2n (Unix)/ 1.1.0g (Windows)
  • phpMyAdmin 4.7.6

 

取り敢えずデフォルトでインストールした後、設定を少々修正。

Apache設定ファイル C:xamppapacheconfhttpd.conf
Document rootをNAS上のディレクトリに変更
MariaDB root password設定
コマンドプロンプトで C:xamppmysqlbin に移動し、mysqladmin -u root password で設定
phpMyAdmin設定 C:xamppphpMyAdminconfconfig.inc.php
phpMyAdminの設定ファイルにroot passwordを設定
MariaDB設定ファイル C:xamppmysqlbinmy.ini
MariaDB 10.1.29とMySQL 5.7でデフォルト設定が下記のように違いがある。
設定項目 MariaDB 10.1.29 MySQL 5.7
innodb_file_format Antelope Barracuda (MySQL 5.7.7~)
innodb_large_prefix OFF ON (MySQL 5.7.7~ Deprecated 5.7.7)
innodb_file_per_table ON ON (MySQL 5.6.6~)
innodb_default_row_format option(compact) DYNAMIC (MySQL 5.7.9~)
MySQL 5.7.9 以降を使用するのであれば文字コードutf8mb4のテーブルでvarchar(255)のようなカラムにインデックスを作成する場合もデフォルトのままで通常は問題ない。
DB作成時に留意する点はcollationをデフォルトのutf8mb4_general_ciのままにするかutf8mb4_binのように寿司ビールを区別するかという点の方かもしれない。
こちらは要件次第で選択するという形になるかと思う。
MariaDB 10.1.29のデフォルトの状態だと、文字コードutf8mb4のテーブルでvarchar(255)のようなカラムにインデックスを作成する場合、
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
といったエラーが出るが、これはutf8mb4の1文字を4byte計算した場合、インデックスの許容サイズが191文字までとなるためのエラー。
対処法はいくつか考えられるが、今後のことを考慮するとinnodb_large_prefixをONにする方法が良さそう。

utf8mb4で255文字までのインデックスを作成できるようにするためには
 innodb_large_prefix = ON
の設定が必要で、この設定を行えるようにするために次の設定
 innodb_file_format = Barracuda
 innodb_file_per_table = ON (MariaDB 10.1.29、MySQL 5.7、ともにデフォルト値)
 innodb_default_row_format = DYNAMIC
が必要となる。
innodb_default_row_format = DYNAMIC についてはテーブル作成時に
CREATE TABLE `TABLE_NAME` (
    :
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC;

としているため問題ない。

 

httpd.conf

Set root password

config.inc.php

my.ini

    :
DocumentRoot "//NAS_NAME/WebServer"
<Directory "//NAS_NAME/WebServer/htdocs">
#DocumentRoot "C:/xampp/htdocs"
#<Directory "C:/xampp/htdocs">
    :
</Directory>
    :
C:/xampp/mysql/bin/mysqladmin -u root password 
New password: **********
Confirm new password: **********
    :
/* Authentication type and info */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'PASSWORD';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;
$cfg['Lang'] = '';
    :
    :
[mysqld]
    :
innodb_file_format = Barracuda
innodb_large_prefix = ON

[mysqldump]
    :

ここまで作業を行った後、PEARでよく使用するパッケージをインストールしようとしたところエラーがあるようで、upgradeもinstallも失敗する。
エラー部分のソースコードを確認し、念のためインターネット上の情報も探してみるとPHP 7.2に対応した記述になっていないようでこの部分のみ修正する。
この修正だけでPEARは動作するが、念のためPEARの設定を確認してみると少々気持ちわるい設定となっていたため、合わせて設定についても修正しておく。

PEAR エラーファイル C:xamppphppearArchiveTar.php
660行目付近を一部修正。
PEAR本家の方では既に対応済みのようで、PEARパッケージ(Archive_Tar)のupgradeをかけると最新の修正済みファイルに変更される模様。
PEAR 設定の確認・変更 C:xamppphppear.bat
コマンドプロンプトで C:xamppphp に移動し、pear config-show を実行して設定確認。
以前はXAMPPのPEARにもpear.iniがあったような気がしたが見当たらないので、それらしきファイルを覗いてみると
現在はpear.batでコマンドを入力したタイミングで環境変数にPEARの設定を割り当てている。気になった設定部分は次の部分。

  1. Windowsのユーザーのフォルダにデータが保存される設定部分
  2. C:php へ保存するように設定されている部分
  3. C:WINDOWS へ保存するように設定されている部分
  4. c:gnupggpg.exe が設定されている部分

1番は修正したい。2番、3番は通常は勝手にフォルダが作成されたりしないため問題ないが気持ちわるいので全て C:xamppphp 内に収めたい。4番についてはローカルなテスト環境のみでの使用で特に必要ないが、気になるようならWindows用のGnuPGをインストールすれば勝手に変更される。
pear.batに追記設定後、全てのパッケージをupgradeして、すぐに必要なパッケージ(MDB2、Pager、HTTP_Request2、Mail_Queue)をインストール。
(XML_Utilについては一旦、現状維持とする。)

 

Tar.php

pear config-show (default)

pear.bat

pear config-show

Pear Packages Upgrade, Install

    :
        // ----- Get the arguments
//      $v_att_list = & func_get_args();
        $v_att_list = func_get_args();
    :
C:xamppphp>pear config-show
CONFIGURATION (CHANNEL PEAR.PHP.NET):
=====================================
Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          C:xamppphp
PEAR documentation directory   doc_dir          C:phppeardocs
PHP extension directory        ext_dir          C:xamppphpext
PEAR directory                 php_dir          C:xamppphppear
PEAR Installer cache directory cache_dir        C:UsersUSER_NAMEAppDataLocalTemppearcache
PEAR configuration file        cfg_dir          C:phppearcfg
directory
PEAR data directory            data_dir         C:phppeardata
PEAR Installer download        download_dir     C:UsersUSER_NAMEAppDataLocalTemppeardownload
directory
Systems manpage files          man_dir          C:phplocalman
directory
PEAR metadata directory        metadata_dir     <not set>
PHP CLI/CGI binary             php_bin          C:xamppphpphp.exe
php.ini location               php_ini          <not set>
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         C:UsersUSER_NAMEAppDataLocalTemppeartemp
PEAR test directory            test_dir         C:phppeartests
PEAR www files directory       www_dir          C:phppearwww
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            0
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          c:gnupggpg.exe
Signature Key Directory        sig_keydir       C:WINDOWSpearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         C:WINDOWSpear.ini
System Configuration File      Filename         C:WINDOWSpearsys.ini
    :
REM Check PEAR global ENV, set them if they do not exist
IF "%PHP_PEAR_INSTALL_DIR%"=="" SET "PHP_PEAR_INSTALL_DIR=C:xamppphppear"
IF "%PHP_PEAR_BIN_DIR%"=="" SET "PHP_PEAR_BIN_DIR=C:xamppphp"
IF "%PHP_PEAR_PHP_BIN%"=="" SET "PHP_PEAR_PHP_BIN=C:xamppphpphp.exe"

IF "%PHP_PEAR_DOC_DIR%"=="" SET "PHP_PEAR_DOC_DIR=C:xamppphpdocs"
IF "%PHP_PEAR_CACHE_DIR%"=="" SET "PHP_PEAR_CACHE_DIR=C:xamppphptmppearcache"
IF "%PHP_PEAR_CFG_DIR%"=="" SET "PHP_PEAR_CFG_DIR=C:xamppphpcfg"
IF "%PHP_PEAR_DATA_DIR%"=="" SET "PHP_PEAR_DATA_DIR=C:xamppphpdata"
IF "%PHP_PEAR_DOWNLOAD_DIR%"=="" SET "PHP_PEAR_DOWNLOAD_DIR=C:xamppphptmppeardownload"
IF "%PHP_PEAR_MAN_DIR%"=="" SET "PHP_PEAR_MAN_DIR=C:xamppphpman"
IF "%PHP_PEAR_TEMP_DIR%"=="" SET "PHP_PEAR_TEMP_DIR=C:xamppphptmppeartemp"
IF "%PHP_PEAR_TEST_DIR%"=="" SET "PHP_PEAR_TEST_DIR=C:xamppphptests"
IF "%PHP_PEAR_WWW_DIR%"=="" SET "PHP_PEAR_WWW_DIR=C:xamppphpwww"
IF "%PHP_PEAR_SYSCONF_DIR%"=="" SET "PHP_PEAR_SYSCONF_DIR=C:xamppphp"
    :
C:xamppphp>pear config-show
CONFIGURATION (CHANNEL PEAR.PHP.NET):
=====================================
Auto-discover new Channels     auto_discover    <not set>
Default Channel                default_channel  pear.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pear.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          C:xamppphp
PEAR documentation directory   doc_dir          C:xamppphpdocs
PHP extension directory        ext_dir          C:xamppphpext
PEAR directory                 php_dir          C:xamppphppear
PEAR Installer cache directory cache_dir        C:xamppphptmppearcache
PEAR configuration file        cfg_dir          C:xamppphpcfg
directory
PEAR data directory            data_dir         C:xamppphpdata
PEAR Installer download        download_dir     C:xamppphptmppeardownload
directory
Systems manpage files          man_dir          C:xamppphpman
directory
PEAR metadata directory        metadata_dir     <not set>
PHP CLI/CGI binary             php_bin          C:xamppphpphp.exe
php.ini location               php_ini          <not set>
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         C:xamppphptmppeartemp
PEAR test directory            test_dir         C:xamppphptests
PEAR www files directory       www_dir          C:xamppphpwww
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            0
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          C:Program Files
                                                (x86)gnupgbingpg.EXE
Signature Key Directory        sig_keydir       C:xamppphppearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         C:xamppphppear.ini
System Configuration File      Filename         C:xamppphppearsys.ini
C:xamppphp>pear list-upgrades
PEAR.PHP.NET AVAILABLE UPGRADES (STABLE):
=========================================
CHANNEL      PACKAGE     LOCAL           REMOTE          SIZE
pear.php.net Archive_Tar 1.4.0 (stable)  1.4.3 (stable)  21kB
pear.php.net PEAR        1.10.1 (stable) 1.10.5 (stable) 285kB
pear.php.net XML_Util    1.3.0 (stable)  1.4.3 (stable)  18.4kB

C:xamppphp>pear upgrade Archive_Tar
downloading Archive_Tar-1.4.3.tgz ...
Starting to download Archive_Tar-1.4.3.tgz (20,682 bytes)
........done: 20,682 bytes
upgrade ok: channel://pear.php.net/Archive_Tar-1.4.3

C:xamppphp>pear upgrade PEAR
WARNING: "pear/Console_Getopt" is deprecated in favor of "pear/Console_GetoptPlus"
downloading PEAR-1.10.5.tgz ...
Starting to download PEAR-1.10.5.tgz (291,151 bytes)
.............................................................done: 291,151 bytes
downloading XML_Util-1.4.2.tgz ...
Starting to download XML_Util-1.4.2.tgz (18,993 bytes)
...done: 18,993 bytes
upgrade ok: channel://pear.php.net/XML_Util-1.4.2
upgrade ok: channel://pear.php.net/PEAR-1.10.5
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)
PEAR: To install optional features use "pear install pear/PEAR#featurename"

C:xamppphp>pear upgrade XML_Util
pear/pear dependency package "pear/XML_Util" downloaded version 1.4.3 is not the recommended version 1.4.2, but may be compatible, use --force to install
pear/XML_Util cannot be installed, conflicts with installed packages
No valid packages found
upgrade failed

C:xamppphp>pear install MDB2
downloading MDB2-2.4.1.tgz ...
Starting to download MDB2-2.4.1.tgz (121,557 bytes)
.................done: 121,557 bytes
install ok: channel://pear.php.net/MDB2-2.4.1
MDB2: Optional feature fbsql available (Frontbase SQL driver for MDB2)
MDB2: Optional feature ibase available (Interbase/Firebird driver for MDB2)
MDB2: Optional feature mysql available (MySQL driver for MDB2)
MDB2: Optional feature mysqli available (MySQLi driver for MDB2)
MDB2: Optional feature mssql available (MS SQL Server driver for MDB2)
MDB2: Optional feature oci8 available (Oracle driver for MDB2)
MDB2: Optional feature pgsql available (PostgreSQL driver for MDB2)
MDB2: Optional feature querysim available (Querysim driver for MDB2)
MDB2: Optional feature sqlite available (SQLite2 driver for MDB2)
MDB2: To install optional features use "pear install pear/MDB2#featurename"

C:xamppphp>pear install Pager
downloading Pager-2.5.1.tgz ...
Starting to download Pager-2.5.1.tgz (36,596 bytes)
..........done: 36,596 bytes
install ok: channel://pear.php.net/Pager-2.5.1

C:xamppphp>pear install HTTP_Request2
downloading HTTP_Request2-2.3.0.tgz ...
Starting to download HTTP_Request2-2.3.0.tgz (119,717 bytes)
..........................done: 119,717 bytes
downloading Net_URL2-2.2.1.tgz ...
Starting to download Net_URL2-2.2.1.tgz (20,010 bytes)
...done: 20,010 bytes
install ok: channel://pear.php.net/Net_URL2-2.2.1
install ok: channel://pear.php.net/HTTP_Request2-2.3.0

C:xamppphp>pear install Mail_Queue
Unknown remote channel: pear.phpdb.org
WARNING: "pear/DB" is deprecated in favor of "pear/MDB2"
Unknown remote channel: pear.phpdb.org
WARNING: "pear/MDB" is deprecated in favor of "pear/MDB2"
Did not download optional dependencies: channel://pear.phpdb.org/creole, pear/DB, channel://pear.phpdb.org/jargon, pear/MDB, use --alldeps to download automatically
Did not download optional dependencies: pear/Net_SMTP, use --alldeps to download automatically
pear/Mail_Queue can optionally use package "channel://pear.phpdb.org/creole"
pear/Mail_Queue can optionally use package "pear/DB"
pear/Mail_Queue can optionally use package "channel://pear.phpdb.org/jargon"
pear/Mail_Queue can optionally use package "pear/MDB"
pear/Mail can optionally use package "pear/Net_SMTP" (version >= 1.4.1)
downloading Mail_Queue-1.2.7.tgz ...
Starting to download Mail_Queue-1.2.7.tgz (22,212 bytes)
........done: 22,212 bytes
downloading Mail-1.4.1.tgz ...
Starting to download Mail-1.4.1.tgz (21,756 bytes)
...done: 21,756 bytes
downloading Mail_Mime-1.10.2.tgz ...
Starting to download Mail_Mime-1.10.2.tgz (36,501 bytes)
...done: 36,501 bytes
install ok: channel://pear.php.net/Mail-1.4.1
install ok: channel://pear.php.net/Mail_Mime-1.10.2
install ok: channel://pear.php.net/Mail_Queue-1.2.7

C:xamppphp>pear list
INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET:
=========================================
PACKAGE          VERSION STATE
Archive_Tar      1.4.3   stable
Console_Getopt   1.4.1   stable
HTTP_Request2    2.3.0   stable
MDB2             2.4.1   stable
Mail             1.4.1   stable
Mail_Mime        1.10.2  stable
Mail_Queue       1.2.7   stable
Net_URL2         2.2.1   stable
PEAR             1.10.5  stable
Pager            2.5.1   stable
Structures_Graph 1.1.1   stable
XML_Util         1.4.2   stable

C:xamppphp>pear list-upgrades
PEAR.PHP.NET AVAILABLE UPGRADES (STABLE):
=========================================
CHANNEL      PACKAGE  LOCAL          REMOTE         SIZE
pear.php.net XML_Util 1.4.2 (stable) 1.4.3 (stable) 18.4kB