Skip to content

Instantly share code, notes, and snippets.

@roana0229
Last active June 25, 2017 07:56
Show Gist options
  • Save roana0229/5469fd5acbf25f19e3ff500de409b7bc to your computer and use it in GitHub Desktop.
Save roana0229/5469fd5acbf25f19e3ff500de409b7bc to your computer and use it in GitHub Desktop.
Vagrant上のCentOS6.5でどどんとふ鯖を立てるスクリプトと設定ファイル 8080ポート

どどんとふ公式:https://github.com/torgtaitai/DodontoF

curl -O https://gist.githubusercontent.com/roana0229/5469fd5acbf25f19e3ff500de409b7bc/raw/5b8e453fb497a68b76411e0313455401d34874b9/Vagrantfile
vagrant up
vagrant ssh

sudo su -
sh -c "$(curl -fsSL https://gist.githubusercontent.com/roana0229/5469fd5acbf25f19e3ff500de409b7bc/raw/2d06fedcb9a4a708b6c53693bf484cc634d299b7/init.sh)";

# html/DodontoF/DodontoFServer.rb, dodontod.rb 1行目のrubyパス変更する
source ~/.bash_profile
ruby -v
which ruby
vi /usr/share/nginx/html/DodontoF/DodontoFServer.rb 
vi /usr/share/nginx/html/DodontoF/dodontof.rb 

# rubyパス変更後にリスタート
service dodontof restart

# どどんとふを公開するURL
# domain:8080/DodontoF/index.html
#!/bin/bash
#
# chkconfig: 2345 85 15
# description: dodontof with nginx.
start() {
/usr/bin/spawn-fcgi -d /usr/share/nginx/html/DodontoF -f /usr/share/nginx/html/DodontoF/dodontof.rb -p 9000 -F 10 -P /var/run/dodontof.pid
service nginx start
}
stop() {
kill -9 `cat /var/run/dodontof.pid`
service nginx stop
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: HOGE {start|stop|restart}"
esac
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ \.rb$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index DodontoFServer.rb;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
#!/bin/bash
yum upgrade -y
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum install -y http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install -y nginx unzip git
yum install -y fcgi fcgi-devel spawn-fcgi --enablerepo=epel
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
source ~/.bash_profile
rbenv install 2.3.4
rbenv global 2.3.4
gem update --system
gem install fcgi msgpack
cd /tmp
# http://www.dodontof.com/DodontoF/newestVersion.html
wget http://www.dodontof.com/DodontoF/DodontoF_Ver.1.48.27.zip
unzip DodontoF_Ver.1.48.27.zip
cp -rf DodontoF_WebSet/public_html/* /usr/share/nginx/html/
cp -rf DodontoF_WebSet/saveData /usr/share/nginx/
# http://cre.jp/techblog/2016/01/27/dodontof-centos7-nginx-spawn/
wget https://gist.githubusercontent.com/roana0229/de0101f8be8e254c87eb8c550b8c8d3f/raw/5a4e8260911bb7de2c784a7d27734b6d860b7560/dodontof.rb
wget https://gist.githubusercontent.com/roana0229/5469fd5acbf25f19e3ff500de409b7bc/raw/763ac1722927ac5ac6da26b5e76e168a1efd349b/dodontof
wget https://gist.githubusercontent.com/roana0229/5469fd5acbf25f19e3ff500de409b7bc/raw/763ac1722927ac5ac6da26b5e76e168a1efd349b/dodontof.conf
mv dodontof.rb /usr/share/nginx/html/DodontoF/dodontof.rb
mv dodontof.conf /etc/nginx/conf.d/dodontof.conf
mv dodontof /etc/init.d/dodontof
chmod +x /etc/init.d/dodontof
chkconfig --add dodontof
chkconfig dodontof on
cd /usr/share/nginx
chmod 705 html/DodontoF
chmod 705 html/DodontoF/dodontof.rb
chmod 600 html/DodontoF/log.txt
chmod 600 html/DodontoF/log.txt.0
chmod 705 html/DodontoF/saveDataTempSpace
chmod 705 html/DodontoF/fileUploadSpace
chmod 705 html/DodontoF/replayDataUploadSpace
chmod 705 html/imageUploadSpace
chmod 705 html/imageUploadSpace/smallImages
chmod 705 saveData
chown -R nginx. html
chown -R nginx. saveData
# どどんとふの設定変更
sed -i -e "s/\$canUseExternalImageModeOn = false/\$canUseExternalImageModeOn = true/g" html/DodontoF/src_ruby/config.rb
sed -i -e "s/\$isMessagePackInstalled = false/\$isMessagePackInstalled = true/g" html/DodontoF/src_ruby/config.rb
# iptables 8080ポートを許可
sed -i -e "/--dport 22 -j ACCEPT/a -A INPUT -p tcp --dport 8080 -j ACCEPT" /etc/sysconfig/iptables
service iptables restart
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "nrel/CentOS-6.5-x86_64"
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment