Articles tagged with "tamu"
Ruby/Rails on sy*.cs.tamu.edu
I was asked to install Ruby on Rails on a windows server, to be used for class projects. I went with the mongrel via apache approach. I was originally going to install it on IIS runing under FastCGI, but decided against it for a few reasons:
- FastCGI is really only appropriate for a production environment. It’s hard to debug, and this machine is probably going to be used for development, testing, and production.
- Its relatively unstable. FastCGI on IIS is still an awkward combination, and was bound to cause headaches.
- The apache/mongrel approach keeps the two very separate, so it’s easier to find problems.
- To use IIS with Mongrel, you need ISAPI_rewrite, which costs money.
I used this guide, so be sure to look it over if you have any problems.
Step 0: Downloads
Remote desktop into the install machine, and download the following:
Step 1: Install Apache & Ruby
Run the apache installer. Use ”sy
On the next page, click “Custom Install”, and change the installation to “c:\apache”, then choose next and let the installer finish.
Now open the Ruby installer. The default install should be fine.
Step 2: Start the Apache Daemon
Enter the following into a command shell:
cd \
cd apache\apache2\bin
apache –k install
The apache service icon should appear in the task bar.
Step 3: Install Rails & Mongrel
Install the rails, redcloth, and mongrel gems:
gem install rails mongrel mongrel_service redcloth -y
Make sure to choose the win32 option every time it asks.
Step 4: Configure Apache
From the start menu, navigate to “All Programs”->”Apache HTTP Server X”->”Configure Apache Server”->”Edit The Apache http.conf Configuration file”.
Change the line with:
Listen 8080
to:
Listen 80
Note: Binding to port 80 will only work if you don’t have another webserver running on the machine. If you think you might have IIS or something else running on port 80, run:
netstat -a
If you see something like the following:
TCP sy02:http sy02.cs.tamu.edu:0 LISTENING
You may need to change to an open port number. I suggest 81.
Save the file, then start apache using the icon on the bottom right. Enter the following command(change ‘http’ to your port number):
netstat -a | find "http"
It should print out something like:
TCP sy02:http sy02.cs.tamu.edu:0 LISTENING
If you don’t see anything, you have a problem somewhere.
Step 5: Create the Rails App Folder
cd \
mkdir rails_apps
cd rails_apps
rails test_site
cd test_site
ruby script/server –e production
Point your browser to “http://localhost:3000/” ( replace 3000 with whatever port mongrel is running on.), if every thing’s working you should be at the default rails page.
Step 6: Configure Apache to Proxy to Mongrel
Run the following from the command shell:
cd \
cd apache\apache2\conf
(
echo LoadModule proxy_module
modules/mod_proxy.so
echo LoadModule proxy_http_module
modules/mod_proxy_http.so
echo ProxyRequests Off
echo ^<Proxy *^>
echo Order deny,allow
echo Allow from all
echo ^</Proxy^>
) >> http-proxy.conf
(
echo .
echo Include conf/http-proxy.conf
) >> httpd.conf
this should create a http-proxy.conf file in apache’s conf directory. Next run:
set APP_NAME=test_site
set PORT=3000
(
echo .
echo Alias /%APP_NAME% "c:/rails_apps/%APP_NAME%/public"
echo ^<Directory "c:/rails_apps/%APP_NAME%/public"^>
echo Options Indexes FollowSymLinks
echo AllowOverride none
echo Order allow,deny
echo Allow from all
echo ^</Directory^>
echo .
echo ProxyPass /%APP_NAME%/images !
echo ProxyPass /%APP_NAME%/stylesheets !
echo ProxyPass /%APP_NAME%/javascripts !
echo ProxyPass /%APP_NAME%/ http://127.0.0.1:%PORT%/
echo ProxyPass /%APP_NAME% http://127.0.0.1:%PORT%/
echo ProxyPassReverse /%APP_NAME%/ http://127.0.0.1:%PORT%/
) >> http-proxy.conf
Restart apache, browse to “http://localhost/test_site/”, and you should be at your default page.
Step 7: Install Proxy Plugin
Apparently rails needs some help rewriting URL’s to work with the proxy server, so you need to install a rails plugin:
cd \
cd rails_apps\test_site
ruby script/plugin install http://svn.napcsweb.com/public/plugins/reverse_proxy_fix/branches/rails123
http://localhost/test_site
cd vendor\plugins\rails123\lib
echo BASE_URL="http://localhost/test_site" >> config.rb
Step 8: Start mongrel as a service
This will start a mongrel server as a windows service:
mongrel_rails service::install -N test_site
net start test_site
And that should do it. If everything went right, you should get the default rails page again.
Ruby/Rails on unix.cs.tamu.edu
I wanted to host a ruby on rails website on my csnet account, but there were some problems. The server is running an older version of ruby without gems installed. Also, it looks like apache is not compiled with fastcgi. To get around this, I had to install ruby and gems locally, and proxy the requests to a mongrel server. There are a bunch of how-to’s on installing ruby/rails, but I ran into a few hiccups due csnet’s configuration. This guide is mostly gathered from here.
Step 0: Environment Setup
First off, ssh into your unix account. There’s information on how to do this over at cs helpdesk.
I’m used to the bash shell, but the default is tcsh. If you have no idea what difference is, I recommend switching to bash:
echo "exec bash --login" >> ~/.login
Log out and log back in; the prompt should have changed to something like bash-3.00. I recommend changing the prompt to something more usefull:
echo "PS1=\"\[\033[0;31m\][\u@\h \W]#\[\033[0m\] \"" >> ~/.bash_profile
Log in/out or source the .bash_profile file and the prompt should be updated.
Because we are building and executing everything locally, we need to add a few folders:
cd ~/
mkdir -pv soft run www log
cd ~/run
mkdir -pv bin etc include lib man share
Next, we need to set the RUN variable and update PATH:
cat >>${HOME}/.bashrc <<eof
export RUN="\${HOME}/run"
export PATH="\${RUN}/bin:\${PATH}"
export LD_LIBRARY_PATH=\${RUN}/lib:\${LD_LIBRARY_PATH}
export LD_RUN_PATH=\${RUN}/lib:\${LD_RUN_PATH}
eof
echo "source ~/.bashrc" >> ${HOME}/.bash_profile
Step 1: Install Readline
Ruby requires Readline, so we need to install it locally before compiling ruby:
cd ${HOME}/soft
wget ftp://ftp.cwru.edu/pub/bash/readline-5.2.tar.gz
tar xvzf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=${RUN}
make && make install
Step 2: Install Ruby
Download, compile, and install ruby locally:
cd ${HOME}/soft
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar xvzf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure --prefix=${RUN} --with-readline-dir=${RUN}
make && make install
This will tell ruby to use use the local libs folders:
cat >> ${HOME}/.bashrc <<eof
# ruby library search path
export RUBYLIB=\${RUN}/lib/ruby:\${RUN}/lib/rubyext
eof
Logout/in then make sure ruby is pointing to ~/run/bin/ruby and is the version you installed (1.8.6):
which ruby && ruby -v
It should print something like:
/user/brb1763/run/bin/ruby
ruby 1.8.6 (2007-03-13 patchlevel 0) [sparc-solaris2.8]
Step 3: Install RubyGems
Download and install rubygems:
cd ${HOME}/soft
wget http://rubyforge.org/frs/download.php/20989/rubygems-0.9.4.tgz
tar xzvf rubygems-0.9.4.tgz
cd rubygems-0.9.4
ruby setup.rb config --prefix=$RUN
ruby setup.rb setup
ruby setup.rb install
Verify rubygems is installed:
which gem && gem -v
You should see:
/user/brb1763/run/bin/gem
0.9.4
Step 4: Install Rails
Install rails and mongrel:
gem install rails mongrel --no-rdoc --no-ri -y
If you are prompted to choose a gem, select the ones that end with (ruby).
Verify rails is installed:
which rails && rails -v
That should print:
/user/brb1763/run/bin/rails
Rails 1.2.3
Step 5: Create a Test Site
Create a test rails site in your www dir:
cd ~/www
rails test_site
Start a mongrel server to server your site:
cd ~/www/test_site
mongrel_rails start -d -p 3042 -l ~/log/mongrel.log
The port number (3042 in this case) should be a random but unique port number. If you are local or have a vpn connection, browse to http://unix.cs.tamu.edu:<your port number>/, it should serve the ruby on rails placeholder page.
Step 6: Proxy Requests to Your Mongrel Server
Set the mod_proxy stuff in your .htaccess file:
mkdir -pv ${HOME}/web_home/test_site
cd ${HOME}/web_home/test_site
cat >> .htaccess <<eof
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) http://unix.cs.tamu.edu:<your port number>/$1 [P]
eof
chmod 644 .htaccess
Don’t forget to set the port number. Browse to http://students.cs.tamu.edu/<your username>/test_site/, if you see the placeholder page, you’re good to go.