2011年7月26日火曜日

VirtualHostの設定ミス

httpd.conf を変更(書き直し)していたら、apache の起動時に下記のエラーが発生。(オヨヨ)

[root@hogehoge ~]# service httpd restart
httpd を停止中:                                            [  OK  ]
httpd を起動中: [Tue Jul xx hh:mm:ss YYYY] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
 
httpd.conf に設定ミス(漏れ)があった。
NameVirtualHost *:80
設定を追加(コメントを解除)して完了!(OK!)

CAKEPHP でそのまま実行すると下記のようにエラーになる。(いつも事だな。)

Release Notes for CakePHP 1.3.10.
Read the changelog

Notice (1024): Please change the value of 'Security.salt' in app/config/core.php to a salt value specific to your application [CORE/cake/libs/debugger.php, line 684]

Warning: touch() [http://php.net/function.touch]: Utime failed: Permission denied in /var/www/cakephp-1.3.10/cake/libs/file.php on line 125

Notice (1024): Please change the value of 'Security.cipherSeed' in app/config/core.php to a numeric (digits only) seed value specific to your application [CORE/cake/libs/debugger.php, line 688]

URL rewriting is not properly configured on your server.

    Help me configure it
    I don't / can't use URL rewriting

Your tmp directory is writable.

The FileEngine is being used for caching. To change the config edit APP/config/core.php

Your database configuration file is NOT present.
Rename config/database.php.default to config/database.php
saltの変更を促す警告
Notice (1024): Please change the value of 'Security.salt' in app/config/core.php to a salt value specific to your application [CORE/cake/libs/debugger.php, line 684]
(変更箇所)
/**
 * A random string used in security hashing methods.
 */
 Configure::write('Security.salt', '****************************************');
Security.saltに設定する値は、mkpasswd で作成するのが便利。
mkpasswd -l 40
※mkpasswd は、ecpectパッケージに含まれています。


cipherSeed 値の変更を促される。
セキュリティ強化のため、今回の cakephp-1.3.10 あたりで追加されたらしい。
Notice (1024): Please change the value of 'Security.cipherSeed' in app/config/core.php to a numeric (digits only) seed value specific to your application [CORE/cake/libs/debugger.php, line 688]
(変更箇所)
/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
 Configure::write('Security.cipherSeed', '******************************');

Security.cipherSeedに設定する値も mkpasswd で作成するのが便利。
mkpasswd -l 30 -c 0 -d 30 -C 0 -s 0


mod_rewiteの設定に問題あり?
URL rewriting is not properly configured on your server.
バーチャルホストの設定で、下記のディレクティブを設定。
    
        Options FollowSymLinks
        AllowOverride All
    
ようやく無事に初期画面が表示されたぜ。
※データベースの設定はまだだけどね。

PHP5.3 タイムゾーン エラー?

ディスクがクラッシュして再インストールしているが、CAKEPHP(1.3.10)を実行しようとすると下記のエラーが発生。

Warning (2): strtotime() [http://php.net/function.strtotime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Tokyo' for 'JST/9.0/no DST' instead [CORE/cake/libs/cache.php, line 597]

Notice: Trying to get property of non-object in /var/www/html/cakephp/cake/libs/cache/file.php on line 248 Fatal error: Call to a member function cd() on a non-object in /var/www/html/cakephp/cake/libs/cache/file.php on line 248 
今回は PHP5.3 をインストールしてしたが、PHPの設定タイムゾーンの設定が必要なようだ。(いつの間に r(?_?);)
変更前 PHP.ini
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
;date.timezone =
変更後 PHP.ini
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Tokyo

2011年7月23日土曜日

SELinux でつまずく

ファイルおよびフォルダに設定されいるタイプの詳細を確認しようと考え、seedit-gui をインストールして seed-init を実行する。しかし、これがいけなかったようだ。seed-init 実行後に再起動をしたら起動できなかった。

とりあえず、boot時にselinuxを無効にして起動をさせた。

boot時に selinuxを無効にする。
起動時に F2 を押し boot オプションを選択する。

title Turbolinux
kernel (hd0,0)/boot/vmlinuz root=0802 selinux=0
initrd (hd0,0)/boot/initrd

Gnomeがハング?

Gnomeテキスト・エディタでテキストファイルを開こうしたら、ファイルは開いたが「既に開かれているので修正できない」主旨のメッセージが表示された(強制修正は可能)。

画面を見る限り別ウィンドぅでも開いていないので、とりあえずろ「ログオフ」してから再ログインしようとしたらログオフされない。

しばし待機したがログオフされないので、シャットダウンでもするかと思ったがキーがきかなかった。
マウスは動くが、何も選択できない。

何か対策はと思い、X Window を終了させれば良いのだと考え、下記を実施した。

[Ctrl]+[Alt]+[BS]

上記でX サーバーが終了する。特に重要なプロセスも動かしていないので、実行し、ログイン画面に復帰。

ディスク故障で痛い目にあっているので、リセットボタンや電源ボタンによる不用意な再起動は避けねば...

2011年7月20日水曜日

Mysqlの設定

Mysqlの uid gid を何番にしたらよいか...
とりあえず、登録されているユーザーを uid 順に並べて確認する。

[root@ora02 ~]# awk -F":" '{print $3 " " $1}' /etc/passwd | sort -n
0 root
1 bin
2 daemon
Apacheはシステム用の予約済(固定) UID/GID 一覧にあるが、MySQLはなかった。

Yumからインストールすると uid gid ともに 27 であった。

MySQL5.5をインストール

CENTOS(5.6)の通常のリポジトリからだとMySQL5.0になっていまいます。CENTOEはすべてにおいてバージョンがかなり遅れているので、できるだけ最新版を使うには最新版をソースから新ストールするかパッケージにされたリポジトリを探し出します。(実際、いろいろな方がパッケージにしてくれている)

今回は、remi-testリポジトリからインストールします。

コマンドから yum でインストールするか GUI(Yum Extender)からインストールを行います。
以前は、いつもコマンドからyumで行っていましたが、UI(Yum Extender)を知ってからはほとんどGUIで対応しています。 GUIのほうが、多数のリポジトリを指定し特定のリポジトリのものを指定してインストールできるから大変便利です。

データベースの格納先を変更する

yumでインストールとすると、ユーザー:mysql のホームディレクトリが /var/lib/mysql に設定されます。
データベースの格納先を別の場所にしたいので、mysql のホームディレクトリを変更し、my.cnf でデータベースの格納先も合わせて変更することにします。

mysqlのホームディレクトリの変更先のディレクトリを作成。
mkdir /opt/mysql

ディレクトリのユーザ:グループの設定
chown mysql:mysql /opt/mysql
※アクセス権は 755

セキュリティコンテキストの設定
chcon system_u:object_r:mysqld_db_t /opt/mysql
   ↓下記に変更
chcon -R --reference=/var/lib/mysql /opt/mysql