LoginSignup
1
0

More than 5 years have passed since last update.

VagrantでMailCatcher環境構築(CentOS6 + PHP)

Last updated at Posted at 2018-03-29

全体の流れ

  1. Ruby2系を入れる
  2. GemでMailCatcherを入れる
  3. PHPで動くように設定
  4. VagrantのIPを指定して起動

Ruby2系のインストール

標準リポジトリではRuby1.8が入ってしまうためRHSCLを利用する
rbenvを使おうかと思ったが設定周りで事故りそうなので今回はRHSCLを利用する事にする

RHSCLからRuby2.3をインストールしPATHを通す

# yum install centos-release-scl
# yum install rh-ruby23 rh-ruby23-ruby-devel
# ln -s /opt/rh/rh-ruby23/enable /etc/profile.d/rh-ruby23.sh

PATHが通ってるか確認

# ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux-gnu]

GemでMailCatcherをインストール

MailCatcherをインストールするにはまだ必要な物があるため引き続きyumでインストール

# yum install gcc gcc-c++ sqlite-devel

必要な物が揃ったのでMailCatcherをインストール

# gem install mailcatcher

PHPで動くように設定

php.iniのmail関連の設定を下記のように変更(hostやportはライブラリ側で設定しても良い)

SMTP = 127.0.0.1
smtp_port = 1025
sendmail_from = no-reply@example.com
sendmail_path = /usr/bin/env /opt/rh/rh-ruby23/root/usr/local/bin/catchmail

VagrantのIPを指定して起動

# mailcatcher --http-ip 192.168.33.10

確認
http://192.168.33.10:1080

1
0
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
1
0