<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Magic Web &#187; php</title>
	<atom:link href="http://www.a-magic-web.com/contents/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.a-magic-web.com</link>
	<description></description>
	<lastBuildDate>Sat, 07 Aug 2010 05:57:45 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>CentOS5.4 に MySQL5.1,PHP5.3とphpMyAdmin</title>
		<link>http://www.a-magic-web.com/server_linux/mysql/mysql5-1_php5-3.html</link>
		<comments>http://www.a-magic-web.com/server_linux/mysql/mysql5-1_php5-3.html#comments</comments>
		<pubDate>Sat, 27 Feb 2010 16:33:54 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/?p=652</guid>
		<description><![CDATA[MySQL、PHP、phpMyAdminのインストールから、Wordpress用のデータベース作成まで。 最新版を入れるため、yumのリポジトリをインストールして変更する。依存関係を解消しながらインストールするより、yum を使った方がずっと楽。 インストール [root@localhost ~]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm [root@localhost ~]# wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm [root@localhost ~]# rpm -Uvh epel-release-5* remi-release-5* [root@localhost ~]# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm [root@localhost ~]# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm インストールする。 [root@localhost ~]# yum --enablerepo=remi,epel,rpmforge update php* mysql* [root@localhost ~]# yum --enablerepo=remi,epel,rpmforge install php php-gd php-mbstring php-mysql php-odbc php-pdo php-pear mysql-server mysql-bench phpMyadmin のインストール。 # yum --enablerepo=remi,epel,rpmforge install [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL、PHP、phpMyAdminのインストールから、Wordpress用のデータベース作成まで。</p>
<p>最新版を入れるため、yumのリポジトリをインストールして変更する。依存関係を解消しながらインストールするより、yum を使った方がずっと楽。</p>
<h3>インストール</h3>
<div class="command">
<pre>[root@localhost ~]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
[root@localhost ~]# wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm
[root@localhost ~]# rpm -Uvh epel-release-5* remi-release-5*

[root@localhost ~]# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[root@localhost ~]# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm</pre>
</div>
<p>インストールする。</p>
<div class="command">
<pre>[root@localhost ~]# yum --enablerepo=remi,epel,rpmforge update php* mysql*
[root@localhost ~]# yum --enablerepo=remi,epel,rpmforge install php php-gd php-mbstring php-mysql php-odbc php-pdo php-pear mysql-server mysql-bench</pre>
</div>
<p>phpMyadmin のインストール。</p>
<div class="command">
<pre># yum --enablerepo=remi,epel,rpmforge install phpMyAdmin</pre>
</div>
<h3>PHPの動作確認</h3>
<p>apacheの再起動</p>
<div class="command">
<pre>[root@localhost ~]# service httpd restart</pre>
</div>
<p>phpinfo を表示してみる。一緒にインストールしたモジュールの項目が表示されていることを確認。</p>
<div class="command">
<pre>[root@centos ~]# vi /var/www/html/test.php</pre>
</div>
<h3>MySQL 設定</h3>
<p>設定は文字コードのみ。</p>
<div class="command">
<pre>[root@centos ~]# vi /etc/my.cnf
[mysqld]
default-character-set = utf8
[mysql]
default-character-set = utf8</pre>
</div>
<p>起動、自動起動設定</p>
<div class="command">
<pre>[root@centos ~]# service mysqld start
[root@centos ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig --list mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off</pre>
</div>
<p>mysql の root にパスワードを設定する。OS自体のユーザーとは別もの。まずは、パスワードを設定するユーザーを確認。</p>
<div class="command">
<pre>[root@centos ~]# mysql -u root
mysql&gt; select user,host,password from mysql.user;
+-------------+-----------------------+-------------------------------------------+
| user        | host                  | password                                  |
+-------------+-----------------------+-------------------------------------------+
| root        | localhost             |                                           |
| root        | localhost.localdomain |                                           |
| root        | 127.0.0.1             |                                           |
|             | localhost             |                                           |
|             | localhost.localdomain |                                           |
+-------------+-----------------------+-------------------------------------------+</pre>
</div>
<p>root にパスワードを設定。</p>
<div class="command">
<pre>mysql&gt; set password for root@localhost=password('パスワード');
mysql&gt; set password for root@localhost.localdomain=password('パスワード');
mysql&gt; set password for root@127.0.0.1=password('パスワード');</pre>
</div>
<p>mysql のrootにパスワードが設定されたことを確認。</p>
<div class="command">
<pre>mysql&gt; select user,host,password from mysql.user;
+-------------+-----------------------+-------------------------------------------+
| user        | host                  | password                                  |
+-------------+-----------------------+-------------------------------------------+
| root        | localhost             | *0B6A2F2B175B57F40643A0377BE9274ACB964C44 |
| root        | localhost.localdomain | *0B6A2F2B175B57F40643A0377BE9274ACB964C44 |
| root        | 127.0.0.1             | *0B6A2F2B175B57F40643A0377BE9274ACB964C44 |
+-------------+-----------------------+-------------------------------------------+</pre>
</div>
<p>サンプルデータベース削除。</p>
<div class="command">
<pre>[root@centos ~]# mysql -u root -p
mysql&gt; show databases;
mysql&gt; drop database test;
mysql&gt; show databases;</pre>
</div>
<h3>wordpress 用のデータベース作成</h3>
<div class="command">
<pre>[root@centos ~]# mysql -u root -p
mysql&gt; create database wordpress;
mysql&gt; grant all privileges on wordpress.* to wordpress@localhost identified by 'パスワード';</pre>
</div>
<h3>phpMyAdmin を使う</h3>
<p>yum でインストールした phpMyadmin は以下にインストールされる。</p>
<blockquote><p>/usr/share/phpMyAdmin</p></blockquote>
<p>設定はデフォルトのままで使用可能。ただし、ドキュメントルート外にインストールされるので、そのままではアクセスできない。http://phpmyadmin.localhost.com/ でアクセスするため、bind  のレコード追加と、Virtual hostの設定をしてみた。</p>
<h4>Bind 設定</h4>
<div class="command">
<pre>[root@localhost ~]# cat /var/named/chroot/var/named/localhost.com.db
$TTL    86400
@       IN      SOA     localhost.com.  root.localhost.com.(
                                      2004031901 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN NS    localhost.com.
        IN MX 10 localhost.com.
@       IN A     192.168.0.250
<span style="color: #ff0000;">phpmyadmin      IN A    192.168.0.250</span>
*       IN A     192.168.0.250</pre>
</div>
<h4>Virtual host の設定</h4>
<div class="command">
<pre>NameVirtualHost *:80
&lt;VirtualHost *:80&gt;
    ServerAdmin root@localhost.com
    DocumentRoot /usr/share/phpMyAdmin/
    ServerName phpmyadmin.localhost.com
  &lt;Directory "/usr/share/phpMyAdmin"&gt;
    AllowOverride All
    Allow from All
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
</div>
<pre>参考記事</pre>
<pre><a href="http://a98.jugem.jp/?eid=371">CentOS 5.3 に php-5.2.9, mysql-5.1.35 をインストール</a></pre>
<pre><a href="http://a98.jugem.jp/?eid=371">データベースサーバー構築(MySQL)</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/server_linux/mysql/mysql5-1_php5-3.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>php.ini を書き変えずにエラーを表示させる</title>
		<link>http://www.a-magic-web.com/contents/php/php_ini_set.html</link>
		<comments>http://www.a-magic-web.com/contents/php/php_ini_set.html#comments</comments>
		<pubDate>Fri, 28 Aug 2009 04:42:40 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/contents/php/php_ini_set.html</guid>
		<description><![CDATA[ini_set(); 関数を使うことで、一時的に php.ini の設定値を変更することができます。一時的にエラーを出力させたい時などに役立ちそう。 &#60;?php ini_set(&#34;display_errors&#34;, 1); ?&#62;]]></description>
			<content:encoded><![CDATA[<p>ini_set(); 関数を使うことで、一時的に php.ini の設定値を変更することができます。一時的にエラーを出力させたい時などに役立ちそう。</p>
<pre class="brush: php;">&lt;?php
ini_set(&quot;display_errors&quot;, 1);
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/php_ini_set.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php で JSON を使う php-json</title>
		<link>http://www.a-magic-web.com/contents/php/php_php-json.html</link>
		<comments>http://www.a-magic-web.com/contents/php/php_php-json.html#comments</comments>
		<pubDate>Fri, 07 Aug 2009 03:30:34 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/?p=266</guid>
		<description><![CDATA[CentOS5.3、apache2.2.3、php5.1.6 の環境。php5.2.0 からは標準で組み込まれているため必要ない。今回は、php 5.2 未満の環境で、JSON を使えるようにするための php-json モジュールのインストール方法。 まず、モジュールのインストール [root@centos ~]# yum install php-devel [root@centos ~]# pecl install json 設定ファイルの設置・編集 [root@centos ~]# vi /etc/php.d/json.ini extension=json.so apache を再起動 [root@centos ~]# service httpd restart phpinfo();で json の項目があることを確認 phpでjsonを扱う 「php-jsonのインストール」 JSON on RHEL &#38; PHP 5.1.6 PHPでJSONしたい]]></description>
			<content:encoded><![CDATA[<p>CentOS5.3、apache2.2.3、php5.1.6 の環境。php5.2.0 からは標準で組み込まれているため必要ない。今回は、php 5.2 未満の環境で、JSON を使えるようにするための php-json モジュールのインストール方法。</p>
<p>まず、モジュールのインストール</p>
<div class="command">
<pre>[root@centos ~]# yum install php-devel
[root@centos ~]# pecl install json</pre>
</div>
<p>設定ファイルの設置・編集</p>
<div class="command">
<pre>[root@centos ~]# vi /etc/php.d/json.ini
extension=json.so</pre>
</div>
<p>apache を再起動</p>
<div class="command">
<pre>[root@centos ~]# service httpd restart</pre>
</div>
<p>phpinfo();で json の項目があることを確認</p>
<p><a href="http://www.a-magic-web.com/wp-content/uploads/2009/08/image.png"><img title="image" style="display: inline" height="87" alt="image" src="http://www.a-magic-web.com/wp-content/uploads/2009/08/image_thumb.png" width="609" /></a> </p>
<p><a href="http://logic.stepserver.jp/./data/archives/500.html">phpでjsonを扱う 「php-jsonのインストール」</a></p>
<p><a href="http://maisonbisson.com/blog/post/12137/json-rhel-centos-php-516/">JSON on RHEL &amp; PHP 5.1.6</a></p>
<p><a href="http://blog.miraclelinux.com/dora/2006/11/phpjson_7bd7.html">PHPでJSONしたい</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/php_php-json.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>if の処理指定部分の { } を省略して : (コロン) を使う</title>
		<link>http://www.a-magic-web.com/contents/php/php_if_coron.html</link>
		<comments>http://www.a-magic-web.com/contents/php/php_if_coron.html#comments</comments>
		<pubDate>Sun, 28 Jun 2009 03:24:14 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/contents/php/php_if_coron/</guid>
		<description><![CDATA[&#60;?php if (have_posts()) : ?&#62; &#60;?php while (have_posts()) : the_post(); ?&#62; WordPress の default テーマの index.php を読んでいて、気になったので調べてみました。以下によると、if 文の処理を記述する部分の { } の代わりに : (コロン) を使用できるようです。 if (条件式)の後にコロン(:)を付けてその後に処理を記述します。 elseif や elseの後にもコロンです。 離れPHP島 : No12.もしも・・・だったら&#160; &#8212;- if条件式 { } を使う場合と : を使う場合、以下の：ような動作の違いがあるようです。 注意: 上の例のように波括弧を使用する限り、 elseif と else if はまったく同じだと考えてよいことに注意しましょう。コロンを使って if/elseif 条件を指定する場合は、 else if のように分割してはいけません。 分割すると、パースエラーとなってしまいます。 PHP 日本語ドキュメント : [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: php">&lt;?php if (have_posts()) : ?&gt;
&lt;?php while (have_posts()) : the_post(); ?&gt;</pre>
<p>WordPress の default テーマの index.php を読んでいて、気になったので調べてみました。以下によると、if 文の処理を記述する部分の { } の代わりに : (コロン) を使用できるようです。 </p>
<blockquote>
<p>if (条件式)の後にコロン(:)を付けてその後に処理を記述します。<br />
    <br />elseif や elseの後にもコロンです。 </p>
<p><a href="http://masago.kir.jp/php20030330.php ">離れPHP島 : No12.もしも・・・だったら&#160; &#8212;- if条件式</a></p>
</blockquote>
<p>{ } を使う場合と : を使う場合、以下の：ような動作の違いがあるようです。 </p>
<blockquote>
<p>注意: 上の例のように波括弧を使用する限り、 elseif と else if はまったく同じだと考えてよいことに注意しましょう。コロンを使って if/elseif 条件を指定する場合は、 else if のように分割してはいけません。 分割すると、パースエラーとなってしまいます。 </p>
<p><a href="http://www.php.net/manual/ja/control-structures.elseif.php">PHP 日本語ドキュメント : elseif/else if</a></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/php_if_coron.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty の仕組み</title>
		<link>http://www.a-magic-web.com/contents/php/smarty/smarty_hello_world.html</link>
		<comments>http://www.a-magic-web.com/contents/php/smarty/smarty_hello_world.html#comments</comments>
		<pubDate>Wed, 03 Jun 2009 13:10:38 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/contents/php/smarty/smarty_hello_world/</guid>
		<description><![CDATA[非常に単純な Hello World の仕組みをまとめてみました。ブラウザからアクセスされる .php ファイルに Smarty が include(require) され、指定したテンプレートに変数の値が埋め込まれて表示される、一連の流れです。まとめずらく、若干見づらいですね。]]></description>
			<content:encoded><![CDATA[<p>非常に単純な Hello World の仕組みをまとめてみました。ブラウザからアクセスされる .php ファイルに Smarty が include(require) され、指定したテンプレートに変数の値が埋め込まれて表示される、一連の流れです。まとめずらく、若干見づらいですね。</p>
<p><a href="http://www.a-magic-web.com/wp-content/uploads/2009/06/image.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="565" alt="image" src="http://www.a-magic-web.com/wp-content/uploads/2009/06/image-thumb.png" width="600" border="0" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/smarty/smarty_hello_world.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty のインストール</title>
		<link>http://www.a-magic-web.com/contents/php/smarty/php_smarty_install.html</link>
		<comments>http://www.a-magic-web.com/contents/php/smarty/php_smarty_install.html#comments</comments>
		<pubDate>Sun, 31 May 2009 09:18:53 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[smarty]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/contents/php/smarty/php_smarty_install/</guid>
		<description><![CDATA[PHP の勉強を始めると、ひとつのファイルの中に html と php の記述がごっちゃり入って、わけがわからなくなってきます。もっとスマートにスマートにファイルを分けられないものかと思っていたら、あるんですね、テンプレートエンジンというものが。 調べると、楽天やサイボウズでも使われているようでおどろきです。 公式サイト・ドキュメントなど ダウンロードは Smarty : Download から、日本語のドキュメントは Smarty &#8211; コンパイリング PHP テンプレートエンジン で確認することができるようです。 検証環境 環境はいつものとおり。ほんとにやってみて、動いたというレベルなので参考にはしないでください。 CentOS 5.3 Apache2.2 php5.1.6 Smarty のインストール まずは、wget でダウンロードして解凍します。 [root@centos ~]# wget http://www.smarty.net/do_download.php?download_file=Smarty-2.6.25.tar.gz [root@centos ~]# tar xvzf Smarty-2.6.25.tar.gz 解凍してできたフォルダをリネームします。 [root@centos ~]# mv Smarty-2.6.25 Smarty Smarty 本体を格納するディレクトリを作成し、Smarty を移動します。 [root@centos ~]# mkdir /usr/local/lib/php [root@centos ~]# mv Smarty [...]]]></description>
			<content:encoded><![CDATA[<p>PHP の勉強を始めると、ひとつのファイルの中に html と php の記述がごっちゃり入って、わけがわからなくなってきます。もっとスマートにスマートにファイルを分けられないものかと思っていたら、あるんですね、テンプレートエンジンというものが。</p>
<p>調べると、楽天やサイボウズでも使われているようでおどろきです。</p>
<h3>公式サイト・ドキュメントなど</h3>
<p>ダウンロードは <a href="http://www.smarty.net/download.php">Smarty : Download</a> から、日本語のドキュメントは <a href="http://www.smarty.net/manual/ja/">Smarty &#8211; コンパイリング PHP テンプレートエンジン</a> で確認することができるようです。</p>
<h3>検証環境</h3>
<p>環境はいつものとおり。ほんとにやってみて、動いたというレベルなので参考にはしないでください。</p>
<ul>
<li>CentOS 5.3 </li>
<li>Apache2.2 </li>
<li>php5.1.6 </li>
</ul>
<h3>Smarty のインストール</h3>
<p>まずは、wget でダウンロードして解凍します。</p>
<div class="command">
<pre>[root@centos ~]# wget http://www.smarty.net/do_download.php?download_file=Smarty-2.6.25.tar.gz
[root@centos ~]# tar xvzf Smarty-2.6.25.tar.gz</pre>
</div>
<p>解凍してできたフォルダをリネームします。</p>
<div class="command">
<pre>[root@centos ~]# mv Smarty-2.6.25 Smarty</pre>
</div>
<p>Smarty 本体を格納するディレクトリを作成し、Smarty を移動します。</p>
<div class="command">
<pre>[root@centos ~]# mkdir /usr/local/lib/php
[root@centos ~]# mv Smarty /usr/local/lib/php/</pre>
</div>
<h3>Smarty 用のディレクトリの準備</h3>
<p>Smarty で使用するテンプレートや、コンパイルされた PHP ファイルが格納されるディレクトリを作成します。これらのディレクトリはサーバ単位ではなく、コンテンツ単位で必要になるようです。*1</p>
<div class="command">
<pre>[root@centos ~]# mkdir -p /var/www/html/smarty
[root@centos ~]# cd /var/www/html/smarty
[root@centos ~]# mkdir templates templates_c configs cache</pre>
</div>
<p>各フォルダやディレクトリに apache が書き込みや変更ができるようにパーミッションの変更を行います。</p>
<div class="command">
<pre>[root@centos ~]# chown -R apache:apache /var/www/html/smarty
[root@centos ~]# chmod 777 /var/www/html/smarty/templates_c
[root@centos ~]# chmod 777 /var/www/html/smarty/cache</pre>
</div>
<p>php.ini を編集します。以下の編集を行うと、Smarty のライブラリファイルを呼び出す際に、フルパスではなく「require_once &#8216;Smarty.class.php&#8217;;」だけ書けばよいので簡潔になります。フルパスで指定してもいいけどね。php.ini を編集したら、httpd の再起動をしておきます。</p>
<div class="command">
<pre>[root@centos ~]# vi /etc/php.ini
(色々省略)
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: &quot;/path1:/path2&quot;
;include_path = &quot;.:/php/includes&quot;
include_path = &quot;.:/usr/share/pear:/usr/local/lib/php/Smarty/libs&quot;
[root@centos ~]# service httpd restart</pre>
</div>
<h3>動作確認</h3>
<p>サンプルの php ファイルを用意します。</p>
<div class="command">
<pre>[root@centos ~]# vi /var/www/html/index.php
&lt;?php
require ('Smarty.class.php');

$smarty = new smarty();
$smarty-&gt;template_dir = '/var/www/html/smarty/templates';
$smarty-&gt;compile_dir = '/var/www/html/smarty/templates_c';
$smarty-&gt;cache_dir = '/var/www/html/smarty/cache';
$smarty-&gt;config_dir = '/var/www/html/smarty/configs';

$smarty-&gt;assign('name', '太郎');
$smarty-&gt;display('index.tpl');
?&gt;</pre>
</div>
<p>サンプルのテンプレートを用意します。</p>
<div class="command">
<pre>[root@centos ~]# vi /var/www/html/smarty/templates/index.tpl
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Smarty&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
Hello, {$name}!
&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p>ブラウザから、index.php にアクセスすると</p>
<p><a href="http://www.a-magic-web.com/wp-content/uploads/2009/05/ss000000.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ss000000" border="0" alt="ss000000" src="http://www.a-magic-web.com/wp-content/uploads/2009/05/ss000000-thumb.jpg" width="502" height="338" /></a> </p>
<p>とりあえず動いた。けど、まだよくわからないな?</p>
<hr />
</p>
<p>*1 <a href="http://www.atmarkit.co.jp/flinux/rensai/mysql5_11/mysql5_11a.html">@IT : Smartyでテンプレートエンジンの威力を知る</a> 「Smartyを動作させるには、PHPスクリプトとテンプレート以外に、4つのディレクトリ（tempalates／templates_c／configs／cache）を必要とします。これらのディレクトリはサーバ単位ではなく、コンテンツ単位で用意することが推奨されています。」</p>
<hr />
<p>参考にしたサイト</p>
<p><a href="http://www.atmarkit.co.jp/flinux/rensai/mysql5_11/mysql5_11a.html">@IT : Smartyでテンプレートエンジンの威力を知る</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/smarty/php_smarty_install.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP とセッションのまとめ</title>
		<link>http://www.a-magic-web.com/contents/php/php_session.html</link>
		<comments>http://www.a-magic-web.com/contents/php/php_session.html#comments</comments>
		<pubDate>Wed, 27 May 2009 06:46:37 +0000</pubDate>
		<dc:creator>vohedge</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.a-magic-web.com/contents/php/php_session/</guid>
		<description><![CDATA[PHP を勉強中です。さっそくセッションでつまっています。最終的に、ログイン認証を行って、ユーザー固有のページを表示することです。今回は、セッション動作に関してまとめてみました。 セッションとは 以下の説明が一番直観的でわかりやすかったです。 セッションとは、ページ間で変数の内容を維持するための仕組み。 http://www.phppro.jp/school/phpschool/vol8/1 セッションの仕組み ページ間で変数の内容を維持するためには、クライアントからのアクセスをサーバーが識別する必要があります。 PHP でのセッションの管理では、セッション ID をクッキーとしてクライアントに持たせ、2回目以降のアクセスの際、http ヘッダーに含まれるセッション ID で、サーバーに保存されたセッションと、そこに保存されたセッション変数を使える状態に復帰します。 サーバー側のセッションの保存場所 セッションの保存場所は、php.ini ファイルでの設定によって変わります。今回の環境（CenOS5.3, Apache2.2, PHP5.1.6）では以下の場所になっていました。 [root@localhost /]# cat /etc/php.ini （すごく省略） session.save_path = &#34;/var/lib/php/session&#34; セッションは、こんな感じで保存されます。 [root@localhost session]# ls -a . .. sess_h30n26sijgt513rlagqvuvh065 クライアント側のセッションの保存場所 クライアント側では、セッションはクッキーとして保存されます。また、クッキーの一般的な話として、有効期限をつけないと、クッキーはメモリ上に保存され、ブラウザの終了時に一緒に消去されるようです。有効期限を設定すると、ユーザープロファイル内の Cookie フォルダに保存されます。 やってみたこと とにかくセッションの仕組みと実際の動作を知りたかったので、実際にやってみました。やってみたのは、PHP BOOK : セッション変数の書き込みと読み込み に書かれている、アクセス回数をカウントするスクリプトです。 IE にインストールした ieHTTPHeaders で HTTP ヘッダーを監視しつつ、サーバー側のセッションファイルの状態と中身を確認してみました。 その結果がしたの絵。 &#160; やってみて、セッションID、セッション変数、クッキーの繋がりがわかってきました。次はこの仕組みを、どうやってログイン認証に利用していくかというところです。&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>PHP を勉強中です。さっそくセッションでつまっています。最終的に、ログイン認証を行って、ユーザー固有のページを表示することです。今回は、セッション動作に関してまとめてみました。 </p>
<h3>セッションとは</h3>
<p>以下の説明が一番直観的でわかりやすかったです。</p>
<blockquote><p>セッションとは、ページ間で変数の内容を維持するための仕組み。      <br /><a href="http://www.phppro.jp/school/phpschool/vol8/1">http://www.phppro.jp/school/phpschool/vol8/1</a> </p>
</blockquote>
<h3>セッションの仕組み</h3>
<p>ページ間で変数の内容を維持するためには、クライアントからのアクセスをサーバーが識別する必要があります。</p>
<p>PHP でのセッションの管理では、セッション ID をクッキーとしてクライアントに持たせ、2回目以降のアクセスの際、http ヘッダーに含まれるセッション ID で、サーバーに保存されたセッションと、そこに保存されたセッション変数を使える状態に復帰します。 </p>
<h3>サーバー側のセッションの保存場所</h3>
<p>セッションの保存場所は、php.ini ファイルでの設定によって変わります。今回の環境（CenOS5.3, Apache2.2, PHP5.1.6）では以下の場所になっていました。</p>
<div class="command">
<pre>[root@localhost /]# cat /etc/php.ini
（すごく省略）
session.save_path = &quot;/var/lib/php/session&quot; </pre>
</div>
<p>セッションは、こんな感じで保存されます。</p>
<div class="command">
<pre>[root@localhost session]# ls -a
. .. sess_h30n26sijgt513rlagqvuvh065 </pre>
</div>
<h3>クライアント側のセッションの保存場所</h3>
<p>クライアント側では、セッションはクッキーとして保存されます。また、クッキーの一般的な話として、有効期限をつけないと、クッキーはメモリ上に保存され、ブラウザの終了時に一緒に消去されるようです。有効期限を設定すると、ユーザープロファイル内の Cookie フォルダに保存されます。 </p>
<h3>やってみたこと</h3>
<p>とにかくセッションの仕組みと実際の動作を知りたかったので、実際にやってみました。やってみたのは、PHP BOOK : セッション変数の書き込みと読み込み</a> に書かれている、アクセス回数をカウントするスクリプトです。</p>
<p>IE にインストールした ieHTTPHeaders で HTTP ヘッダーを監視しつつ、サーバー側のセッションファイルの状態と中身を確認してみました。 その結果がしたの絵。</p>
<p><a href="http://www.a-magic-web.com/wp-content/uploads/2009/05/image1.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.a-magic-web.com/wp-content/uploads/2009/05/image-thumb1.png" width="622" height="696" /></a> </p>
<p><a href="http://www.a-magic-web.com/wp-content/uploads/2009/05/image2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.a-magic-web.com/wp-content/uploads/2009/05/image-thumb2.png" width="621" height="696" /></a>&#160;</p>
<p>やってみて、セッションID、セッション変数、クッキーの繋がりがわかってきました。次はこの仕組みを、どうやってログイン認証に利用していくかというところです。&#160; </p>
<hr />
<p>参考にしたサイト</p>
<p><a href="http://c-brains.jp/blog/wsg/08/05/22-193020.php">バシャログ : 10日で覚えるPHPのキソ 第 10 回 セッション（SESSION）</a> </p>
<p>→すごくわかりやすかったです。 </p>
<p><a href="http://www.phpbook.jp/tutorial/session/index.html PHP ">PHP BOOK : セッション管理</a> </p>
<p><a href="http://jp.php.net/manual/ja/ ">マニュアル</a> </p>
<p><a href="http://www.phppro.jp/school/phpschool/vol8/1">PHPプロ！Saity先生のPHP基礎講座 : 第8回 セッションの仕組みを知ろう (その1)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.a-magic-web.com/contents/php/php_session.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
