proftpd の設定
net-ftp/proftpd-1.3.3c を新規インストールして、
# cd /etc/proftpd # cp proftpd.conf.sample proftpd.conf
として、proftpd.conf を編集するわけだが・・
# This is a sample ProFTPD configuration file for Gentoo Linux (rename # it to 'proftpd.conf' for actual use). It establishes a single server # and a single anonymous login. ServerName "ProFTPD Default Server" ServerType standalone DefaultServer on RequireValidShell off AuthPAM off AuthPAMConfig ftp # Listen on the standard FTP port 21. Port 21 # New directories and files should not be group or world writable. Umask 022 # To prevent DoS attacks set the maximum number of child processes # to 30. If you need to allow more than 30 concurrent connections # at once simply increase this value. MaxInstances 30 # The server will run under ftp/ftp. User ftp Group ftp (後略)
たしか以前は、
# The server will run under ftp/ftp. User proftpd Group proftpd
となっていて、USER=GROUP=proftpd はインストール時に作成されるので、パスワードだけ設定すればよかったはず。
チェックしてみると USER=GROUP=ftp も既に作られているので同様にパスワードを設定しただけで、クライアントからユーザー名:ftp で接続を試みたところ、
Response: 530-Unable to set anonymous privileges. Response: 530 Login incorrect.
というメッセージが出て拒否される。
いろいろ設定を変えてみたが効果なし。
そこで、/etc/proftpd/proftpd.conf に、
# The server will run under ftp/ftp. User proftpd Group proftpd
と設定後、新たに proftpd グループと proftpd ユーザーを作り、このアカウントで接続したらOKだった。
しかし、もうちょっとスマートな解決法があるんだろうと思う。
redmine-1.0.5 インストール覚書
VirtualBox で仮想サーバーを作って、redmine を入れたときの覚書。
事前にインストールしたのは、apache2、mysql で、ruby や rails は未インストールという条件である。
最初に autounmask で redmine と関連パッケージのマスクを外した。
# autounmask =www-apps/redmine-1.0.5
生成された /etc/portage/package.keywords は以下の通り。
# --- # BEGIN: www-apps/redmine-1.0.5 # --- =www-apps/redmine-1.0.5 ~x86 =dev-ruby/coderay-0.9.6 ~x86 =dev-ruby/coderay-0.9.5 ~x86 =dev-ruby/rails-2.3.5-r3 ~x86 =dev-ruby/rails-2.3.5-r2 ~x86 =dev-ruby/i18n-0.4.2 ~x86 =dev-ruby/ruby-net-ldap-0.0.4-r1 ~x86 =dev-ruby/actionpack-3.0.3 ** =dev-ruby/actionpack-2.3.10 ~x86 =dev-ruby/actionpack-2.3.8-r1 ~x86 =dev-ruby/actionpack-2.3.8 ~x86 =dev-ruby/actionpack-2.3.5-r1 ~x86 =dev-ruby/activeresource-2.3.5-r1 ~x86 =dev-ruby/activesupport-2.3.5-r4 ** =dev-ruby/activesupport-2.3.5-r1 ~x86 =dev-ruby/actionmailer-2.3.5-r1 ~x86 =dev-ruby/activerecord-2.3.5-r1 ~x86 =dev-ruby/tmail-1.2.7.1-r2 ~x86 =dev-ruby/racc-1.4.6 ~x86 =dev-ruby/i18n-0.1.3 ~x86 =dev-ruby/rack-1.2.1 ~x86 =dev-ruby/rack-1.1.0-r1 ~x86 =dev-ruby/rack-1.1.0 ~x86 =dev-ruby/rack-1.0.1-r1 ~x86 # --- # END: www-apps/redmine-1.0.5 # ---
そして、redmine のインストール。
# emerge =www-apps/redmine-1.0.5
次に、redmine の日本語サイト のインストラクションに従って、データベースの設定を行なった。
なお、データベース名は "redmine" とし、当該データベースを新規作成しておいた。
【/var/lib/redmine/config ディレクトリに、以下の内容の設定ファイル database.yml を新規作成する】
production: adapter: mysql database: redmine username: root password: ******** host: localhost encoding: utf8
【/var/lib/redmin に入り、下記コマンドで config/initializers/session_store.rb を生成】
# rake config/initializers/session_store.rb
【データベースの初期化】
# rake db:migrate RAILS_ENV=production # rake redmine:load_default_data RAILS_ENV=production
次に、passenger で apache2 と連携させた。
# emerge www-apache/passenger
インストールされた passenger のバージョンは 2.2.15 だった。
/etc/conf.d/apache2 に "-D PASSENGER" を追加。
APACHE2_OPTS="-D PASSENGER ...
apache2 が /var/lib/redmine/public を参照できるように、apache2 のドキュメント・ルートに当該ディレクトリのシンボリック・リンクを作成した。名前はわかり易く redmine。
# ln -s /var/lib/redmine/public /var/www/localhost/htdocs/redmine
この /var/lib/redmine/public で Ruby on Rails アプリ(つまり redmine)が実行されるように、/etc/apache2/httpd.conf に以下の行を追記した。
RailsBaseURI /redmine
以上でインストール作業は完了。
/etc/init.d/apache2 restart でウェブサーバーを再起動し、
ウェブブラウザで下記へアクセスすると redmine が起動する。
http://<サーバーのURL>/redmine
なお、デフォルトでは、ID=パスワード=admin でログインできる。
texlive-2010 で日本語フォントを使う
ここではMacに標準搭載されているヒラギノフォントを例に、texlive-2010 と dvipdfmx(いずれも unstable バージョン)によるフォント埋め込みタイプのPDF作成手順を述べる。
【手順1】
ヒラギノフォントのコピーをシステムフォントと同じディレクトリに置く。
具体的には、/usr/share/fonts にサブディレクトリ "hiragino" を新規作成し、そこへ以下の2つのフォントファイルを保存する。
【手順2】
マップファイル "hiragino.map" を作成し、 /usr/share/texmf/fonts/map/dvipdfmx ディレクトリに保存する。
このファイルの内容は以下に示すとおり。
rml H HiraMinPro-W3.otf rmlv V HiraMinPro-W3.otf gbm H HiraKakuPro-W6.otf gbmv V HiraKakuPro-W6.otf
【手順3】
設定ファイル "/etc/texmf/texmf.d/10standardpaths.cnf" の OSFONTDIR にシステムフォント・ディレクトリのパスを指定する。
texlive をインストールした直後には、188行目が以下のようになっている。
OSFONTDIR = /please/set/osfontdir/in/the/environment
これを、以下のように書き換える。
OSFONTDIR = /usr/share/fonts
【手順4】
最後に、texmf-update コマンドを実行して、/etc/texmf/ 以下の設定を更新する。
$ platex hoge.tex $ dvipdfmx -f hiragino.map hoge.dvi
php インストールに際しての設定
php-5.3.4 のインストール終了時に、次のようなメッセージが出力される。
* This ebuild installed a version of php.ini based on php.ini-development version.
* You can chose which version of php.ini to install by default by setting PHP_INI_VERSION to either
* 'production' or 'development' in /etc/make.conf
* Both versions of php.ini can be found in /usr/share/doc/php-5.3.4
すなわち、デフォルトでは「development」バージョンがインストールされる。
このバージョンでは、php を利用しているウェブアプリケーションの実行時に、エラー/警告メッセージがウェブページ上に表示される。
これを回避するには、/etc/make.conf で、「production」バージョンがインストールされるように明示的に設定すればよい。
PHP_INI_VERSION = "production"
以下は、「production」バージョンと「development」バージョンの、それぞれの /etc/php/apache2-php5.3/php.ini の差分である。
514c514< error_reporting = E_ALL & ~E_DEPRECATED
- -
> error_reporting = E_ALL | E_STRICT
531c531< display_errors = Off
- -
> display_errors = On
542c542< display_startup_errors = Off
- -
> display_startup_errors = On
586c586< track_errors = Off
- -
> track_errors = On
604c604< html_errors = Off
- -
> html_errors = On
971a972
> ;extension=php_phar.dll
1246,1253d1246< ; Allow accessing, from PHP's perspective, local files with LOAD DATA statements< ; http://php.net/mysqli.allow_local_infile
< ;mysqli.allow_local_infile = On< < ; Allow or prevent persistent links.< ; http://php.net/mysqli.allow-persistent
< mysqli.allow_persistent = On<
1302c1295< mysqlnd.collect_memory_statistics = Off
- -
> mysqlnd.collect_memory_statistics = On
1571c1564< session.bug_compat_42 = Off
- -
> session.bug_compat_42 = On
1580c1573< session.bug_compat_warn = Off
- -
> session.bug_compat_warn = On
1597a1591
> session.entropy_file =
なお、インストールは、以下のような設定を手動で行なうことで完了する。
* To switch apache2 to use php:5.3, run
* eselect php set apache2 php5.3
php-5.3.4 の設定について
先日、Gentoo Linux の php のバージョンが 5.3.3-r1 から 5.3.4 にアップした。
結果、個人サーバーで運用している concrete5 にアクセスすると、数百行に及ぶメッセージが出力されるようになった。以下はその一部。
Strict Standards: Non-static method Loader::database() should not be called statically in /var/www/localhost/htdocs/fusion/concrete/dispatcher.php on line 23 Strict Standards: Non-static method Loader::library() should not be called statically in /var/www/localhost/htdocs/fusion/concrete/libraries/loader.php on line 139 Strict Standards: Non-static method Loader::library() should not be called statically in /var/www/localhost/htdocs/fusion/concrete/libraries/loader.php on line 140 Strict Standards: Non-static method Loader::library() should not be called statically in /var/www/localhost/htdocs/fusion/concrete/libraries/loader.php on line 141
/etc/php/apache2-php5.3/php.ini の "Error handling and logging" の部分(460行目以降)を見ると、
; Common Values: ; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.) ; E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices) ; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors) ; E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.) ; Default Value: E_ALL & ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL & ~E_DEPRECATED ; http://php.net/error-reporting error_reporting = E_ALL | E_STRICT
となっていて、error_reporting = E_ALL | E_STRICT からして、今回の php は「開発用」としてインストールされたらしい。
なので、concrete5 のようなウェブアプリケーションを正常動作させるには、これを、
error_reporting = E_ALL & ~E_NOTICE (註:デフォルト)
または
error_reporting = E_ALL & ~E_DEPRECATED (註:プロダクション)
と変更する必要がある。
なお、この設定変更を反映させるには、以下のように apache の再起動を行なうこと。
/etc/init.d/apache2 restart
redmine の wiki に数式を入れる
redmine 用の LaTeX プラグインは複数あるかもしれないけれど、とりあえず、ここで配布されているもの を入れてみた。
これは、あらかじめシステムにインストール済みの LaTeX 処理系を前提としている。
ちなみに、現在使っているPCには texlive がインストールしてある。
なお、プラグイン一般のインストール手順は、ここ を参照 すればよい。
ダウンロードした LaTeX プラグインのフォルダ名は、nisrael-redmine-wiki_latex_plugin-28000b9 と長たらしいが、これを wiki_latex_plugin に修正しないと動かない。
また、/wiki_latex_plugin/app/controllers/wiki_latex_controller.rb に、wiki 中の LaTeX の数式コードを画像に変換するプログラムが記述されているが、オリジナルのままでは動作しなかったので、若干チューニングを施した。以下は、修正後のプログラムである。
class WikiLatexController < ApplicationController def image @latex = WikiLatex.find_by_image_id(params[:image_id]) @name = params[:image_id] if @name != "error" image_file = File.join([RAILS_ROOT, 'tmp', 'wiki_latex_plugin', @name+".png"]) else image_file = File.join([RAILS_ROOT, 'public', 'plugin_assets', 'wiki_latex_plugin', 'images', @name+".png"]) end if (!File.exists?(image_file)) render_image end if (File.exists?(image_file)) render :file => image_file, :layout => false, :content_type => 'image/png' else render_404 end rescue ActiveRecord::RecordNotFound render_404 end private def render_image dir = File.join([RAILS_ROOT, 'tmp', 'wiki_latex_plugin']) begin Dir.mkdir(dir) rescue end basefilename = File.join([dir,@name]) temp_latex = File.open(basefilename+".tex",'w') temp_latex.puts('\documentclass[24pt]{article}') temp_latex.puts('% add additional packages here') temp_latex.puts('\pagestyle{empty}') temp_latex.puts('\usepackage{amsmath}') temp_latex.puts('\usepackage{amsfonts}') temp_latex.puts('\usepackage{amssymb}') temp_latex.puts('\usepackage{color}') temp_latex.puts('%\usepackage[active,displaymath,textmath,graphics]{preview}') temp_latex.puts('\begin{document}') temp_latex.puts @latex.source temp_latex.puts '\end{document}' temp_latex.flush temp_latex.close fork_exec(dir, "/usr/bin/latex --interaction=nonstopmode "+@name+".tex 2> /dev/null > /dev/null") fork_exec(dir, "/usr/bin/dvipng -q -D 120 -T tight -M -pp 1 "+@name+".dvi -o "+@name+".png") ['tex','dvi','log','aux','ps'].each do |ext| if File.exists?(basefilename+"."+ext) File.unlink(basefilename+"."+ext) end end end def fork_exec(dir, cmd) pid = fork{ Dir.chdir(dir) exec(cmd) exit! ec } ec = nil begin Process.waitpid pid ec = $?.exitstatus rescue end end end
さらに、数式コードの中に中括弧{}が含まれていると、このプログラムが正常動作しないが、LaTeX では中括弧を多用するから、このままでは使いものにならない。
ただし、これはプラグインではなく redmine 側の文字列解析の問題だ。
すなわち、redmine の中の wiki フォーマットを制御しているプログラムを修正する必要がある。
具体的には、/var/lib/redmine/lib/redmine/wiki_formatting/textile/formatter.rb 内の "MACROS_RE = /" で始まるブロックを、次のように書き換える。
(!)? # escaping ( \{\{ # opening tag ([\w]+) # macro name (\(((.(?!\}\}))*)\))? # optional arguments \}\} # closing tag ) /mx unless const_defined?(:MACROS_RE)
で、wiki の中に、たとえば、
{{latex($\hat{\sigma}^2=\displaystyle \frac {1}{N-p} (\mathbf{y}-\mathbf{Xb})^T (\mathbf{y}-\mathbf{Xb})$)}}
なんて書くと、、、
まぁ、いちおう数式が美しく表示されるのだが、まだまだ細かいところの調整が必要かも・・