Skip to content

Instantly share code, notes, and snippets.

@liwh
Created June 21, 2012 06:39
Show Gist options
  • Save liwh/2964250 to your computer and use it in GitHub Desktop.
Save liwh/2964250 to your computer and use it in GitHub Desktop.

Collection API安装文档

安装git

rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
yum install --enablerepo=webtatic git-core

安装rbenv和ruby

git clone git://github.com/sstephenson/rbenv.git /opt/.rbenv
echo 'export PATH="/opt/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'export RBENV_ROOT="/opt/.rbenv"' >> .bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL
mkdir -p /opt/.rbenv/plugins
cd /opt/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git
rbenv install 1.9.3-p194
rbenv rehash
rbenv global 1.9.3-p194

安装MongoDB

tar -zxvf mongodb-linux-x86_64-2.0.5.tgz 
mv  mongodb-linux-x86_64-2.0.5  /opt/mongodb
mkdir -p /opt/db/mongodb
mkdir -p /opt/logs/mongodb
touch /opt/logs/mongodb/mongodb.log

mkdir /opt/bin/
mkdir /opt/config

cd /opt/bin/
wget -O mongodb-start http://library.linode.com/assets/625-mongodb-start.sh
wget -O mongodb-stop http://library.linode.com/assets/626-mongodb-stop.sh
chmod +x *

//配置mongodb属性
edit /opt/config/mongodb
  dbpath = /opt/db/mongodb
  logpath = /opt/logs/mongodb/mongodb.log
  logappend = true
  bind_ip = 127.0.0.1
  port = 27017
  fork = true
  auth = true

wget -O init-rpm.sh http://library.linode.com/assets/624-mongodb-init-rpm.sh
mv init-rpm.sh /etc/init.d/mongodb
chmod +x /etc/init.d/mongodb

安装Nginx

wget http://nginx.org/download/nginx-1.2.1.tar.gz
tar -xzvf nginx*
yum install pcre
yum install pcre-devel
./configure --prefix=/opt/nginx

安装bundler和gems

gem install bundler --no-ri --no-rdoc
git clone ssh://[email protected]/gitroot/m-push /opt/m-push
cd /opt/m-push/collection-api/
bundle 
//配置项目环境,在下面配置production下的变量
cp config/redis.yml.example config/redis.yml
cp config/mongo.yml.example config/mongo.yml
cp config/thin.yml.example config/thin.yml

###配置Nginx Conf

//根据thin 启动的服务,配置upstream
    upstream thin_collection_servers {
        server 127.0.0.1:xxxx;
        ...
    }

    server {
      listen	xxxx;
      server_name	xx;

      index index.jsp index.html index.htm;
      access_log  /opt/logs/nginx/default/collection_api.log  main;

      # 全部使用utf-8编码
      charset	utf-8;

        location / {
			proxy_pass          http://thin_lbs_servers;
            proxy_redirect      default;
            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header    X-Real-IP $remote_addr;
            proxy_set_header    Host $http_host;
            proxy_set_header    Range $http_range;

            proxy_next_upstream http_502 http_504 error timeout invalid_header;

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