fulcrum と Unicorn と Nginx と SSL と Basic認証と
昨日の記事のやつを運用にのっけるためにやったことのメモ
fulcrum の設定
cd /home/fulcrum/fulcrum bundle exec fulcrum:setup db:setup RAILS_ENV=production
アセットファイルのコンパイル
bundle exec rake assets:precompile
設定を変更
cd /home/fulcrum/fulcrum
cp config/fulcrum.example.rb config/fulcrum.rb
app_host と mailer_sender を変更
Configuration.for('fulcrum') do # Set this to the domain name of your installation. Env var APP_HOST app_host '<MY_DOMAIN>' # The email address that notification emails will be sent from. Env var # MAILER_SENDER mailer_sender 'noreply@<MY_DOMAIN>' # Disable registration pages. If set to true, users will need to be invited # to a project rather than being able to self sign-up. # Env var DISABLE_REGISTRATION #disable_registration false end
nginx の設定
インストール
yum install nginx
fulcrum のバーチャルホストを設定
vim /etc/nginx/conf.d/fulcrum.conf
SSL証明書を作成
期限は適当に10年に設定
cd /etc/nginx mkdir ssl openssl genrsa -des 1024 > key.pem openssl rsa -in key.pem -out key.pem openssl req -new -days 3650 -key key.pem csr.pem openssl req -new -days 3650 -key key.pem -out csr.pem openssl x509 -in csr.pem -out cert.pem -req -signkey key.pem -days 3650
Basic認証
htpasswdをインストール
yum install httpd-tools
パスワードを生成
htpasswd -c /etc/nginx/htpasswd <username>
その他
ホームディレクトリの権限変更
chmod 751 /home/fulcrum
起動
/etc/nginx/init.d/nginx start
自動起動設定
chkconfig nginx on
Unicorn
インストール
gem install unicorn --no-ri --no-rdoc
起動
unicorn_rails -c config/unicorn.rb -E production -p 5000
ブラウザからアクセスできるか確認だけして落とす
起動ファイル作成
vim /etc/init.d/fulcrum
GitLab からインスパイアして作成
自動起動設定など
chmod 755 /etc/init.d/fulcrum chkconfig fulcrum on
起動
/etc/init.d/fulcrum start
HTTPS でアクセスできる、はず