ผลต่างระหว่างรุ่นของ "ฐานความรู้"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
แถว 44: แถว 44:
 
== Installing Grader Web Interface ==
 
== Installing Grader Web Interface ==
 
: ''See [[Installing Grader Web Interface]]''
 
: ''See [[Installing Grader Web Interface]]''
=== Installing HAML ===
 
The grader makes use of HAML. So you need to install it first.
 
gem install haml --no-ri
 
 
=== Checking out the Grader Web Interface ===
 
First, make a directory that will contain all the grader files. In my case, I make a directory called "grader" inside my home directory.
 
mkdir ~/grader
 
Inside the directory, you check out the web interface.
 
svn co http://theory.cpe.ku.ac.th/grader/web/tags/0.1 ~/grader/web
 
 
=== Setting up the Database ===
 
cd ~/grader/web/config
 
cp database.yml.SAMPLE database.yml
 
Then, edit '''<tt>database.yml</tt>''' so that it reflects the database setting of your machine.
 
 
'''Note:''' In Ubuntu, the database socket is not located at '''<tt>/tmp/mysql.sock</tt>''' as it is in other distributions. You need to add one extra line in database.yml to tell rails this:
 
  adapter: mysql
 
  '''socket: /var/run/mysqld/mysqld.sock'''
 
  database: ioi
 
  username: ioi
 
  password: whateverpassword
 
  host: localhost
 
 
Next, you do the migration:
 
cd ~/grader/web
 
rake db:migrate
 
 
Check your MySQL to see if the tables actually appear.
 
 
=== Test the Grader for the First Time ===
 
Then, run the server
 
ruby script/server
 
 
Go check '''<tt>http://localhost:3000</tt>'''. You can login as '''<tt>root</tt>''' and the password is '''<tt>ioionrails</tt>'''. You should change the password immediately and logout.
 
 
=== Set Up Mongrel Cluster ===
 
Have mongrel create a config file for you:
 
mongrel_rails cluster::config -e production -p 5000 -a 127.0.0.1 -N 2 -c ~/grader/web
 
 
The config file is located at '''<tt>~/grader/web/config/mongrel_cluster.yml</tt>'''. It should look like this:
 
---
 
cwd: /home/ioi/grader/web
 
log_file: log/mongrel.log
 
port: "5000"
 
environment: production
 
address: 127.0.0.1
 
pid_file: tmp/pids/mongrel.pid
 
servers: 2
 
 
Next, start the server.
 
cd /~grader/web
 
mongrel_rails cluster::start
 
 
See if it works by checking out http://localhost:5000/.
 
  
 
==Judge==
 
==Judge==
 
: ''see main article [[Installing and configuring Judge]]''
 
: ''see main article [[Installing and configuring Judge]]''

รุ่นแก้ไขเมื่อ 15:25, 16 มีนาคม 2551

Apache2 on Ubuntu

Enabling User Directory

This is how to set up Apache2 on Ubuntu so that, when hxxp://server/~username is accessed, the browser returns the content in /home/username/public_html.

First, user directory is now a mod in Ubuntu's apache2. If you have not installed the mod, then execute the following command:

sudo a2enmod userdir

Second, edit /etc/apache2/apache2.conf and add the following lines:

<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>

Third, execute the following command:

cd /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/userdir.conf userdir.conf
sudo ln -s /etc/apache2/mods-available/userdir.load userdir.load

Forth, restart your apache2:

sudo /etc/init.d/apache2 restart

Rails Deployment with Mongrel on Ubuntu Guide

This guide plagiarizes Punneng's Rail::Deployment (Ubuntu - Apache - Subversion - Mongrel - Capistrano) article.

This guide assumes that you already have rails installed.

Create a New User

For each one application, you should create a new user for exclusive use by the application. Put the user in the www-data group.

useradd username
usermod -g www-data username

Edit /etc/sudoers and add:

username ALL = (ALL) ALL

Install Mongrel and Mongrel Cluster

sudo gem install daemons mongrel mongrel_cluster

Install Your Rails Application Somewhere

Well, this step is totally up to you.

Installing Grader Web Interface

See Installing Grader Web Interface

Judge

see main article Installing and configuring Judge