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

提供: FreeBSD入門
2014年8月12日 (火) 22:30時点におけるDaemon (トーク | 投稿記録)による版

移動: 案内検索
スポンサーリンク

FreeBSD 10.0-RELEASEPHP 5.5をインストールしました。

読み方

PHP 5.5
ぴーえいちぴー ごーてんご

概要

$ php -v
PHP 5.5.9 (cli) (built: Feb 13 2014 14:02:42)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
$ php-cgi -v
PHP 5.5.9 (cgi-fcgi) (built: Feb 13 2014 14:02:56)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

インストール

$ sudo pkg install php55 php55-extensions
Updating repository catalogue
The following 21 packages will be installed:
 
        Installing php55: 5.5.9
        Installing php55-session: 5.5.9
        Installing php55-opcache: 5.5.9
        Installing php55-xmlwriter: 5.5.9
        Installing php55-dom: 5.5.9
        Installing php55-xml: 5.5.9
        Installing php55-simplexml: 5.5.9
        Installing php55-ctype: 5.5.9
        Installing php55-posix: 5.5.9
        Installing php55-hash: 5.5.9
        Installing php55-filter: 5.5.9
        Installing php55-tokenizer: 5.5.9
        Installing php55-json: 5.5.9
        Installing sqlite3: 3.8.3.1
        Installing php55-pdo: 5.5.9
        Installing php55-iconv: 5.5.9
        Installing php55-phar: 5.5.9
        Installing php55-xmlreader: 5.5.9
        Installing php55-sqlite3: 5.5.9
        Installing php55-pdo_sqlite: 5.5.9
        Installing php55-extensions: 1.8
 
The installation will require 19 MB more space
 
3 MB to be downloaded

mbstring もないと困るので、もう少しいろいろインストールします。

$ sudo pkg install php55 php55-extensions php55-mbstring php55-gd
$ sudo portmaster -y -d /usr/ports/devel/pecl-intl

pecl-APC を入れようとしたらPHP 5.4を入れることになってしまうので、portsでビルドする必要があります。

設定

以下の設定ファイルが用意されています。

  • /usr/local/etc/php-fpm.conf
  • /usr/local/etc/php-fpm.conf.default
  • /usr/local/etc/php.conf
  • /usr/local/etc/php.ini-development
  • /usr/local/etc/php.ini-production
  • /usr/local/etc/php/extensions.ini

Apache 2.4 + PHP-FPM

ApacheとPHP FPM(FastCGI Process Manager)を使う場合は、Apacheに以下の設定を加えます。 /usr/local/etc/apache24/Includes/php-fpm.conf

<LocationMatch "^/.*\.php$">
      ProxyPass fcgi://127.0.0.1:9000/home/foo/public_html/
</LocationMatch>

httpd.conf で以下のモジュールを有効にします。

LoadModule proxy_module libexec/apache24/mod_proxy.so
LoadModule proxy_fcgi_module libexec/apache24/mod_proxy_fcgi.so

上記は、Apache 2.4の場合です。

php-fpmのコントロール

起動

sudo /usr/local/etc/rc.d/php-fpm start

停止

sudo /usr/local/etc/rc.d/php-fpm stop

再起動

sudo /usr/local/etc/rc.d/php-fpm restart

ステータス

sudo /usr/local/etc/rc.d/php-fpm status

コマンドの終了を待つ

sudo /usr/local/etc/rc.d/php-fpm poll

サービスが有効か確認する

サービスが有効な場合は、0、そうでなければ、1を返します。コマンドは、何も表示しません。

sudo /usr/local/etc/rc.d/php-fpm enabled

rc.confの設定を表示します

サービスの制御に使われるrc.conf変数を表示します。

sudo /usr/local/etc/rc.d/php-fpm rcvar

使い方

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

php

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

Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F]
  -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
  -h               This help
  -i               PHP information
  -m               Show compiled in modules
  -v               Version number
  -p, --prefix <dir>
                   Specify alternative prefix path to FastCGI process manager (default: /usr/local).
  -g, --pid <file>
                   Specify the PID file location.
  -y, --fpm-config <file>
                   Specify alternative path to FastCGI process manager config file.
  -t, --test       Test FPM configuration and exit
  -D, --daemonize  force to run in background, and ignore daemonize option from config file
  -F, --nodaemonize
                   force to stay in foreground, and ignore daemonize option from config file
  -R, --allow-to-run-as-root
                   Allow pool to run as root (disabled by default)

php-fpmのログファイルは、 /var/log/php-fpm.log です。

php55-openssl

pkgコマンドでインストールする場合

sudo pkg install php55-openssl

関連項目





スポンサーリンク