Skip to content

Instantly share code, notes, and snippets.

@kennyj
Created September 16, 2012 02:09
Show Gist options
  • Save kennyj/3730757 to your computer and use it in GitHub Desktop.
Save kennyj/3730757 to your computer and use it in GitHub Desktop.
building test env
■db server
・mysql
$ sudo yum install mysql55 mysql55-devel mysql55-server mysql55-common mysql55-libs
$ sudo vim /etc/my.cnf
[mysqld]
character-set-server = utf8
[mysqld_safe]
character-set-server = utf8
[mysql]
default-character-set = utf8
$ sudo chown -R mysql:mysql /var/lib/mysql
$ sudo mysql_install_db
$ sudo service mysqld start
$ sudo mysql_secure_installation
$ sudo chkconfig mysqld on
$ mysql -uroot -p
mysql> GRANT ALL ON *.* TO root@"xxx.xxx.xxx.xxx" IDENTIFIED BY "password";
mysql> flush privilegs;
・postgresql
$ sudo yum -y install postgresql9 postgresql9-contrib postgresql9-devel postgresql9-libs postgresql9-server
$ sudo service postgresql initdb
$ sudo vim /var/lib/pgsql9/data/postgresql.conf
listen_addresses = 'localhost,(own hostname)'
$ sudo vim /var/lib/pgsql9/data/pg_hba.conf
host all all xxx.xxx.xxx.xxx/32 trust
$ sudo /etc/init.d/postgresql start
$ sudo chkconfig postgresql on
・oracle-xe
$ sudo dd if=/dev/zero of=/swap.extended bs=1M count=2048
$ sudo mkswap /swap.extended
$ sudo swapon /swap.extended
$ sudo vim /etc/fstab
swap /swap.extended swap defaults 0 0
$ unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
$ cd Disk1
$ sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
$ sudo /etc/init.d/oracle-xe configure
$ sudo /etc/init.d/oracle-xe status
$ sqlplus system/xxxxx@localhost/1521
> create user app_production identified by xxxxx;
> grant connect,resource,create session,create synonym to app_production;
■web/app server
・sqlite
$ sudo yum -y install sqlite sqlite-devel
・mysql
$ sudo yum -y install mysql55
$ sudo yum install -y mysql-devel
$ sudo vim /etc/my.cnf
[mysql]
default-character-set = utf8
$ mysql -uroot -p --host xxx.xxx.xxx.xxx (接続確認)
・postgresql
$ sudo yum -y install postgresql9 postgresql9-devel postgresql-libs
$ psql --username=postgres --host=xxx.xxx.xxx.xxx (接続確認)
・oracle
$ sudo rpm -ivh oracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient11.2-devel-11.2.0.2.0.x86_64.rpm
$ sudo rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm
$ sudo vim /etc/profile.d/oracle.sh
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/:$LD_LIBRARY_PATH
export PATH=/usr/lib/oracle/11.2/client64/bin/:$PATH
export NLS_LANG=JAPANESE_JAPAN.AL32UTF8
$ sqlplus system/[email protected]/xe (接続確認)
・rails
$sudo yum -y install git
$ sudo yum -y install libevent libevent-devel memcached memcached-devel
$ sudo chkconfig memcached
$ sudo /etc/init.d/memcached start
$ sudo yum -y install openssl-devel curl-devel readline-devel zlib-devel libxml2 libxml2-devel libxslt-devel libyaml-devel libffi-devel
$ sudo yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel java-1.6.0-openjdk-src
$ sudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
$ sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm
$ sudo vim /etc/yum.repos.d/nodejs-stable.repo
[nodejs-stable]
name=Stable releases of Node.js
#baseurl=http://nodejs.tchol.org/stable/amzn1/$releasever/$basearch/
mirrorlist=http://nodejs.tchol.org/mirrors/nodejs-stable-amzn1
enabled=1
skip_if_unavailable=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nodejs-stable-amzn1-$releasever
[nodejs-stable-source]
name=Stable releases of Node.js - source
#baseurl=http://nodejs.tchol.org/stable/amzn1/$releasever/SRPMS/
mirrorlist=http://nodejs.tchol.org/mirrors/nodejs-stable-source-amzn1
enabled=0
skip_if_unavailable=1
gpgcheck=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-nodejs-stable-amzn1-$releasever
$ sudo yum install nodejs-compat-symlinks npm
$ sudo npm install coffee-script -g
$ curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
$ rvm install 1.9.3-p194
$ rvm use --default 1.9.3
$ gem install rails --no-ri --no-rdoc
$ git clone https://github.com/rails/rails.git
$ cd rails
$ bundle update
$ cd ..
$ git clone https://github.com/rails/sass-rails.git
$ git clone https://github.com/rails/coffee-rails.git
$ git clone https://github.com/rails/journey.git
$ git clone https://github.com/rails/activerecord-deprecated_finders.git
$ git clone https://github.com/rsim/oracle-enhanced.git
$ cd oracle-enhanced/
$ git checkout -b rails4 origin/rails4
$ gem install ruby-oci8
$ mkdir apps
$ cd apps
$ ~/rails/railties/bin/rails new app
$ cd app
$ vim Gemfile
source 'https://rubygems.org'
gem 'rails', :path => '/home/ec2-user/rails'
gem 'journey', :path => '/home/ec2-user/journey'
gem 'activerecord-deprecated_finders', :path => '/home/ec2-user/activerecord-deprecated_finders'
# Bundle edge Rails instead:
# gem 'rails', github: 'rails/rails'
gem 'sqlite3'
gem 'mysql2'
gem 'pg'
gem 'ruby-oci8'
gem 'activerecord-oracle_enhanced-adapter', :path => '/home/ec2-user/oracle-enhanced'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sprockets-rails', github: 'rails/sprockets-rails'
gem 'sass-rails', :path => '/home/ec2-user/sass-rails'
gem 'coffee-rails', :path => '/home/ec2-user/coffee-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano', group: :development
# To use debugger
# gem 'debugger'
$ bundle update
$ RAILS_ENV=production rails g model Post title:string body:text
$ vim config/database.yml
$ RAILS_ENV=production rake db:create
$ RAILS_ENV=production rake db:migrate
sqlite3/mysql/postgres/oracle
$ vim gen.rb
columns = []
20.times { |i| columns << "column_#{i}:string" }
200.times do |i|
puts i
`rails g model m_#{i}_users #{columns.join(" ")}`
end
$ ruby gen.rb
$ RAILS_ENV=production rake db:migrate
※ Insert 1000 records every table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment