goo blog サービス終了のお知らせ 

つれづれなるまゝに

単なる作業メモ。主に、Linux, arduino, raspberry piとか?

rails アプリ編 はじめの一歩

2013-11-07 21:53:15 | linux
さて、アプリ作って動かしてみる

$ rails new testApp
$ cd testApp
$ rails server

とすると、

/usr/local/rvm/gems/ruby-1.9.3-p448/gems/execjs-2.0.2/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

というエラーが出る。JavaScriptの環境がないみたい。
調べてみると、Gemfileに以下を追加する必要があるとのこと。

gem 'execjs'
gem 'therubyracer'

そのあと、bundle installで必要なものがインストールされる。再度、

$ rails server

で、ちゃんと動きましたと。

redmine その6 設定編

2013-11-04 09:10:04 | linux
/var/lib/redmineに移動して作業

1) セッションストア秘密鍵の生成

rvmsudo rake generate_secret_token

2) データベース上にテーブルを作成

rvmsudo RAILS_ENV=production rake db:migrate

<いっぱいメッセージが出る>

3) デフォルトデータをデータベースに登録

rvmsudo RAILS_ENV=production rake redmine:load_default_data

Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
===================================

4) 簡単な動作確認

rvmsudo ruby script/rails server webrick -e production

でブラウザから、http://サーバのアドレス:3000/でアクセス

動きました!

次は、passengerでの起動

/var/lib/redmine$ rvmsudo gem install passenger --no-rdoc --no-ri
Fetching: daemon_controller-1.1.7.gem (100%)
Fetching: passenger-4.0.23.gem (100%)
Building native extensions. This could take a while...
Successfully installed daemon_controller-1.1.7
Successfully installed passenger-4.0.23
2 gems installed

~$ sudo su -
~# passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v4.0.23.

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...

* Checking for C compiler...
Found: yes
Location: /usr/bin/gcc
* Checking for C++ compiler...
Found: yes
Location: /usr/bin/g++
* Checking for Curl development headers with SSL support...
Found: no
Error: Cannot find the `curl-config` command.
* Checking for OpenSSL development headers...
Found: yes
Location: true
* Checking for Zlib development headers...
Found: yes
Location: true
* Checking for Ruby development headers...
Found: yes
Location: /usr/local/rvm/rubies/ruby-1.9.3-p448/include/ruby-1.9.1/ruby.h
* Checking for OpenSSL support for Ruby...
Found: yes
* Checking for RubyGems...
Found: yes
* Checking for Rake (associated with /usr/local/rvm/wrappers/ruby-1.9.3-p448/ruby)...
Found: yes
Location: /usr/local/rvm/wrappers/ruby-1.9.3-p448/rake
* Checking for rack...
Found: yes
* Checking for Apache 2...
Found: yes
Location of httpd: /usr/sbin/apache2
Apache version: 2.2.22
* Checking for Apache 2 development headers...
Found: no
* Checking for Apache Portable Runtime (APR) development headers...
Found: no
* Checking for Apache Portable Runtime Utility (APU) development headers...
Found: no

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 run apt-get install libcurl4-openssl-dev or libcurl4-gnutls-dev, whichever you prefer.

* To install Apache 2 development headers:
Please install it with apt-get install apache2-threaded-dev

* To install Apache Portable Runtime (APR) development headers:
Please install it with apt-get install libapr1-dev

* To install Apache Portable Runtime Utility (APU) development headers:
Please install it with apt-get install libaprutil1-dev

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

/usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.23/doc/Users guide Apache.html
http://www.modrails.com/documentation/Users%20guide%20Apache.html


必要なパッケージをインストール後、再度実行。


The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.23/buildout/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.23
PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p448/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.

--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:

<VirtualHost *:80>
ServerName www.yourhost.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /somewhere/public
<Directory /somewhere/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

/usr/local/rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.23/doc/Users guide Apache.html
http://www.modrails.com/documentation/Users%20guide%20Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
https://www.phusionpassenger.com

Phusion Passenger is a trademark of Hongli Lai & Ninh Bui.

できたっと。あとは、apacheの設定ですな。

redmineインストール その5

2013-11-03 22:17:51 | linux
ということでやっとbundleに成功!残りは次回に。

/var/lib/redmine$ rvmsudo bundle install --without development test
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.1)
Using multi_json (1.8.2)
Using activesupport (3.2.13)
Using builder (3.0.0)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.3)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.38)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coderay (1.0.9)
Using rack-ssl (1.3.3)
Using json (1.8.1)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using jquery-rails (2.0.3)
Using net-ldap (0.3.1)
Using pg (0.17.0)
Using ruby-openid (2.3.0)
Using rack-openid (1.4.0)
Using rails (3.2.13)
Installing rmagick (2.13.2)
Your bundle is complete!
Gems in the groups development and test were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

redmineインストール その4

2013-11-03 22:11:45 | linux
さて、旅路はまだ続く。

/var/lib/redmine$ rvmsudo bundle install --without development test
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.1)
Using multi_json (1.8.2)
Using activesupport (3.2.13)
Using builder (3.0.0)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.3)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.38)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coderay (1.0.9)
Using rack-ssl (1.3.3)
Using json (1.8.1)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using jquery-rails (2.0.3)
Using net-ldap (0.3.1)
Installing pg (0.17.0)
Using ruby-openid (2.3.0)
Using rack-openid (1.4.0)
Using rails (3.2.13)
Installing rmagick (2.13.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... yes
checking for sys/types.h... yes
checking for wand/MagickWand.h... no

Can't install RMagick 2.13.2. Can't find MagickWand.h.
*** 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/rvm/rubies/ruby-1.9.3-p448/bin/ruby


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rmagick-2.13.2 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rmagick-2.13.2/ext/RMagick/gem_make.out

An error occurred while installing rmagick (2.13.2), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.13.2'` succeeds before bundling.


と、RMagickでまたもや問題が><

sudo apt-get install graphicsmagick-libmagick-dev-compat

ここで同じ現象の人発見。これでいけるか!

redmineインストール その3

2013-11-03 22:03:50 | linux
さて、残りのエラーはMagick-config がないというものなので、ImageMagickのパッケージをインストールする。

sudo apt-get install graphicsmagick-libmagick-dev-compat

再度チャレンジ!

$ rvmsudo bundle install --without development test
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.1)
Using multi_json (1.8.2)
Using activesupport (3.2.13)
Using builder (3.0.0)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.3)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.38)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coderay (1.0.9)
Using rack-ssl (1.3.3)
Using json (1.8.1)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using jquery-rails (2.0.3)
Using net-ldap (0.3.1)
Installing pg (0.17.0)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/local/rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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/rvm/rubies/ruby-1.9.3-p448/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p448/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p448/gems/pg-0.17.0/ext/gem_make.out


まだゴールではなかったorz


sudo apt-get install postgresql-server-dev-all

を行った後、再度チャレンジ