PHP5.6をインストールする

提供: FreeBSD入門
2014年9月20日 (土) 13:04時点におけるDaemon (トーク | 投稿記録)による版

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索
スポンサーリンク

FreeBSD に PHP 5.6 に Apache 用の libphp5.so と php コマンドをインストールします。phpdbgを利用する場合には、portsでビルドします。

概要

Apache 用もlibphp5.so は、 mod_php56をインストールします。

インストール

$ sudo pkg install php56 php56-extensions mod_php56

PHP 5.6 のビルドオプション

phpdbg は、オフになっています。

$ pkg info -f php56
php56-5.6.0
Name           : php56
Version        : 5.6.0
Installed on   : Tue Sep 16 23:17:12 JST 2014
Origin         : lang/php56
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : www lang devel
Licenses       : PHP301
Maintainer     : ale@FreeBSD.org
WWW            : http://www.php.net/
Comment        : PHP Scripting Language
Options        :
        CGI            : on
        CLI            : on
        DEBUG          : off
        DTRACE         : off
        EMBED          : off
        FPM            : on
        FPM_IPV6       : off
        IPV6           : on
        LINKTHR        : on
        MAILHEAD       : off
        PHPDBG         : off
        ZTS            : off
Shared Libs required:
        libxml2.so.2
        libpcre.so.3
Annotations    :
        cpe            : cpe:2.3:a:php:php:5.6.0:::::freebsd10:x64
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 14.9MiB
Description    :
PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open
Source general-purpose scripting language that is especially suited for
Web development and can be embedded into HTML.  Its syntax draws upon C,
Java, and Perl, and is easy to learn.  The main goal of the language is to
allow web developers to write dynamically generated webpages quickly, but
you can do much more with PHP.
 
WWW: http://www.php.net/

PHP 5.5 から PHP 5.6 へアップグレードする方法

PHP 5.6 と PHP 5.5 は、別パッケージですので、PHP 5.5 が入ってる環境であれば、以下の方法でインストールします。 一度、php55系のパッケージを削除します。

$ pkg info | fgrep php55 >/tmp/php.txt
$ sudo pkg remove '*php55*'
$ sudo pkg install `sed -e 's/-5.5.*$//' -e 's/php55/php56/' \
-e 's/extensions.*/extensions/' /tmp/php.txt `

sqlite3 でエラーがおきる場合

sqlite3.so が libsqlite3.so.0 がありません、とエラーが出ている場合は、sqlite3 のパッケージをアップデートします。

$ php
PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20131226/sqlite3.so' - Shared object "libsqlite3.so.0" not
found, required by "sqlite3.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20131226/pdo_sqlite.so' - Shared object "libsqlite3.so.0"
not found, required by "pdo_sqlite.so" in Unknown on line 0

このようにアップデートします。

$ sudo pkg install sqlite3
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 1 packages will be affected (of 0 checked):
 
Installed packages to be UPGRADED:
        sqlite3: 3.8.4.2 -> 3.8.6
 
The process will require 59 KB more space.
664 KB to be downloaded.
 
Proceed with this action? [y/N]: y
Fetching sqlite3-3.8.6.txz: 100%  664 KB 136.0k/s    00:05
Checking integrity... done (0 conflicting)
[1/1] Upgrading sqlite3 from 3.8.4.2 to 3.8.6: 100%

pear のアップデート

pear 系のパッケージをアップデートする場合は、このような形でアップデートできます。

$ sudo pkg install `pkg info '*pear*' | perl -ne 's/-[\d].*$//;print;'`

設定

PHP

/usr/local/etc/php.ini-development
/usr/local/etc/php.ini-production

Apache

LoadModule php5_module        libexec/apache24/libphp5.so

使い方

バージョン

$ php -v
PHP 5.6.0 (cli) (built: Sep 10 2014 06:12:49)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

コマンドラインオプション

Usage: php [options] [-f] <file> [--] [args...]
   php [options] -r <code> [--] [args...]
   php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
   php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
   php [options] -S <addr>:<port> [-t docroot]
   php [options] -- [args...]
   php [options] -a
 
  -a               Run interactively
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  -e               Generate extended information for debugger/profiler
  -f <file>        Parse and execute <file>.
  -h               This help
  -i               PHP information
  -l               Syntax check only (lint)
  -m               Show compiled in modules
  -r <code>        Run PHP <code> without using script tags <?..?>
  -B <begin_code>  Run PHP <begin_code> before processing input lines
  -R <code>        Run PHP <code> for every input line
  -F <file>        Parse and execute <file> for every input line
  -E <end_code>    Run PHP <end_code> after processing all input lines
  -H               Hide any passed arguments from external tools.
  -S <addr>:<port> Run with built-in web server.
  -t <docroot>     Specify document root <docroot> for built-in web server.
  -s               Output HTML syntax highlighted source.
  -v               Version number
  -w               Output source with stripped comments and whitespace.
  -z <file>        Load Zend extension <file>.
 
  args...          Arguments passed to script. Use -- args when first argument
                   starts with - or script is read from stdin
 
  --ini            Show configuration file names
 
  --rf <name>      Show information about function <name>.
  --rc <name>      Show information about class <name>.
  --re <name>      Show information about extension <name>.
  --rz <name>      Show information about Zend extension <name>.
  --ri <name>      Show configuration for extension <name>.

PHPサーバ

PHPサーバを起動する方法です。

$ php -S 0 0.0.0:8080

phpdbg が使いたい場合

pkpdbgが使用したい場合には、php56 を自分でビルドする必要があります。

make config で PHPDBG にチェックを入れて、ビルドします。

$ cd /usr/ports/lang/php56
$ sudo make config
$ sudo make install clean

関連項目




スポンサーリンク