在 OpenShift 中创建 DIY 应用 cd $OPENSHIFT_TMP_DIR wget http://nginx.org/download/nginx-1.2.2.tar.gz tar zxf nginx-1.2.2.tar.gz cd $OPENSHIFT_TMP_DIR wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.bz2 tar jxf pcre-8.31.tar.bz2 cd nginx-1.2.2 ./configure --prefix=$OPENSHIFT_DATA_DIR/nginx --with-pcre=$OPENSHIFT_TMP_DIR/pcre-8.31 make install
vi $OPENSHIFT_DATA_DIR/nginx/conf/nginx.conf http { … server { listen $OPENSHIFT_DIY_IP:$OPENSHIFT_DIY_PORT; server_name localhost; … } … } mv $OPENSHIFT_DATA_DIR/nginx/conf/nginx.conf $OPENSHIFT_DATA_DIR/nginx/conf/nginx.conf.template
在本地程序目录中修改 vi .openshift/action_hooks/start #!/bin/bash # The logic to start up your application should be put in this # script. The application will work only if it binds to # $OPENSHIFT_INTERNAL_IP:8080 # nohup $OPENSHIFT_REPO_DIR/diy/testrubyserver.rb $OPENSHIFT_INTERNAL_IP $OPENSHIFT_REPO_DIR/diy > $OPENSHIFT_DIY_LOG_DIR/server.log 2>&1 & # replace the $OPENSHIFT_INTERNAL_IP and $OPENSHIFT_INTERNAL_PORT before starting up the server sed -e "s/`echo '$OPENSHIFT_IP:$OPENSHIFT_PORT'`/`echo $OPENSHIFT_INTERNAL_IP:$OPENSHIFT_INTERNAL_PORT`/" $OPENSHIFT_DATA_DIR/nginx/conf/nginx.conf.template > $OPENSHIFT_DATA_DIR/nginx/conf/nginx.conf nohup $OPENSHIFT_DATA_DIR/nginx/sbin/nginx > $OPENSHIFT_DIY_LOG_DIR/server.log 2>&1 & vi .openshift/action_hooks/stop 追加: killall nginx
git commit -a -m "start nginx when starting up the app" git push 或在服务端重启应用使修改生效 ctl_all restart