PHP
Webアプリケーションの開発言語であるPHPを導入する。
PHPを導入することで動的なページの生成やSQLサーバとの連携などWebベースの仕組みの幅が広がることが期待される。
PHPをインストールするためには以下のソフトウェアが必要になる。
事前にRPMでインストールしておく。
・bison
・flex
・libxml2
・libxml2-devel
$ wget http://jp2.php.net/get/php-5.1.4.tar.bz2/from/jp.php.net/mirror $ tar xvjf php-5.1.4.tar.bz2 $ cd php-5.1.4 $ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-zlib --with-gd --enable-mbstring --enable-mbregex --disable-ipv6 $ make # make installPHPの設定ファイルであるphp.iniをソースより流用する。
# cp $SOURCE/php.ini-dist /usr/local/lib/php.iniApacheの設定を変更しPHPスクリプトが実行されるようにする。
/usr/local/apache2/conf/httpd.conf
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module modules/libphp5.so
<IfModule mime_module>
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
</IfModule>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
設定変更を反映させる。
# /sbin/service httpd configtest Syntax OK # /sbin/service httpd restart httpdを停止中: [ OK ] httpdを起動中: [ OK ]以下の内容のPHPスクリプトを作成しブラウザでアクセスする。
/usr/local/apache2/htdocs/info.php
<?php
phpinfo();
?>
HTTP/1.x 200 OK
Date: Thu, 12 Oct 2006 23:47:13 GMT
Server: Apache
X-Powered-By: PHP/5.1.6
Content-Type: text/html
さらに特定のURLにアクセスすることでPHPの情報を取得することも可能。
http://www.kajukaju.net/index.php?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000
/usr/local/lib/php.ini
;Apacheを再起動して完了。
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
expose_php = Off
# /sbin/service httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ]
