1. SSH into your instance
$ ssh ec2-user@50.16.195.2 -i ~/rtremainekey.pem2. Install GCC - enter "y" when prompted
$ sudo yum install gcc3. Install MySQL - enter "y" when prompted
$ sudo yum install mysql-server mysql-libs mysql-devel4. Install Ruby - enter "y" when prompted
sudo yum install ruby ruby-devel ruby-irb ruby-rdoc ruby-ri5. Install RubyGems
$ cd /tmp $ wget -q http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz $ tar xzf rubygems-1.3.7.tgz $ cd rubygems-1.3.7 $ sudo ruby setup.rb6. Install Rails - this one will take a while
$ sudo gem install rails7. Start MySQL
$ sudo /etc/init.d/mysqld start8. Give the root MySQL user a password
$ mysqladmin -u root password yourpassword
9. Create symlinks to MySQL libraries$ cd /usr/lib64/ $ sudo ln -s mysql/libmysqlclient.so $ sudo ln -s mysql/libmysqlclient.so.16 $ sudo ln -s mysql/libmysqlclient_r.so $ sudo ln -s mysql/libmysqlclient_r.so.1610. Install MySQL Gem
Expect to see some "No definition" errors.
$ sudo gem install mysql11. Open Port 3000
To keep things simple I'm opening port 3000 which is the default WEBrick binding. Login to the AWS Management Console and select the security group for your instance. Add a new entry with the following values.
- Connection Method: HTTP
- Protocol: TCP
- From Port: 3000
- To Port: 3000
The remaining steps are taken from the Getting Started with Rails tutorial. I'm only using the first few steps here to verify Rails and MySQL are configured and running correctly.
12. Create A Test Project
$ cd ~ $ rails new blog --database=mysql $ cd blog $ sudo bundle install13. Set your MySQL password
Edit config/database.yml
$ nano config/database.ymland apply the root password from step 8. You'll need to add it in 3 places, your database.yml should look like this when finished:
development: adapter: mysql2 encoding: utf8 reconnect: false database: blog_development pool: 5 username: root password: yourpassword socket: /var/lib/mysql/mysql.sock test: adapter: mysql2 encoding: utf8 reconnect: false database: blog_test pool: 5 username: root password: yourpassword socket: /var/lib/mysql/mysql.sock production: adapter: mysql2 encoding: utf8 reconnect: false database: blog_production pool: 5 username: root password: yourpassword socket: /var/lib/mysql/mysql.sock14. Create The Database
$ rake db:create15. Start WEBrick
$ rails serverNote: WEBrick should really only be used for development & testing. For a production level web server you'll want something like Mongrel.
16. Welcome Aboard!
Browse to http://50.16.195.2:3000/ (using your Elastic Ip). If everything worked you will be greeted with the welcome aboard page.
You should be all set. If you're new to Rails I recommend continuing the Getting Started with Rails tutorial, to keep going with it start at 4.2 Say “Hello”, Rails.
This is great. Did you choose not to use rvm for a specific reason? Obviously not strictly necessary. Could always add it later. Also I wonder why you had to make the mysql symlinks, I've never heard of that.
ReplyDeletehttp://news.ycombinator.com/item?id=2059964
ReplyDeleteThanks. No reason against rvm, good idea for a follow up post. I'd also like to get Mongrel running on there.
ReplyDeleteWithout the symlinks the mysql gem was failing with complaints about not being able to find the libs. There is probably a better a way to solve it.