Fresh install on fedora 7.
First install gcc:yum install gcc
I started with No mysql and no apache installed I first did the following:
1. Install ruby.
sudo yum install ruby ruby-docs ruby-irb ruby-libs ruby-mode ruby-rdoc ruby-ri
2. Install the latest version of RubyGems, download it here http://rubyforge.org/projects/rubygems/. Save this in your home folder somewhere. I have a Downloads/src/ directory that I save these types of things to. You can skip this step if you want to use the version of RubyGems (0.9.2) that is part of the Fedora 7 install. Just use "sudo yum install rubygems".
3. Extract the downloaded file (the latest at the time of this post was rubygems-0.9.4.tgz):
# cd /home/yourusename/Downloads/src/
# tar -zxf rubygems-0.9.4.tgz
# cd /rubygems-0.9.4/
# sudo ruby setup.rb
4. Install rails:
# sudo gem install rails --include-dependencies
Mongrel
gem install mongrel mongrel_cluster railsmachine --include-dependencies
For the last install, it may ask which version you want, choose the latest ruby versions.
This error is not uncommon:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
timed out fetching http://gems.rubyforge.org/gems/net-ssh-gateway-1.0.0.gem
Configuring Mongrel
Also as root
* Creating a mongrel user to run mongrel as: /usr/sbin/adduser -r mongrel
* Create mongrel conf directory: mkdir /etc/mongrel_cluster
* Symlink mongrel initscript
ln -s /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.2/resources/mongrel_cluster /etc/init.d/mongrel_cluster
* Make it executable chmod 755 /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.2/resources/mongrel_cluster
* Add it to chkconfig chkconfig --add mongrel_cluster
* Enable it in chkconfig chkconfig mongrel_cluster on
Setup Mongrel on Your Rails App
This is using a production environment for rails.
I'm assuming you've setup your application in /var/www/ProjectName
As root:
CODE
cd /var/www/ProjectName
mongrel_rails cluster::configure -e production -p 8000 -N 3 -c /var/www/ProjectName/ -a 127.0.0.1 --user mongrel --group mongrel -c /var/www/ProjectName/
ln -s /var/www/ProjectName/config/mongrel_cluster.yml /etc/mongrel_cluster/ProjectName.yml
chown -R mongrel:mongrel /var/www/ProjectName/tmp/
Test Mongrel
Start Mongrel with service mongrel_cluster start
Browse to http://127.0.0.1:8000 http://127.0.0.1:8001 and http://127.0.0.1:8002 and check mongrel is running your rails app on each of those ports.
Setup Apache
Selinux is grumpy about the proxy setup, so go write rules for it or disable selinux on your system.
Add this to a new configuration file /etc/httpd/conf.d/rails_cluster.conf
CODE
BalancerMember http://127.0.0.1:8000
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
ProxyPass / balancer://mongrel_cluster/
ProxyPassReverse / balancer://mongrel_cluster/
Since I don't have a webserver installed yet I wondered could I use WeBrick out of the shoot, so I did the following
cd var
mkdir /www
cd www
rails test
I quickly discoverd port 3000 is not open via:
telnet server 3000
I did discover that port 80 was open
Connected to server
Okay options figure out how to open port 3000 or alter WeBrick to use port 80.....
*** I took a side break to install mysql ***
yum install httpd mysql-server mysql
*** apache ugh ***
To see what ports are listening by a process use netstat -A inet -lnp
iptables -A INPUT -i eth0 -p tcp -m tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
I found that mongrel doesn't play well with SELinux ( This took many hours to realize I didn't do this )
setenforce 1 ( on )
setenforce 0 ( off )
You can point many vhosts at a single cluster, but a cluster can only run a single application. Youll need at least one cluster per application.
So I finally get Mongrel to work witha apache but I was getting a new error:
MissingSourceFile (no such file to load -- sqlite3):
Turns out this is due rails trying to use a db driver for sqlite3, need to update the database.yml to use mysql..
Old database.yml
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000
If you change the database.yml you MUST restart mongrel
mongrel_rails stop
to start mongrel
mongrel_rails start -c /var/www/tools4domains.com/test -P log/mongrel.pid -l log/mongrel.log -e production -d -a 127.0.0.1 -p 8000
mongrel_rails start -c /var/www/tools4domains.com/test -P log/mongrel.pid -l log/mongrel.log -e development -d -a 127.0.0.1 -p 8000
New database.yml
# MySQL (default setup). Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On MacOS X:
# gem install mysql -- --include=/usr/local/lib
# On Windows:
# There is no gem for Windows. Install mysql.so from RubyForApache.
# http://rubyforge.org/projects/rubyforapache
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
socket: /var/lib/mysql/mysql.sock
database: rails_dev
username: root
password:
host: localhost
# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
adapter: mysql
socket: /var/lib/mysql/mysql.sock
database: rails_test
username: root
password:
host: localhost
production:
adapter: mysql
socket: /var/lib/mysql/mysql.sock
database: rails_prod
username: root
password:
host: localhost
*** Next thing is that if you change a view or anything the code change isn't reflected ****
I'm noticing that I can't get mongrel to stop and start gracefully :(
So I try:
mongrel_rails start -c /var/www/tools4domains.com/test -P log/mongrel.pid -l log/mongrel.log -e development -d -a 127.0.0.1 -p 8000
IT WORKS!
I'm not sure why on a windows box the views are help.html.erb etc. I changed them via mv to help.rhtml no problem I'm not sure what causes them to change like that?
** SSH Altering the default ssh time out ***
find / -name sshd_config
LoginGraceTime
The server disconnects after this time if the user has not successfully logged in. If the value is 0, there is no time limit. The default is 120 seconds.
-Caleb
No go:
[root@host ~]# sudo /sbin/service sshd start
Starting sshd:/etc/ssh/sshd_config: line 115: Bad configuration option: ConnectTimeout
/etc/ssh/sshd_config: terminating, 1 bad configuration options
At the end of this tutorial you will have a full scale ruby-on-rails production environment running clustered through the mongrel ruby application platform, load balanced by reversed proxied by Apache.
Start with an install of Fedora 7 onto your machine.
Installing Fedora Packages
As root
CODE
yum install httpd mysql-server mysql
yum install install ruby ruby-devel ruby-irb ruby-libs ruby-rdoc ruby-ri rubygems
Installing Ruby Packages
If any of the installs say they cant find the package, try again.
Also as root
CODE
#install rails
gem install rails --include-dependencies
#installing mongrel
gem install gem_plugin daemons capistrano --include-dependencies ROR(Ruby On Rails)
0 comments:
Post a Comment