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

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
 
(ไม่แสดง 38 รุ่นระหว่างกลางโดยผู้ใช้ 2 คน)
แถว 24: แถว 24:
 
  sudo /etc/init.d/apache2 restart
 
  sudo /etc/init.d/apache2 restart
  
== Installing Grader Web Interface ==
+
== Rails Deployment with Mongrel on Ubuntu Guide ==
=== Installing HAML ===
+
This guide plagiarizes Punneng's [http://weblog.punneng.com/2007/5/5/rails-deployment-ubuntu-apache-subversion-mongrel-capistrano Rail::Deployment (Ubuntu - Apache - Subversion - Mongrel - Capistrano)] article.
The grader makes use of HAML. So you need to install it first.
 
gem install haml --no-ri
 
  
=== Checking out the Grader Web Interface ===
+
This guide assumes that you already have rails installed.
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/trunk ~/grader/web
 
  
=== Setting up the Database ===
+
=== Create a New User ===
  cd ~/grader/web/config
+
For each one application, you should create a new user for exclusive use by the application. Put the user in the '''<tt>www-data</tt>''' group.
  cp database.yml.SAMPLE database.yml
+
  useradd username
Then, edit '''<tt>database.yml</tt>''' so that it reflects the database setting of your machine.
+
  usermod -g www-data username
 +
Edit '''<tt>/etc/sudoers</tt>''' and add:
 +
username ALL = (ALL) ALL
  
'''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:
+
=== Install Mongrel and Mongrel Cluster ===
  adapter: mysql
+
sudo gem install daemons mongrel mongrel_cluster
  '''socket: /var/run/mysqld/mysqld.sock'''
 
  database: ioi
 
  username: ioi
 
  password: whateverpassword
 
  host: localhost
 
  
Next, you do the migration:
+
=== Install Your Rails Application Somewhere ===
cd ~/grader/web
+
Well, this step is totally up to you.
rake db:migrate
 
  
Check your MySQL to see if the tables actually appear.
+
== Design and Specification of the Lower-Level Grading System ==
 +
: ''See [[An Online Programming Judge System]]''
  
=== Test the Grader for the First Time ===
+
== Installing Grader Web Interface ==
Then, run the server
+
: ''See [[Installing Grader Web Interface]]''
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.
 
  
 
==Judge==
 
==Judge==
===Basic directory structure===
+
: ''see main article [[Installing and configuring Judge]]''
/[judge-root]
+
== Resetting MySQL Root Password ==
  /ev                    (containing grading information for each problem)
+
This HOWTO is copied from [http://www.debian-administration.org/articles/442 here].
    /problem_1
+
First, stop your database.
      ...
+
/etc/init.d/mysql stop
    /problem_n
+
Then, start up the database in the background.
    /test_request        (containing TEST interface template for each problem)
+
/usr/bin/mysqld_safe --skip-grant-tables &
      /problem_1
+
You can now log in to MySQL without a password.
      ...
+
mysql --user=root mysql
      /problem_n
+
And you can set a new password with the following two commands:
  /result                (containing grading results)
+
mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
    /user_1
+
mysql> flush privileges;
      /problem_1
+
Once you're done with that, leave MySQL, and bring the server back up to the foreground.
        /submission_1   
+
fg
    ...
+
Kill the server with Ctrl-C. And restart the server again.
    /user_n
+
/etc/init.d/mysql start
  /scripts                (where all script are)
 
    /config              (where all config files are)
 
    /lib       
 
    /std-script          (grading scripts)
 
    /templates            (used for importing scripts)
 
    /test
 

รุ่นแก้ไขปัจจุบันเมื่อ 09:28, 5 สิงหาคม 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.

Design and Specification of the Lower-Level Grading System

See An Online Programming Judge System

Installing Grader Web Interface

See Installing Grader Web Interface

Judge

see main article Installing and configuring Judge

Resetting MySQL Root Password

This HOWTO is copied from here. First, stop your database.

/etc/init.d/mysql stop

Then, start up the database in the background.

/usr/bin/mysqld_safe --skip-grant-tables &

You can now log in to MySQL without a password.

mysql --user=root mysql

And you can set a new password with the following two commands:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
mysql> flush privileges;

Once you're done with that, leave MySQL, and bring the server back up to the foreground.

fg

Kill the server with Ctrl-C. And restart the server again.

/etc/init.d/mysql start