LAMP環境

CentOS5.2 (64bit) にて、お手軽にLAMP環境を作ります。

動作検証のために、 MovableType 4.21 を入れてみます。

インストールの指針

それぞれ必要そうなパッケージを探し、要るものをインストールします。

Apache

#pre{{ [root@localhost ~]# yum search httpd Loading "fastestmirror" plugin Loading mirror speeds from cached hostfile

* base: ftp.oss.eznetsols.org
* updates: ftp.oss.eznetsols.org
* addons: ftp.oss.eznetsols.org
* extras: ftp.oss.eznetsols.org

httpd-devel.i386 : Development tools for the Apache HTTP server. httpd-devel.x86_64 : Development tools for the Apache HTTP server. httpd-manual.x86_64 : Documentation for the Apache HTTP server. httpd.x86_64 : Apache HTTP Server mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP server system-config-httpd.noarch : Apache configuration tool mod_dav_svn.x86_64 : Apache server module for Subversion server. httpd.x86_64 : Apache HTTP Server }}

インストールします。

#pre{{ [root@localhost ~]# yum install httpd httpd-manual mod_ssl ...

Transaction Summary ============================================================================= Install 3 Package(s) Update 0 Package(s) Remove 0 Package(s)

Total download size: 2.0 M Is this ok [y/N]: y Downloading Packages: (1/3): httpd-manual-2.2.3 100% |=========================| 832 kB 00:02 (2/3): mod_ssl-2.2.3-11.e 100% |=========================| 85 kB 00:00 (3/3): httpd-2.2.3-11.el5 100% |=========================| 1.1 MB 00:02 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction

 Installing: httpd                        ######################### [1/3] 
 Installing: mod_ssl                      ######################### [2/3] 
 Installing: httpd-manual                 ######################### [3/3] 

Installed: httpd-manual.x86_64 0:2.2.3-11.el5_1.centos.3 mod_ssl.x86_64 1:2.2.3-11.el5_1.centos.3 Dependency Installed: httpd.x86_64 0:2.2.3-11.el5_1.centos.3 Complete! }}

MySQL

同じように探します。

#pre{{ [root@localhost ~]# yum search mysql ... }}

必要なものをインストールします。 他のモジュールとの連携をすることも考慮して選択しましょう。

#pre{{ [root@localhost ~]# yum install mysql mysql-server perl-DBD-MySQL php-mysql MySQL-python ... }}

Perl/PHP/Python

これも同様です。

Perl や Python はインストールされているままで使い、 さらに追加で次のパッケージをインストールしました。

#pre{{ [root@localhost ~]# yum install php php-mbstring ... }}

動作確認

それぞれ起動してみます。

MySQL

設定ファイルは /etc/my.cnf にあります。 内容を一応確認してから、起動スクリプトを実行してみます。

#pre{{ [root@localhost ~]# cat /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql

# Default to using old password format for compatibility with mysql 3.x

# clients (those using the mysqlclient10 compatibility package). old_passwords=1

[mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid }}

#pre{{ [root@localhost ~]# /etc/init.d/mysqld start MySQL データベースを初期化中: Installing MySQL system tables... OK Filling help tables... OK

To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com

                                                          [  OK  ]

MySQL を起動中: [ OK ] }}

起動したということで、動作確認してみます。 ここにも書いてありますが、ちゃんと使うにはパスワードを設定してからにしましょう。

#pre{{ [root@localhost ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;

  1. --------------------+
    Database
  2. --------------------+ | information_schema | | mysql | | test |
  3. --------------------+ 3 rows in set (0.00 sec)

mysql> \q Bye }}

Apache + PHP

PHP の設定ファイルは /etc/php.ini です。 日本語のため、mbstring 周りを設定します。 下記の行について先頭の ";" を外して有効化しました。

#pre{{ [mbstring] mbstring.language = Japanese mbstring.internal_encoding = EUC-JP mbstring.http_input = auto mbstring.http_output = SJIS mbstring.encoding_translation = Off mbstring.detect_order = auto mbstring.substitute_character = none; mbstring.func_overload = 0 mbstring.strict_encoding = Off }}

Apache httpd から読まれるのは /etc/httpd/conf.d/php.conf ですが、 これは特に変更の必要はありません。

httpd を起動します。

#pre{{ [root@localhost ~]# /etc/init.d/httpd start httpd を起動中: [ OK ] }}

正しく起動したら、ブラウザからアクセスしてみます。

httpd.png

PHP についても確認してみましょう。 確認用に phpinfo.php を1行書きます。

#pre{{ [root@localhost ~]# cat /var/www/html/phpinfo.php

? phpinfo(); ?> }}

同様にブラウザからアクセスします。 http://(IPアドレス)/phpinfo.php です。

php.png

設定された環境が表示されるので、一通り確認します。 mbstring の日本語周りや、MySQL のドライバなどを見ましょう。

確認できたらこの phpinfo.php は消しておきます。

MovableType 4.21

まずインストール先として、 httpd で /cgi-bin/ として設定されているディレクトリを探します。

#pre{{ [root@localhost ~]# grep ^ScriptAlias /etc/httpd/conf/httpd.conf ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" }}

ダウンロードしてきたMTを展開し、cgi-bin/mt として設置します。

#pre{{ [root@localhost ~]# unzip MT-4_21-ja.zip ... [root@localhost ~]# mv MT-4.21-ja /var/www/cgi-bin/mt [root@localhost ~]# chmod 755 /var/www/cgi-bin/mt }}

/etc/httpd/conf.d/mt.conf を編集して、 CGI として動かすための設定をします。 このディレクトリに置けば httpd の起動時に httpd.conf から読み込まれます。

#pre{{ [root@localhost ~]# cat /etc/httpd/conf.d/mt.conf AddHandler cgi-script .cgi Alias /cgi-bin/mt/ "/var/www/cgi-bin/mt/"

Directory "/var/www/cgi-bin/mt">

   AllowOverride None
   Options ExecCGI
   Order allow,deny
   Allow from all

/Directory> }}

httpd を再起動して、ブラウザから http://(IPアドレス)/cgi-bin/mt/ にアクセスします。

#pre{{ [root@localhost ~]# /etc/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ] }}

mt-1.png

しばらく経つと画面が切り替わります。

mt-2.png

ウィザードを進めていくと、MySQL のデータベースを用意する必要があることがわかります。 MT用のデータベースと、接続用のユーザを作成します。

#pre{{ [root@localhost ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE mt CHARACTER SET ujis; Query OK, 1 row affected (0.00 sec)

mysql> GRANT all ON mt.* TO mtuser IDENTIFIED BY 'mtuser'; Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)

mysql> exit Bye }}

として作成しました。接続できることを確認します。

#pre{{ [root@localhost ~]# mysql -h localhost -u mtuser -p -D mt Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 7 Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> }}

この情報を元に、MT に設定を入力します。

mt-3.png

設定が終わったら mt-config.cgi が生成されるので、 /var/www/cgi-bin/mt/mt-config.cgi として書き込み、 実行権限をつけます。

#pre{{ [root@localhost ~]# vi /var/www/cgi-bin/mt/mt-config.cgi ... [root@localhost ~]# chmod +x /var/www/cgi-bin/mt/mt-config.cgi }}

ブログを作成する設定に進んだら、必要なディレクトリを作ります。

#pre{{ [root@localhost ~]# mkdir -p /var/www/html/my_first_blog [root@localhost ~]# chown apache:apache /var/www/html/my_first_blog }}

その後データベースなどの設定が進み、ちゃんと終了すれば MovableType が使えるようになりました。

このように記事を書いていくことができます。

mt-4.png

正しく運用するには画像表示のためのディレクトリへの設定など、 他にも httpd で必要なものもあります。 /etc/httpd/conf.d/mt.conf で設定していきましょう。



添付ファイル: filemt-2.png 440件 [詳細] filemt-1.png 446件 [詳細] filemt-4.png 447件 [詳細] filemt-3.png 439件 [詳細] filephp.png 536件 [詳細] filehttpd.png 543件 [詳細]

トップ   差分 履歴 リロード   一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-01-29 (土) 15:27:48