Redmineを使っているサーバのお引越しに伴い,改めてインストールからやってみる。
今度の環境は,FreeBSD11
FreeBSD 11.0のイニシエータからBuffalo TeraStation TS5400DをターゲットとしてiSCSIで接続した。
iSCSIはSCSI(Small Computer System Interface)をTCP/IPネットワーク上で実現したものである。
iSCSIでは,サーバ側のデバイスを提供する側を「ターゲット」と呼び、サービスを利用する側を「イニシエータ」と呼ぶ。
Tera StationをiSCSIターゲットとして使用するには,最初にボリュームを作成する必要がある。
FreeBSD ハンドブック 28.12. iSCSI Initiator and Target Configurationを参照して設定した。
FreeBSD 10以降,iSCSIはカーネルレベルでネイティブに動作するようになったので,デーモンであるiscsidを起動する。
# service iscsid start
とりあえず,Handbookの通り手動でつないでみる。
# iscsictl -A -p 10.10.10.10 -t iqn.xxx.xxx.xxx
繋がったかどうかの確認をしてみる。
# iscsictl Target Name Target Portal State iqn.xxx.xxx.xxx.target0 10.10.10.10 Connected: da1 #
Connectedと表示されていれば,/dev/da1としてターゲットを接続できている。
接続できないときは,
# iscsictl Target Name Target Portal State iqn 10.10.10.10 Service unavailable #
と表示され,コンソールにも以下のメッセージが表示される。
WARNING: 10.10.10.10(iqn): login timed out after 61 seconds; reconnecting
この場合は,Initiatorは,再接続にトライし続けるため,コンソールにメッセージが表示され続ける。
iscsictlコマンドにより明示的に切断する必要がある。
# iscsictl -R -p 10.10.10.10 -t iqn.xxx.xxx.xxx.target0
iscsiにより接続すたあとは,ファイルシステムを作ってマウントすればディスクとして使える。
もちろん,ファイルシステムを作成するのは,最初だけね。
# newfs -U /dev/da0 # mount /dev/da0 /mnt
/etcにiscsi.confを作成する。
# cat /etc/iscsi.conf TeraStation { # nickname targetaddress = 10.10.10.10 targetname = iqn.xxx.xxx.xxx.target0 }
/etc/rc.confにiscsictlを有効にするよう記述する
: iscsictl_enable="YES" iscsictl_flags="-Aa"
iscsi.confを記述することで,ニックネームによる接続/切断が可能となる。
# iscsictl -An TeraStation
だとそのニックネームのターゲットが接続する。
全部接続する場合は,
# iscsictl -Aa
切断は-Aを-Rにすれば良い。
イニシエータであるFreeBSDをShutdownする分には(とりあえず)気にすることなく落とせる。
ターゲットであるTeraStationを落とす場合は,イニシエータ側のFreeBSDがターゲットをマウントしたままになっていると,
iSCSIが応答しなくなるので,ちょうどその時,アクセスすると張り付く。
ターゲットが起動すれば正常に終わるかどうかは別にしてiSCSIの処理からは帰ってくるっぽい。
Targetは,Initiatorより先に落としてはいけない。
Initiatorでは,unmountする前にiscsiデバイスとremoveしてはいけない。
[まっそうだよね。普通にディスクをぶっこ抜いたらどうなるかとおんなじだもんね。]
# pkg install cmake
# cd /usr/ports/devel/cmake # make # make install # make clean
% tar xvzf mysql-5.7.18.tar.gz % cd mysql-5.7.18 % cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1とcmakeするとDOWNLOAD_BOOSTとWITH_BOOSTのパスを設定せよとのこと。5.7からboostが必要になった。
% tar xvzf mysql-5.7.18.tar.gz % cd mysql-5.7.18 % cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/myqsl_boost % make VERBOSE=1もし,再びcmakeする場合は,boostをダウンロード済みなので,-DDOWNLOAD_BOOSTは不要
# vi /etc/group : mysql:*:86: : # vipw : mysql:*:86:86::0:0:mysql:/usr/local/mysql:/usr/sbin/nologin :または,
# pw groupadd -n mysql -g 86 # pw useradd -n mysql -u 86 -g mysql -d /usr/local/mysql -s /nonexistentpwコマンドの意味は以下の通り
# pw groupadd -n <グループ名> -n <グループ番号> # pw useradd -n <ユーザ名> -u <ユーザ番号> -g <グループ番号> -d <ログイン場所> -s <シェル>
# make install
# cd /usr/local/mysql # chown -R mysql:mysql .
root@three:/usr/local/mysql # ls -l total 71 -rw-r--r-- 1 mysql mysql 17987 Mar 18 16:45 COPYING -rw-r--r-- 1 mysql mysql 2478 Mar 18 16:45 README drwxr-xr-x 2 mysql mysql 41 May 12 00:53 bin lrwxr-xr-x 1 mysql mysql 26 May 12 00:55 data -> /iscsimount/database/data/ drwxr-xr-x 2 mysql mysql 5 May 12 00:53 docs drwxr-xr-x 3 mysql mysql 53 May 12 00:53 include drwxr-xr-x 4 mysql mysql 9 May 12 00:53 lib drwxr-xr-x 4 mysql mysql 4 May 12 00:53 man drwxr-xr-x 10 mysql mysql 22 May 12 00:53 mysql-test drwxr-xr-x 2 mysql mysql 2 May 12 01:37 mysql_secure drwxr-xr-x 2 mysql mysql 2 May 12 01:38 mysql_tmpdir drwxr-xr-x 28 mysql mysql 39 May 12 00:53 share drwxr-xr-x 2 mysql mysql 6 May 12 00:53 support-files
# /usr/local/mysql/bin/mysqld --initialize --user=mysql
# /usr/local/mysql/bin/mysqld --initialize --user=mysql YYYY-MO-DDTHH:MI:SS.xxxxxxZ 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). YYYY-MO-DDTHH:MI:SS.xxxxxxZ 0 [Warning] InnoDB: New log files created, LSN=45790 YYYY-MO-DDTHH:MI:SS.xxxxxxZ 0 [Warning] InnoDB: Creating foreign key constraint system tables. YYYY-MO-DDTHH:MI:SS.xxxxxxZ 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: dd39fd38-441c-11e7-8f73-94188235778c. YYYY-MO-DDTHH:MI:SS.xxxxxxZ 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. YYYY-MO-DDTHH:MI:SS.xxxxxxZ 1 [Note] A temporary password is generated for root@localhost: l:y1Qj(P5w>3Warningが出ているけど後でみる。
# /usr/local/mysql/bin/mysqld_safe --user=mysql
# vi /etc/rc.conf : mysqld_enable="YES" :
#!/bin/sh # # $FreeBSD: head/databases/mysql57-server/files/mysql-server.in 434623 2017-02-22 17:25:22Z mmokhi $ # # PROVIDE: mysql # REQUIRE: LOGIN iscsi_mount # KEYWORD: shutdown # # Add the following line to /etc/rc.conf to enable mysql: # mysql_enable (bool): Set to "NO" by default. # Set it to "YES" to enable MySQL. # mysql_limits (bool): Set to "NO" by default. # Set it to yes to run `limits -e -U mysql` # just before mysql starts. # mysql_dbdir (str): Default to "%%MY_DBDIR%%" # Base database directory. # mysql_confdir (str): Default to "%%ETCDIR%%" # Base configuration directory. # mysql_optfile (str): Server-specific option file. # Set it in the rc.conf or default behaviour of # `mysqld_safe` itself, will be picking # ${mysql_confdir}/my.cnf if it exists. # mysql_pidfile (str): Custum PID file path and name. # Default to "${mysql_dbdir}/${hostname}.pid". # mysql_args (str): Custom additional arguments to be passed # to mysqld_safe (default empty). # . /etc/rc.subr name="mysql" rcvar=mysql_enable load_rc_config $name : ${mysql_enable="NO"} : ${mysql_limits="NO"} #: ${mysql_dbdir="/usr/local/mysql/data"} : ${mysql_dbdir="/usr/local/mysql/data"} : ${mysql_confdir="/usr/local/etc/mysql"} if [ -f "${mysql_confdir}/my.cnf" ]; then : ${mysql_optfile="${mysql_confdir}/my.cnf"} elif [ -f "${mysql_dbdir}/my.cnf" ]; then : ${mysql_optfile="${mysql_dbdir}/my.cnf"} fi if [ ! -z "${mysql_optfile}" ]; then mysql_extra="--defaults-extra-file=${mysql_optfile}" fi mysql_user="mysql" mysql_limits_args="-e -U ${mysql_user}" : ${hostname:=`/bin/hostname`} pidfile=${mysql_pidfile:-"${mysql_dbdir}/${hostname}.pid"} command="/usr/sbin/daemon" command_args="-c -f /usr/local/mysql/bin/mysqld_safe ${mysql_extra} --basedir=/usr/local/mysql --datadir=${mysql_dbdir} --pid- file=${pidfile} --user=${mysql_user} ${mysql_args} " #procname="/usr/local/mysql/libexec/mysqld" procname="/usr/local/mysql/bin/mysqld" start_precmd="${name}_prestart" start_postcmd="${name}_poststart" mysql_install_db="/usr/local/mysql/bin/mysql_install_db" mysql_install_db_args="${mysql_extra} --basedir=/usr/local/mysql --datadir=${mysql_dbdir} --mysqld-file=${procname} --user=${mysql_user}" mysql_create_auth_tables() { eval $mysql_install_db $mysql_install_db_args >/dev/null 2>/dev/null } mysql_prestart() { if [ ! -d "${mysql_dbdir}/mysql/." ]; then mysql_create_auth_tables || return 1 fi if checkyesno mysql_limits; then eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null else return 0 fi } mysql_poststart() { local timeout=15 while [ ! -f "${pidfile}" -a ${timeout} -gt 0 ]; do timeout=$(( timeout - 1 )) sleep 1 done return 0 } run_rc_command "$1"
MySQL> set passowrd = password('ppaasswwoorrd');
apache web serverの2.4は,APRと分離されたので,先にapr, apr-utilを
インストールする必要がある。
apr(Apache Portable Runtime)は Apache HTTP Server のサポートライブラリ。
OSとソフトウェアの間でOSなどの環境の違いを吸収するAPI
apr-1.5.2
$ tar xvjf apr-1.5.2.tar.bz2 $ cd apr-1.5.2 $ ./configure $ make # make install
apr-util-1.5.4
$ tar xvjf apr-util-1.5.4.tar.bz2 $ cd apr-util-1.5.4 $ ./configure --with-apr=/usr/local/apr --with-mysql=/usr/local/mysql もしかしたら $ ./configure --with-apr=/usr/local/apr --with-mysql=/usr/local/mysql --with-iconv=/usr/local $ make # make install
pcre-8.40 : ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.bz2
$ tar xvjf pcre-8.40.tar.bz2 $ ./configure $ make # make install
または,portsでインストール
# cd /usr/ports/devel/pcre # make # make install # make clean
または,
pkgでさくっとインストール
# pkg install pcre
httpd-2.4.25
$ tar xvjf httpd-2.4.25.tar.bz2 $ ./configure --enable-so $ make # make install
テストしてみる。
# /usr/local/apache2/bin/apachectl start
ブラウザからIPアドレス直打ちで "It works!"
自動起動の設定
/etc/rc.confに以下を記述
apache2_enable="YES" apache2_http_accept_enable="YES" <-- see http://nhh.mo-blog.jp/ttt/2006/10/freebsd_aparch2_b1ae.html
/usr/local/etc/rc.d/にapache.shを配置
PHPをインストールする前にlibxml2をインストールする。
apxsが存在せずとエラーがでた。
よくよく見るとperlが見つからない。
$ perl -v
としてもエラーになっていた。 というわけで,pkgでさくっとインストール
$ sudo pkg install perl5
でもって,apxsのパスを修正
libxml2はpkgを使う
$ sudo pkg install libxml2
PHPのインストール
$ tar xvjf php-7.1.5.bz2 $ cd php-7.1.5 $ ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --enable-mbstring \ --enable-mysqlnd $ make $ make test $ sudo make install
phpを使うためにapacheの設定を変更する。
変更するファイルは、/usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp7.so ←はphpでインストールされるはず AddType application/x-httpd-php .php
ImageMagickは,多くのライブライに依存しているので,パッケージでインストールしてしまう。
# pkg install imagemagick-nox11
=========================================================================== Note that some standard Python modules are provided as separate ports as they require additional dependencies. They are available as: bsddb databases/py-bsddb gdbm databases/py-gdbm sqlite3 databases/py-sqlite3 tkinter x11-toolkits/py-tkinter =========================================================================== Message from trousers-0.3.14_1: To run tcsd automatically, add the following line to /etc/rc.conf: tcsd_enable="YES" You might want to edit /usr/local/etc/tcsd.conf to reflect your setup. If you want to use tcsd with software TPM emulator, use the following configuration in /etc/rc.conf: tcsd_enable="YES" tcsd_mode="emulator" tpmd_enable="YES" To use TPM, add your_account to '_tss' group like following: # pw groupmod _tss -m your_account Message from freetype2-2.8: The 2.7.x series now uses the new subpixel hinting mode (V40 port's option) as the default, emulating a modern version of ClearType. This change inevitably leads to different rendering results, and you might change port's options to adapt it to your taste (or use the new "FREETYPE_PROPERTIES" environment variable). The environment variable "FREETYPE_PROPERTIES" can be used to control the driver properties. Example: FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ cff:no-stem-darkening=1 \ autofitter:warping=1 This allows to select, say, the subpixel hinting mode at runtime for a given application. The controllable properties are listed in the section "Controlling FreeType Modules" in the reference's table of contents (/usr/local/share/doc/freetype2/reference/ft2-toc.html, if documentation was installed). Message from ghostscript9-agpl-base-9.16_5: Note: in order to use the script "dvipdf", dvips must be installed. This program is provided by another package print/tex-dvipsk. FAPIfontmap and FAPIcidfmap in /usr/local/share/ghostscript/9.16/Resource/Init have to be configured if you want to use FAPI feature. Message from liblqr-1-0.4.2: ========================================================================== NOTE: In order to compile examples for liblqr, you will also need pngwriter port (/usr/ports/graphics/pngwriter). Examples are located in /usr/local/share/examples/liblqr-1 ========================================================================== #
Pythonは,pkgでインストールしてしまう。
# pkg install python
Mercurial自体のインストールはportsでインストールしてしまう。
# cd /usr/ports/devel/mercurial # make; make install
hgユーザを作成しリポジトリのオーナー/グループをhgにしておく。
ユーザー: hg (143)
グループ: hg (143)
MercurialはサーバにPushするためにSSHとHTTP経由が使える(らしい)。
今回は,HTTP経由を選択した。
HTTP経由で公開するには,hgweb.cgiを公開する必要がある。
今回portsでインストールしたMercurial4.2では,hgweb.fcgiとhgweb.wsgiが
/usr/local/share/mercurial/www
にあり,hgweb.cgiは無かった。
Mercurial Wikiでもhgweb.cgiを使えるような記述になっていたので
sourceを覗いたら,直下にhgweb.cgiがありました。
これをWebサーバにcgi-binにコピーして使う。
ちなみに/usr/local/share/mercurial/contribにはhgrcとかのサンプルもあった。(テストインストールの時は気がつかなかったorz...)
hgweb.cgi
#!/usr/bin/env python # # An example hgweb CGI script, edit as necessary # See also http://www.mercurial-scm.com/wiki/PublishingRepositories # Path to repo or hgweb config to serve (see 'hg help hgweb') config = "/PATH/hg/hgweb.config" # Uncomment and adjust if Mercurial is not installed system-wide # (consult "installed modules" path from 'hg debuginstall'): #import sys; sys.path.insert(0, "/path/to/python/lib") import os os.environ["HGENCODING"] = "UTF-8" # Uncomment to send python tracebacks to the browser if an error occurs: #import cgitb; cgitb.enable() from mercurial import demandimport; demandimport.enable() from mercurial.hgweb import hgweb, wsgicgi application = hgweb(config) wsgicgi.launch(application)
hgweb.config
[web] description = repository author = mail@address push_ssl = false allow_push = * [trusted] users=hg groups=hg [collections] /PATH/hg/repos = /PATH/hg/repos [paths]
Installing Redmine によれば,現時点(July 14th, 2017)でのrubyバージョンとRedmineのバージョンは以下の通り。
Redmine version | Supported Ruby versions | Rails version used |
3.4 | ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3, 2.41 | Rails 4.2 |
3.3 | ruby 1.9.34, 2.0.03, 2.1, 2.22, 2.3 | Rails 4.2 |
3.2 | ruby 1.9.34, 2.0.03, 2.1, 2.22 | Rails 4.2 |
Redmine 3.4, Ruby 2.3, Rails 4.2の組合せでインストールする。
Rubyはパッケージでインストールする。
# pkg install lang/ruby23
Message from ruby-2.3.4_1,1: ==== Some of the standard commands are provided as separate ports for ease of upgrading: devel/ruby-gems: gem - RubyGems package manager devel/rubygem-rake: rake - Ruby Make And some of the standard libraries are provided as separate ports since they require extra dependencies: databases/ruby-gdbm: GDBM module Install them as occasion demands. ====
# pkg install devel/ruby-gems
gem自身でgemのアップデートをする
# gem update --system
Latest version currently installed. Aborting.
ということで,アップデートの必要はないらしい。
# gem install rails
: : Done installing documentation for i18n, thread_safe, tzinfo, minitest, concurrent-ruby, activesupport, rack, rack-test, mini_portile2, nokogiri, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mime-types-data, mime-types, mail, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, rake, thor, method_source, railties, bundler, sprockets, sprockets-rails, rails after 47 seconds 38 gems installed
さて,ここまでが,redmineをインストールするための種 ここから先は,redmineにインストール手順に従ってっやてみましょ。
redmienのソースをサイトからgetする。
これを展開してインストールしていくんだけど,展開した先でredmineが動作する(?)
ようなので,/usr/local/redmineに配置する。
% tar xvzf redmine-3.4.2 # mv redmine-3.4.2 /usr/local/redmine-3.4.2 # cd /usr/local/redmine-3.4.2
create database redmine character set utf8; create user 'redmine'@'localhost' identified by 'my_password'; grant all privileges on redmine.* to 'redmine'@'localhost';
config/database.example.yml をコピーして config/database.yml を作成する。
# cp config/database.yml.example config/database.yml
# vi database.yml production: adapter: mysql database: redmine host: localhost username: redmine password: MY_PASSWORD encoding: utf8
# gem install bundler
# bundle install --without development test postgresql sqlite
[redmine.jpのインストール手順では,記載されて] [いなかったので,コメントにしておく ] [--MySQLのC bindingをインストール ] [ # gem install mysql2 ]
# rake generate_secret_token
# rake db:migrate RAILS_ENV=production
[Redmine.jpのインストールでmysqlに失敗する場合,rails wiki pages ] [を参照せよとあるので,そちらをみて, ] [ # gem install mysql – –with-mysql-config=/usr/bin/mysql_config ] [を実行してみた。 ] [ [ # gem install mysql - -with-mysql-config=/usr/local/mysql/bin/mysql_config] [Fetching: mysql-2.8.1.gem (100%) ] [Building native extensions. This could take a while... ] [Successfully installed mysql-2.8.1 ] [1 gem installed ] [Installing ri documentation for mysql-2.8.1... ] [Installing RDoc documentation for mysql-2.8.1... ] [ ] [ # setenv LD_LIBRARY_PATH /usr/local/mysql/lib ] [ # ldconfig ] [ # gem install mysql -- --with-mysql-lib=/usr/local/mysql/lib ] [ --with-mysql-config=/usr/local/mysql/bin/mysql_config ] [ # rake db:migrate ] [ ] [このページを参考にした ] [>http://www.binrand.com/post/1080301-gems-ruby-undefined-method-init-for-mysql-class.html]
# rake redmine:load_default_data
# mkdir tmp public/plugin_assets # chown -R redmine:redmine files log tmp public/plugin_assets # chmod -R 755 files log tmp public/plugin_assets
# ruby bin/rails server webrick -e production
WEBrickが起動したら、ブラウザで http://localhost:3000/にアクセスする。
デフォルトでは,ユーザ名,パスワードともadmin
以降順次更新
setenv APXS2 /usr/local/sbin/apxs setenv APR_CONFIG /usr/local/lib/apache2/apr-config setenv APU_CONFIG /usr/local/lib/apache2/apu-config
2012-09-04
結局,このエラーは,passengerにてApacheとrailsを連携したときもでている。
undefined method `init' for Mysql:Class
切り分けるために素の状態からインストールしていく。
最初にインストールしたときは,ruby1.9系だった。
2回目は,ruby1.8系だった。rubyが1.8系の時はマイグレーションの時
LD_LIBRARY_PATHを設定するとうまくいくが,
結局passengerでapacheと連携するとうまくいかいない。
なので,rubyを1.9系にしてpassengerでApacheとRailsの連携まで行ってみる。
% ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [amd64-freebsd9]
# cd /usr/ports/devel/ruby-gems # make install clean # gem upate --system Latest version currently installed. Aborting. #
ちゃんとインストールできたっぽい。
このあと,railsのインストールに進むのである。gem install railsでインストールされるrailsのバージョンは,3.2.8。
ところが,redmineのbundlerでインストールされるrailsは3.2.6。
この差が気になるので,今回は,railsのインストールはredmineのbundlerに任せることにして
データベースを設定しましょ。
まえのまま。
production: adapter: mysql database: redmine host: localhost username: redmine password: password
# cd /usr/local/redmine # bundle install --without development test postgresql sqliteがしかし,mysqlのところでエラー発生。
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby18 extconf.rb checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... no checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby18 --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection. Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql- 2.8.1/ext/mysql_api/gem_make.out An error occurred while installing mysql (2.8.1), and Bundler cannot continue. Make sure that `gem install mysql -v '2.8.1'` succeeds before bundling.
redmine.jpに1.0系でインストールするときはmysql2を使えと書いてあったので,
# gem install mysql2
を行ったあと,mysqlも除いてbundlerでインストールしてみる。
# bundle install --without development test postgresql sqlite mysql
無事に終わった模様
# rake generate_secret_token rake aborted! no such file to load -- iconv (See full trace by running task with --trace)
おや,iconvでエラーですか。ならば,
# gem install iconv Fetching: iconv-0.1.gem (100%) Building native extensions. This could take a while... ERROR: Error installing iconv: ERROR: Failed to build gem native extension. /usr/local/bin/ruby18 extconf.rb checking for iconv() in iconv.h... no checking for iconv() in -liconv... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
そうですか,portsのconverterからruby-iconvをインストールする。
# cd /usr/ports/converters/ruby-iconv # make install clean
# rake generate_secret_token #
成功!
# rake db:migrate RAILS_ENV=production rake aborted! Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)
Tasks: TOP => db:migrate => environment (See full trace by running task with --trace)
ん?いままでとはちょっと違うメッセージ
メッセージの通りしてみましょ。
# gem install activerecord-mysql-adapter gem i activerecord-mysql-adapter ERROR: Could not find a valid gem 'activerecord-mysql-adapter' (>= 0) in any repository
activerecord-mysql-adapterの意味が違ったか。うーむ。
とりえあず,mysql2をuninstallしてmysqlをインストールしてみる。 今度は,mysql-dirを指定してみる。
# gem install mysql -- --with-mysql-dir=/usr/local/mysql Building native extensions. This could take a while... Successfully installed mysql-2.8.1 1 gem installed Installing ri documentation for mysql-2.8.1... Installing RDoc documentation for mysql-2.8.1...
素直に入った。
さて...
# gem install mysql -- --with-mysql-dir=/usr/local/mysql \ --with-mysql-include=/usr/local/mysql/include \ --with-mysql-lib=/usr/local/mysql/lib
なんか,Provided configuration options:にmysql関連のオプションがあったので,こんふぃぐ以外を全部つけてみた。
# rake db:migrate RAILS_ENV=production : :
成功!
# rake redmine:load_default_data REILS_ENV=production
webricで確認してきた。ふぅ。
# gem install passenger Fetching: fastthread-1.0.7.gem (100%) Building native extensions. This could take a while... Fetching: daemon_controller-1.0.0.gem (100%) Fetching: passenger-3.0.17.gem (100%) Successfully installed fastthread-1.0.7 Successfully installed daemon_controller-1.0.0 Successfully installed passenger-3.0.17 3 gems installed
passengerがインストールできたのでコマンドですね。
# passenger-install-apache2-module Welcome to the Phusion Passenger Apache 2 module installer, v3.0.17. This installer will guide you through the entire installation process. It shouldn't take more than 3 minutes in total. Here's what you can expect from the installation process: 1. The Apache 2 module will be installed for you. 2. You'll learn how to configure Apache. 3. You'll learn how to deploy a Ruby on Rails application. Don't worry if anything goes wrong. This installer will advise you on how to solve any problems. Press Enter to continue, or Ctrl-C to abort.
-------------------------------------------- Checking for required software...
* GNU C++ compiler... found at /usr/bin/g++ * Curl development headers with SSL support... not found * OpenSSL development headers... found * Zlib development headers... found * Ruby development headers... found * OpenSSL support for Ruby... found * RubyGems... found * Rake... found at /usr/local/bin/rake * rack... found * Apache 2... not found * Apache 2 development headers... not found * Apache Portable Runtime (APR) development headers... not found * Apache Portable Runtime Utility (APU) development headers... not found Some required software is not installed. But don't worry, this installer will tell you how to install them. Press Enter to continue, or Ctrl-C to abort.
見つからないといっているのは,curlとapache関連
まずは,curl
# cd /usr/ports/ftp/curl # make install clean;
次にapache関連
setenv APXS2 /usr/local/apache2/bin/apxs setenv APR_CONFIG /usr/local/apache2/bin/apr-1-config setenv APU_CONFIG /usr/local/apache2/bin/apu-1-config
再度,passenger-install-apache2-moduleを実行すると今度は,必要な素材が見つかってapache用のモジュールが生成された。
で,これをapacheに設定するばよいのね。
LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.17/ext/apache2/mod_passenger.so PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.17 PassengerRuby /usr/local/bin/ruby18
シンボリックリンクを使って,redmineをapache配下に
# ln -s /usr/local/redmine/public /usr/local/apache/htdocs/redmine
Apacheへの設定追加
RailsBaseURI /redmine
2012-09-06
VMマシン上でテストしていたんだけど,本機のテスト環境でインストールしようとしたらやっぱり,「undefined method `init' for Mysql:Class」に悩まされる。
この前dbはmysql一本で行こうってことにしたけど,ここは,SQLite3を使ってみたら,あっさり稼働した。
本番機は,SQLiteかな。
RoRとMySQLの連携で悩むよりRedmineを使っていきたいし。 http://htrmine.blog52.fc2.com/category3-1.html
2012-09-08
本機の環境は,FreeBSD71 #今度アップしよう + MySQL5.1
ここでは,undefined method `init' for Mysql:Classに悩まされた。mysql2を使えば解決するとかruby-mysqlを使えば大丈夫だとか。
config/database.ymlのadapterをmysqlからmysql2に変えたりしたけど効果なしだった。 これは,どうもruby1.8が使われていたためにmysql2を使用していなかったらしい。
いろいろなページを眺めていて, FreeBSD 9.0 + Redmine + Ruby19
# Install required dependancies echo "RUBY_VERSION=1.9.3" >> /etc/make.conf
によりrubyのバージョンを固定すれば...と さっそく,make.confに記述し,ruby, gem, bundlerを再インストールした。
bundlerによりredmine関連のモジュールをインストールするときにmysqlの項目がmysql2に代わっていた。
その後,rake db:migrateを行うと問題なく終了!
これで,mysqlを使うことができる。
#mysqlを必ず使わなくてはならないわけぢゃないんだけど,
#できないと気になるじゃん。
評価で使ってもらおうと思ったらどかーんと使ってしまっているユーザもいるので,sqliteからmysqlへデータの移行をしなくちゃ。
最初から飛ばすぜっって感じでいろいろ体験できちゃう。
2012-09-10
まだまだ続いていたりする。
ruby1.9系のテストをしていたら,ruby1.8系でテストドライブしていたRedmineを止めてしまったので,ruby1.8系に戻した。
そうしたらruby1.8系と1.9系が混在していた環境となってしまい,エラーが出ていなかったところでもエラーが報告されるようになってしまった。
なので,rubyを含め,Redmine関連でインストールしたものを全て削除した。
改めてruby1.9系で,Redmine環境を作ってwebrickで動作していることを確認したので, passengerを入れてApacheと連携させようとしたら...奥さんっ!
NotImplementedError: fork() function is unimplemented on this machine
forkのエラーが出る orz...
thread forkとprocess forkの違いという記述もどこかで見つけた。そうするとApacheのコンフィグレーションも関連しているかもしれないなと。
ということで,現状では,ruby1.8系でRedmineをドライブすることにする。