Apache 2.4でlibphp5.soを使用する方法

提供: FreeBSD入門
移動: 案内検索
スポンサーリンク

FreeBSD 10.0-RELEASEApache 2.4でApacheモジュール(Apache module)のlibphp5を使用する方法について説明します。

読み方

Apache モジュール
あぱっち もじゅーる
Apache module
あぱっち もじゅーる

概要

pkgコマンドでphp55をインストールした場合、libphp5.soがインストールされません。2014/03/09の時点では、ap22-mod_ 系のパッケージには、phpが存在しません。さらに、ap24-mod_は、シリーズそのものが存在しません。

そのような状況からpkgの恩恵を受けることができず、portsを使用して、自分でPHPをビルドするしかありません。

だと思っていたのですが、mod_php55, mod_php56 などの mod_php* 系のパッケージをインストールすれば、利用できます。

pkgでインストール

PHP 5.6

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

sudo pkg install mod_php56

PHP 5.5

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

sudo pkg install mod_php55

セルフビルドでインストール

make config で Build Apache module を有効にしてください。

cd /usr/ports/lang/php55
sudo make config
sudo make install clean
$ sudo make install
===>  Installing for php55-5.5.9
===>   php55-5.5.9 depends on file: /usr/local/sbin/apxs - found
===>   php55-5.5.9 depends on shared library: libpcre.so - found
===>   php55-5.5.9 depends on shared library: libxml2.so - found
===>  Checking if lang/php55 already installed
===>   Registering installation for php55-5.5.9
[activating module `php5' in /usr/local/etc/apache24/httpd.conf]
Installing php55-5.5.9... done
***************************************************************
 
Make sure index.php is part of your DirectoryIndex.
 
You should add the following to your Apache configuration file:
 
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
 
***************************************************************
 
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/apache24/libphp5.so
/usr/local/bin/php
/usr/local/bin/php-cgi
/usr/local/sbin/php-fpm
 
      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/php-fpm
 
      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.
 
      For more information, and contact details about the security
      status of this software, see the following webpage:
http://www.php.net/

設定

httpd.conf は、自動的に以下の設定が追加されます。

LoadModule php5_module        libexec/apache24/libphp5.so
AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps

DirectoryIndexに index.phpを追加したほうがよいでしょう。

DirectoryIndex index.php

使い方

Apacheapachectlで再起動します。

sudo apachectl restart

もしくはserviceコマンドで再起動します。

sudo service apache24 restart
# or
sudo service apache24 onerestart

関連項目





スポンサーリンク