ラベル Apache の投稿を表示しています。 すべての投稿を表示
ラベル Apache の投稿を表示しています。 すべての投稿を表示

2012年7月10日火曜日

SELinux ラベルの変更

httpd で公開フォルダを追加した時についつい忘れて手間取ってしまうのが、SELinuxのラベルの貼り替えです。

SELinuxで運用しているとフォルダや作成した時には、作成先に見合うラベルを設定する必要があります。
通常は、restorecon -R コマンドで親フォルダの情報が引き継がれると思っていたのですが、単純に引き継がれる訳でないようです。(詳細は未確認(未調査)です。)
よって、作成したフォルダに正しいラベルを設定するという事が必要になります。

# chcon system_u:object_r:httpd_sys_content_t /home/www -R
# chcon system_u:object_r:httpd_sys_script_exec_t /home/www/cgi-bin -R

2012年6月25日月曜日

CakePHP 複数アプリの実行

CakePHP で複数アプリを実行する。

1. virtual host を設定して複数アプリを別々ホスト名で起動する。

2. .htaccess を修正する。(忘れがちなので注意)
[root@hoge sample]# cat .htaccess

   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

[root@hoge sample]# 
 
  ↓↓↓


   RewriteEngine on
   RewriteRule    ^$ webroot/    [L]
   RewriteRule    (.*) webroot/$1 [L]

サブディレクトリにcakePHPを構築する
もしサブドメインに構築する場合には、.htaccessの設定に追記が必要となる。
具体的には、RewriteBaseをきちんと設定にあるような

app/webroot/.htaccess にあるmod_rewriteの設定において RewriteBase /(サブディレクトリ名)を追加する必要がある。

もし、追加し忘れると、500 Internal Server Errorが表示され、Apacheのログには、

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

というメッセージが記録される。

今までDocumentRoot上にしか構築したことがなかったので、少しハマってしまった。

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!)

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月19日火曜日

バーチャルホストの設定

http.confを編集してバーチャルホストの設定ファイル(httpd-vhosts.conf)を読み込むように設定する。

httpd-vhosts.conf
# Virtual hosts
Include conf.d/httpd-vhosts.conf
※redhat系でない場合は、/etc/httpd/extra/httpd-vhosts.confに書くようだ。
httpd-vhosts.conf
# www.hogehoge.org
<VirtualHost *:80>
    DocumentRoot /var/www/vhosts/hogehoge
    ServerName www.hogehoge.org
    ServerAlias hogehoge.org
    ErrorLog logs/hogehoge.org-error_log
    CustomLog logs/hogehoge.org-access_log combined
</VirtualHost>
http://www.hogehoge.org にアクセスしたときに /var/www/vhosts/hogehoge/ ディレクトリのファイルを表示する。エイリアスとして www なしの http://hogehoge.org/ でも同じ設定を使うようになっています。また、ログも分けて出力する。

バーチャルホストが多数ある場合

バーチャルホストの設定が多数あるときは、それぞれのサイト毎にファイルを分けた方が管理し易いと思います。その場合は、下記のように設定すると良いかも。

httpd-vhosts.conf
# Virtual hosts
Include conf.d/vhosts/*.conf
上記のように、conf.d/vhosts/*.conf を読み込むように設定しドメイン事に hogehoge.org.conf や hogehoge2.org.conf などのファイルを作っていきます。
hogehoge.org.conf
# www.hogehoge2.org
<VirtualHost *:80>
    DocumentRoot /var/www/vhosts/hogehoge2
    ServerName hogehoge2.net
    ServerAlias www.hogehoge2.net
    AddDefaultCharset euc-jp
    <Directory "/var/www/vhosts/hogehoge2">
      Options Includes ExecCGI FollowSymLinks MultiViews
      php_value mbstring.language Japanese
      php_value mbstring.internal_encoding EUC-JP
      php_value mbstring.http_input auto
      php_value mbstring.http_output EUC-JP
    </Directory>
</VirtualHost>
上記は、www.hogehoge2.org をEUC-JPで稼動させ,PHPの内部コード(internal_encoding)と出力(http_output)もEUC-JPに設定している。

しかし、再インストールは面倒ですなぁ〜 (/_;)
※ディスクが故障し交換のため、すべて再インストールになった哀れな者