Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created February 3, 2012 14:33
Show Gist options
  • Select an option

  • Save ngsw/1730435 to your computer and use it in GitHub Desktop.

Select an option

Save ngsw/1730435 to your computer and use it in GitHub Desktop.
Scientific Linux 6.1 yum_setup & rbenv
# sl は $releasever をベタ書き
cat > /etc/yum.repos.d/nginx.repo <<'nginxREPO'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
nginxREPO
# ばっといれとく curl-devel は passenger あたりで言われる
yum install gcc pcre* zlib* openssl* gd* libpng* libjpeg* GeoIP* curl-devel
# /etc/init.d/nginx ファイルが欲しい
yum install nginx
cp -a /etc/init.d/nginx /root/
yum remove nginx
# rbenv 使ってるユーザで
$ rbenv exec gem install rake
$ rbenv exec gem install passenger
# nginx 入れる
### http://d.hatena.ne.jp/karasuyamatengu/20120529/1338278986
export nginx_ver="1.1.14"
export nginx_configure_script="nginx_configure_`echo ${nginx_ver}|sed -e 's/\./_/g'`.sh"
mkdir /usr/local/src/NGINX/
cd /usr/local/src/NGINX
wget http://nginx.org/download/nginx-${nginx_ver}.tar.gz
tar zxvf nginx-${nginx_ver}.tar.gz
echo '#!/bin/sh
NGINX=nginx-NGINX_VER
SOURCE_DIR=/usr/local/src/NGINX
id nginx || sudo useradd -s /sbin/nologin -d /usr/local/nginx -M nginx
cd $SOURCE_DIR/$NGINX
[ -e "$SOURCE_DIR/$NGINX/Makefile" ] && make clean
./configure \
--prefix="/usr/local/nginx" \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_random_index_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-cc-opt="-Wno-error" \
--add-module="/home/USER/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/nginx" \
&& make
' | sed -e "s/NGINX_VER/${nginx_ver}/g" > /usr/local/src/${nginx_configure_script}
# でpassengerのコンパイルで使う rake を root が見つけられずで実行できないから、
# /home/USER/.rbenv/shims を PATHに追加しちまったよ
# このやり方賢くない……
sh /usr/local/src/${nginx_configure_script}
cd /usr/local/src/NGINX/${nginx_ver}
make install
# とりあえずここまで
# sl は $releasever をベタ書き
cat > /etc/yum.repos.d/nginx.repo <<'nginxREPO'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
nginxREPO
# ばっといれとく curl-devel は passenger あたりで言われる
yum install gcc pcre* zlib* openssl* gd* libpng* libjpeg* GeoIP* curl-devel
# /etc/init.d/nginx ファイルが欲しい
yum install nginx
cp -a /etc/init.d/nginx /root/
yum remove nginx
# rbenv 使ってるユーザで
$ rbenv exec gem install rake
$ rbenv exec gem install passenger
# nginx 入れる
export nginx_ver="1.1.14"
export nginx_configure_script="nginx_configure_`echo ${nginx_ver}|sed -e 's/\./_/g'`.sh"
mkdir /usr/local/src/NGINX/
cd /usr/local/src/NGINX
wget http://nginx.org/download/nginx-${nginx_ver}.tar.gz
tar zxvf nginx-${nginx_ver}.tar.gz
echo '#!/bin/sh
NGINX=nginx-NGINX_VER
SOURCE_DIR=/usr/local/src/NGINX
id nginx || sudo useradd -s /sbin/nologin -d /usr/local/nginx -M nginx
cd $SOURCE_DIR/$NGINX
[ -e "$SOURCE_DIR/$NGINX/Makefile" ] && make clean
./configure \
--prefix="/usr/local/nginx" \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-cc-opt="-Wno-error" \
--add-module="/home/USER/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/nginx" \
&& make
' | sed -e "s/NGINX_VER/${nginx_ver}/g" > /usr/local/src/${nginx_configure_script}
# でpassengerのコンパイルで使う rake を root が見つけられずで実行できないから、
# /home/USER/.rbenv/shims を PATHに追加しちまったよ
# このやり方賢くない……
sh /usr/local/src/${nginx_configure_script}
cd /usr/local/src/NGINX/${nginx_ver}
make install
# とりあえずここまで
# sl は $releasever をベタ書き
cat > /etc/yum.repos.d/nginx.repo <<'nginxREPO'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/6/$basearch/
gpgcheck=0
enabled=1
nginxREPO
# ばっといれとく curl-devel は passenger あたりで言われる
yum install gcc pcre* zlib* openssl* gd* libpng* libjpeg* GeoIP* curl-devel
# /etc/init.d/nginx ファイルが欲しい
yum install nginx
cp -a /etc/init.d/nginx /root/
yum remove nginx
# rbenv 使ってるユーザで
$ rbenv exec gem install rake
$ rbenv exec gem install passenger
# nginx 入れる
export nginx_ver="1.1.14"
export nginx_configure_script="nginx_configure_`echo ${nginx_ver}|sed -e 's/\./_/g'`.sh"
mkdir /usr/local/src/NGINX/
cd /usr/local/src/NGINX
wget http://nginx.org/download/nginx-${nginx_ver}.tar.gz
tar zxvf nginx-${nginx_ver}.tar.gz
echo '#!/bin/sh
NGINX=nginx-NGINX_VER
SOURCE_DIR=/usr/local/src/NGINX
id nginx || sudo useradd -s /sbin/nologin -d /usr/local/nginx -M nginx
cd $SOURCE_DIR/$NGINX
[ -e "$SOURCE_DIR/$NGINX/Makefile" ] && make clean
./configure \
--prefix="/usr/local/nginx" \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_geoip_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-cc-opt="-Wno-error" \
--add-module="/home/USER/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/ext/nginx" \
&& make
' | sed -e "s/NGINX_VER/${nginx_ver}/g" > /usr/local/src/${nginx_configure_script}
# でpassengerのコンパイルで使う rake を root が見つけられずで実行できないから、
# /home/USER/.rbenv/shims を PATHに追加しちまったよ
# このやり方賢くない……
sh /usr/local/src/${nginx_configure_script}
cd /usr/local/src/NGINX/${nginx_ver}
make install
# とりあえずここまで
@ngsw
Copy link
Copy Markdown
Author

ngsw commented Feb 5, 2012

この場合だと
passenger_root /home/USER/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/passenger-3.0.11;
passenger_ruby /home/USER/.rbenv/versions/1.9.3-p0/bin/ruby;
になるかと
passenger_ruby /home/USER/.rbenv/ruby;
にしてはまった。
ブラウザ表示 #=> Cannot spawn application '/path/to/{rails,sinatra}_root': Could not read from the spawn server: Connection reset by peer (104)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment