LoginSignup
2
2

More than 5 years have passed since last update.

CentOS 6.6(Vagrant)へMailcatherをInstallする

Posted at

はじめに

この環境はVagrant(pluginとしてvagrant omnibusをインストール済みのもの)上のCentOS6.6で、 vagrant omnibus pluginによって環境構築時にインストールされるruby周りの環境を使用してMailcatherをインストールする特殊な一例となるため、一般的にはあまり役に立たないかもしれません。

インストール

vagrant omnibus pluginによってインストールされるrubyとgemは下記のパス上に配置されています。

/opt/chef/embedded/bin/

上記を使用して下記のコマンドを実行します。

sudo /opt/chef/embedded/bin/gem install mailcatcher

Fetching: eventmachine-1.0.5.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mailcatcher:
    ERROR: Failed to build gem native extension.

    /opt/chef/embedded/bin/ruby -r ./siteconf20150914-4428-1pixvkt.rb extconf.rb
*** 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
    --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=/opt/chef/embedded/bin/ruby
    --with-openssl-config
    --without-openssl-config
    --with-pkg-config
    --without-pkg-config
/opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:552:in `try_link0'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:567:in `try_link'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:648:in `try_ldflags'
    from /opt/chef/embedded/lib/ruby/2.1.0/mkmf.rb:1767:in `pkg_config'
    from extconf.rb:61:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.5 for inspection.
Results logged to /opt/chef/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/eventmachine-1.0.5/gem_make.out

エラーになってしまいました。
You have to install development tools first. というメッセージが表示されます。
これらは gcc と g++ をインストールすることにより解決できます。次のコマンドを実行します。

# 自分の場合はsqlite関連についてもエラーが出たので合わせてインストールしています。
sudo yum isntall gcc gcc-c++ sqlite-devel

再度mailcatherのインストールを試みてみる

# --no-ri --no-rdoc をオプションでつけたのはインストール時間を短縮するためです。
sudo /opt/chef/embedded/bin/gem install mailcatcher --no-ri --no-rdoc

Successfully installed mailcatcher-0.6.1
1 gem installed

Successfully が表示されていればインストールが完了しています。

設定

MailcatherのWEB画面にアクセスするために1080のポートを開放します。

# 1080ポートを開放
sudo iptables -A INPUT -p tcp -m tcp --dport 1080 -j ACCEPT

# 変更した設定を保存
sudo service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

# iptablesを再起動
sudo service iptables restart

mailcatherへメールが送信されるようにphp.iniのsendmail_pathとポートの設定を行います。

// php.ini
smtp_port = 1025
sendmail_path = /usr/bin/env /opt/chef/embedded/bin/catchmail

mailcatherの起動

最後に次のコマンドでmailcatherを起動しましょう。

# 192.168.2.10 の箇所については自身のMailcatherが起動している環境のIPを設定して下さい。
sudo /opt/chef/embedded/bin/mailcatcher --http-ip 192.168.2.10

Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://192.168.2.10:1080
*** MailCatcher runs as a daemon by default. Go to the web interface to quit.

お疲れ様です。http://192.168.2.10:1080 にアクセスすると Mailcather の画面が表示されます。
IPアドレスの箇所は御自身が設定したものになるのでご注意を!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2