mk-mode BLOG

このブログは自作の自宅サーバに構築した Debian GNU/Linux で運用しています。
PC・サーバ構築等の話題を中心に公開しております。(クローンサイト: GitHub Pages

ブログ開設日2009-01-05
サーバ連続稼働時間
Reading...
Page View 合計
Reading...
今日
Reading...
昨日
Reading...

Cygwin - Ruby on Rails を Apache2 + Passenger で!

[ サーバ構築 ] [ Apache, Cygwin, Rails, Ruby ]

こんばんは。

Cygwin に構築した Ruby on Rails 環境が Rails 標準の WEBrick では動くことを確認しました。

その流れで、Gem パッケージ Mongrel をインストールして動作確認もしました。 こちらはなんなく動作しました。

そこで、Linux サーバで導入している Apache2 + Phusion Passenger という環境を Cygwin 上でも実現させようと試みました。 Cygwin への Apache2 のインストールは以下をご参照ください。

Phusion Passenger モジュールのインストールは試行錯誤の結果、失敗しています。 参考程度にお考えください。

作業記録

Cygwin に Ruby 1.9.2-p290, Apache2 がインストール済みであることが前提となっています。

1.Gem パッケージ Phusion Passenger のインストール

以下のようにして Gem パッケージ Phusion Passenger をインストールします。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$ gem install passenger
Fetching: fastthread-1.0.7.gem (100%)
Building native extensions.  This could take a while...
Fetching: daemon_controller-0.2.6.gem (100%)
Fetching: passenger-3.0.11.gem (100%)
Successfully installed fastthread-1.0.7
Successfully installed daemon_controller-0.2.6
Successfully installed passenger-3.0.11
3 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for daemon_controller-0.2.6...
Installing ri documentation for passenger-3.0.11...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for daemon_controller-0.2.6...
Installing RDoc documentation for passenger-3.0.11...

2.Phusion Passenger インストール

以下のようにしてPhusion Passenger モジュールをインストールします。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
$ passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.11.

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... found at /usr/sbin/httpd2
 * 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.

--------------------------------------------

Installation instructions for required software

 * To install Curl development headers with SSL support:
   Please download Curl from http://curl.haxx.se/libcurl and make sure you install it with SSL support.

 * To install Apache 2 development headers:
   Please download it from http://httpd.apache.org/

 * To install Apache Portable Runtime (APR) development headers:
   Please download it from http://httpd.apache.org/
   (APR is an integrated part of Apache.)

 * To install Apache Portable Runtime Utility (APU) development headers:
   Please download it from http://httpd.apache.org/
   (APR Utility is an integrated part of Apache.)

If the aforementioned instructions didn't solve your problem, then please take
a look at the Users Guide:

  /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/doc/Users guide Apache.html

エラーが出ています。

3.不足パッケージのインストール

前述の処理で出力されているように、以下のものが不足しているようです。

  • Curl development headers with SSL support
  • Apache 2 development headers
  • Apache Portable Runtime (APR) development headers
  • Apache Portable Runtime Utility (APU) development headers

メッセージでは「ダウンロードしてください」としか表示されていませんが、以下のようにしてインストールしました。(apt-cyg 導入済みが前提)

1
2
3
4
$ apt-cyg install libcurl-devel
$ apt-cyg install apache2-devel
$ apt-cyg install libapr1-devel
$ apt-cyg install libaprutil1-devel

4.再度 Passenger インストール

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
$ passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v3.0.11.

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... 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... found at /usr/sbin/httpd2
 * Apache 2 development headers... found at /usr/sbin/apxs2
 * Apache Portable Runtime (APR) development headers... found at /usr/bin/apr-1-config
 * Apache Portable Runtime Utility (APU) development headers... found at /usr/bin/apu-1-config

--------------------------------------------
Compiling and installing Apache 2 module...
cd /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11
/usr/local/bin/ruby.exe /usr/local/bin/rake apache2:clean apache2 RELEASE=yes
# /usr/local/bin/ruby.exe /usr/local/bin/rake apache2:clean apache2 RELEASE=yes
(in /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11)
rm -rf ext/common/libboost_oxt.a ext/common/libboost_oxt
rm -rf ext/common/libpassenger_common.a ext/common/libpassenger_common
rm -f agents/PassengerWatchdog agents/PassengerLoggingAgent
rm -rf ext/apache2/module_libboost_oxt.a ext/apache2/module_libboost_oxt
rm -rf ext/apache2/module_libpassenger_common.a ext/apache2/module_libpassenger_common
rm -rf ext/apache2/Configuration.o ext/apache2/Bucket.o ext/apache2/Hooks.o ext/apache2/mod_passenger.o ext/apache2/mod_passenger.so agents/PassengerHelperAgent
mkdir -p ext/apache2/module_libpassenger_common
g++ -Iext -Iext/common -Iext/libev -fPIC -DCYGWIN -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include -I/usr/include/apache2 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="<ext/hash_fun.h>" -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/module_libpassenger_common/aggregate.o -c ext/apache2/module_libpassenger_common/aggregate.cpp
ext/apache2/module_libpassenger_common/aggregate.cpp:1: 警告: -fPIC はターゲットで無視されます (全てのコードは位置非依存です)
ext/boost/smart_ptr/detail/spinlock_pool.hpp:25 から include されたファイル中,
                 ext/boost/smart_ptr/shared_ptr.hpp:37 から,
                 ext/boost/shared_ptr.hpp:17 から,
                 ext/boost/thread/pthread/thread_data.hpp:10 から,
                 ext/boost/thread/thread.hpp:17 から,
                 ext/boost/thread.hpp:13 から,
                 ext/common/AccountsDatabase.h:30 から,
                 ext/common/AccountsDatabase.cpp:31 から,
                 ext/apache2/module_libpassenger_common/aggregate.cpp:5 から:
ext/boost/smart_ptr/detail/spinlock.hpp:41:53: boost/smart_ptr/detail/spinlock_w32.hpp: No such file or directory
In file included from ext/boost/smart_ptr/shared_ptr.hpp:37,
                 from ext/boost/shared_ptr.hpp:17,
                 from ext/boost/thread/pthread/thread_data.hpp:10,
                 from ext/boost/thread/thread.hpp:17,
                 from ext/boost/thread.hpp:13,
                 from ext/common/AccountsDatabase.h:30,
                 from ext/common/AccountsDatabase.cpp:31,
                 from ext/apache2/module_libpassenger_common/aggregate.cpp:5:
ext/boost/smart_ptr/detail/spinlock_pool.hpp:38: error: `spinlock' does not name a type
ext/boost/smart_ptr/detail/spinlock_pool.hpp:42: error: ISO C++ forbids declaration of `spinlock' with no type
ext/boost/smart_ptr/detail/spinlock_pool.hpp:42: error: expected `;' が '&' トークンの前にあります
ext/boost/smart_ptr/detail/spinlock_pool.hpp:48: error: expected `;' が "class" の前にあります
ext/boost/smart_ptr/detail/spinlock_pool.hpp:52: error: ISO C++ forbids declaration of `spinlock' with no type
ext/boost/smart_ptr/detail/spinlock_pool.hpp:52: error: expected `;' が '&' トークンの前にあります
ext/boost/smart_ptr/detail/spinlock_pool.hpp: In constructor `boost::detail::spinlock_pool<I>::scoped_lock::scoped_lock(const void*)':
ext/boost/smart_ptr/detail/spinlock_pool.hpp:59: error: class `boost::detail::spinlock_pool<I>::scoped_lock' does not have any field named `sp_'
ext/boost/smart_ptr/detail/spinlock_pool.hpp:59: error: there are no arguments to `spinlock_for' that depend on a template parameter, so a declaration of `spinlock_for' must be available
ext/boost/smart_ptr/detail/spinlock_pool.hpp:59: error: (if you use `-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
ext/boost/smart_ptr/detail/spinlock_pool.hpp:61: error: `sp_' undeclared (first use this function)
ext/boost/smart_ptr/detail/spinlock_pool.hpp:61: error: (未宣言変数については、それが関数内で最初に現われた時だけ報告されます。)
ext/boost/smart_ptr/detail/spinlock_pool.hpp: In destructor `boost::detail::spinlock_pool<I>::scoped_lock::~scoped_lock()':
ext/boost/smart_ptr/detail/spinlock_pool.hpp:66: error: `sp_' undeclared (first use this function)
ext/boost/smart_ptr/detail/spinlock_pool.hpp: At global scope:
ext/boost/smart_ptr/detail/spinlock_pool.hpp:71: error: expected constructor, destructor, or type conversion が "spinlock_pool" の前にあります
ext/boost/smart_ptr/detail/spinlock_pool.hpp:71: error: expected `;' が "spinlock_pool" の前にあります
In file included from ext/boost/shared_ptr.hpp:17,
                 from ext/boost/thread/pthread/thread_data.hpp:10,
                 from ext/boost/thread/thread.hpp:17,
                 from ext/boost/thread.hpp:13,
                 from ext/common/AccountsDatabase.h:30,
                 from ext/common/AccountsDatabase.cpp:31,
                 from ext/apache2/module_libpassenger_common/aggregate.cpp:5:
ext/boost/smart_ptr/shared_ptr.hpp: In function `boost::shared_ptr<X> boost::atomic_exchange(boost::shared_ptr<X>*, boost::shared_ptr<X>)':
ext/boost/smart_ptr/shared_ptr.hpp:647: error: `spinlock' is not a member of `boost::detail'
ext/boost/smart_ptr/shared_ptr.hpp:647: error: `sp' undeclared (first use this function)
ext/boost/smart_ptr/shared_ptr.hpp:647: error: `spinlock_for' is not a member of `boost::detail::spinlock_pool<2>'
ext/boost/smart_ptr/shared_ptr.hpp: In function `bool boost::atomic_compare_exchange(boost::shared_ptr<X>*, boost::shared_ptr<X>*, boost::shared_ptr<X>)':
ext/boost/smart_ptr/shared_ptr.hpp:663: error: `spinlock' is not a member of `boost::detail'
ext/boost/smart_ptr/shared_ptr.hpp:663: error: `sp' undeclared (first use this function)
ext/boost/smart_ptr/shared_ptr.hpp:663: error: `spinlock_for' is not a member of `boost::detail::spinlock_pool<2>'
In file included from ext/oxt/detail/../spin_lock.hpp:51,
                 from ext/oxt/detail/backtrace_enabled.hpp:36,
                 from ext/oxt/backtrace.hpp:132,
                 from ext/common/ServerInstanceDir.h:30,
                 from ext/common/AccountsDatabase.h:33,
                 from ext/common/AccountsDatabase.cpp:31,
                 from ext/apache2/module_libpassenger_common/aggregate.cpp:5:
ext/oxt/detail/../detail/spin_lock_pthreads.hpp: At global scope:
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:41: error: `pthread_spinlock_t' does not name a type
ext/oxt/detail/../detail/spin_lock_pthreads.hpp: In constructor `oxt::spin_lock::spin_lock()':
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:61: error: `spin' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:61: error: `pthread_spin_init' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp: In destructor `oxt::spin_lock::~spin_lock()':
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:71: error: `spin' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:71: error: `pthread_spin_destroy' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp: In member function `void oxt::spin_lock::lock()':
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:78: error: `spin' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:78: error: `pthread_spin_lock' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp: In member function `void oxt::spin_lock::unlock()':
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:88: error: `spin' undeclared (first use this function)
ext/oxt/detail/../detail/spin_lock_pthreads.hpp:88: error: `pthread_spin_unlock' undeclared (first use this function)
In file included from ext/apache2/module_libpassenger_common/aggregate.cpp:6:
ext/common/AgentBase.cpp: In function `void Passenger::installAbortHandler()':
ext/common/AgentBase.cpp:308: error: `MINSIGSTKSZ' undeclared (first use this function)
ext/common/AgentBase.cpp:317: error: `stack_t' undeclared (first use this function)
ext/common/AgentBase.cpp:317: error: expected `;' が "stack" の前にあります
ext/common/AgentBase.cpp:318: error: `stack' undeclared (first use this function)
ext/common/AgentBase.cpp:321: error: `sigaltstack' undeclared (first use this function)
In file included from ext/common/MessageServer.h:47,
                 from ext/common/Utils.cpp:45,
                 from ext/apache2/module_libpassenger_common/aggregate.cpp:10:
ext/common/MessageChannel.h: In member function `bool Passenger::MessageChannel::readRaw(void*, unsigned int, long long unsigned int*)':
ext/common/MessageChannel.h:395: error: `llroundl' undeclared (first use this function)
rake aborted!
Command failed with status (1): [g++ -Iext -Iext/common -Iext/libev -fPIC -...]
/usr/local/lib/ruby/1.9.1/rake.rb:993:in `block in sh'
/usr/local/lib/ruby/1.9.1/rake.rb:1008:in `call'
/usr/local/lib/ruby/1.9.1/rake.rb:1008:in `sh'
/usr/local/lib/ruby/1.9.1/rake.rb:1092:in `sh'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/build/cplusplus_support.rb:31:in `compile_cxx'
/usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/build/common_library.rb:126:in `block in define_common_library_task'
/usr/local/lib/ruby/1.9.1/rake.rb:634:in `call'
/usr/local/lib/ruby/1.9.1/rake.rb:634:in `block in execute'
/usr/local/lib/ruby/1.9.1/rake.rb:629:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:629:in `execute'
/usr/local/lib/ruby/1.9.1/rake.rb:595:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/rake.rb:605:in `block in invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:602:in `invoke_prerequisites'
/usr/local/lib/ruby/1.9.1/rake.rb:594:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/usr/local/lib/ruby/1.9.1/rake.rb:588:in `invoke_with_call_chain'
/usr/local/lib/ruby/1.9.1/rake.rb:581:in `invoke'
/usr/local/lib/ruby/1.9.1/rake.rb:2041:in `invoke_task'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `block (2 levels) in top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `each'
/usr/local/lib/ruby/1.9.1/rake.rb:2019:in `block in top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:2058:in `standard_exception_handling'
/usr/local/lib/ruby/1.9.1/rake.rb:2013:in `top_level'
/usr/local/lib/ruby/1.9.1/rake.rb:1992:in `run'
/usr/local/bin/rake:31:in `<main>'

--------------------------------------------

It looks like something went wrong

Please read our Users guide for troubleshooting tips:

   /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/doc/Users guide Apache.html

If that doesn't help, please use our support facilities at:

   http://www.modrails.com/

We'll do our best to help you.

5.対応

上記の出力メッセージの中でまず “llroundl” が定義されていないという旨が見つかります。 この場合の対応方法をいろいろ調べて、ある方法を試してみました。 しかし、"llroundl" の部分のエラーは解消されたものの、次は他の部分でエラーが発生してしまいます。 先が長そうなので、Cygwin + Apache2 + Phusion Passenger での運用はあきらめることにします。 本サーバでもなくテスト用環境ですから、Cygwin 上での Ruby on Rails は Mongrel で行くことにします。


以上です。

Comments