Building VirtualJudge under Ubuntu14.04

Source: Internet
Author: User
As required by the training team, we decided to set up our own OnlineJudge and VirtualJudge. The establishment of OJ was very smooth, but I encountered quite a number of problems during the establishment of Vjudge. Helpless, among the flood of blog posts, there are quite a few excellent products, and most of them are reprinted and reposted. The same content is not nutritious, and there are even fewer blog posts on Vjudge construction, I have not been able to build it for two consecutive days. With the help of jcf, I finally solved various problems and successfully set up VirtualJu.

As required by the training team, we decided to set up our own OnlineJudge and Virtual Judge.

The establishment of OJ was very smooth, but I encountered quite a number of problems during the establishment of Vjudge.

Helpless, among the flood of blog posts, there are quite a few excellent products, and most of them are reprinted and reposted. The same content is not nutritious, and there are even fewer blog posts on Vjudge construction, I have not been able to build it for two consecutive days. With the help of jcf, I finally solved various problems and successfully set up Virtual Judge.

(I had a hard time talking about it: MB of war files were dropped during packaging, which caused me to spend two days)

However, for those who are not familiar with Linux and JSP, this article may be too simple. However, I have no better reference to blog posts or documents. Therefore, I decided to spend some time to complete this vacancy. This article was born.

1. Preparations: 1.1 A Linux System
For the sake of the field competition, I have always been using ubangtu. Here I used Ubuntu14.04 Desktop 64bit for testing. Of course, it would be better to select Server. The system installation will not be described in detail. Please Select Server version as the Server.
1.2 update source

Before building the environment, make sure that your source is effective and the speed is high,
We recommend that you select a domestic source 14.04 LTS update source.

Sudo gedit/etc/apt/sources. list overwrites the original source and saves it. Finally, execute sudo apt-get update to update the source.
1.3 prepare necessary documents
We need to download these files (some links require FQ to be accessed ):
1. *. SQL https://gist.github.com/trcnkq/a3cf7004759d41d79eb72.http_client.json https://gist.github.com/trcnkq/7a5deff639ff994751383.remote_accounts.json https://gist.github.com/trcnkq/e9dac7eea72d2b7819494.virtual judge source file https://github.com/trcnkq/virtual-judge

If FQ is not available, use the backup link Vjudge to build it.

Or:

------------------------------------------ Split line ------------------------------------------

FTP address: ftp://ftp1.linuxidc.com

Username: ftp1.linuxidc.com

Password: www.linuxidc.com

Build Virtual Judge in LinuxIDC.com/Ubuntu 14.04/February

Download Method see http://www.linuxidc.com/Linux/2013-10/91140.htm

------------------------------------------ Split line ------------------------------------------

2. install and configure JDK 2.1 in the necessary environment
First download JDK, address: https://jdk7.java.net/download.html Attention System is 32-bit or 64-bit
1) decompress the downloaded file tar-xzvf jdk1.7.0 _ 80
2) Move the folder to the specified directory. sudo mkdir/usr/lib/jvmsudo mv jdk1.7.0 _ 80 // usr/lib/jvm/
3 .) set the environment variable sudo gedit/etc/profile to add the following content at the end of the file: export JAVA_HOME =/usr/lib/jvm/jdk1.7.0 _ 80 export JRE_HOME =$ {JAVA_HOME}/jreexport CLASSPATH =.: $ {JAVA_HOME}/lib :$ {JRE_HOME}/libexport PATH =$ {JAVA_HOME}/bin: $ PATH

4) Make the modification take effect: sudo source/etc/profile at this time, enter java-version on the terminal to view the current JDK version, and the JDK configuration is complete.

2.2 install and configure Redis
1) download and install Redis: wget http://download.redis.io/releases/redis-2.8.9.tar.gz tar xvzf redis-2.8.9.tar.gz cd redis-2.8.9/makesudo make install
2 .) configure init Script: wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-serverwget https://github.com/ijonas/dotfiles/raw/master/etc/redis.confsudo mv redis-server/etc/init. d/redis-serversudo chmod + x/etc/init. d/redis-serversudo mv redis. conf/etc/redis. conf
3 .) before initializing the user and Log Path to start Redis for the first time, we recommend that you create a user for Redis separately, create the sudo useradd redissudo mkdir-p/var/lib/redissudo mkdir-p/var/log/redissudo chown redis data and log folders. redis/var/lib/redissudo chown redis. redis/var/log/redis
4) set the boot automatic boot, shutdown automatic shutdown update-rc.d redis-server defaults
5) start Redis:/etc/init. d/redis-server start
2.3 install and configure Maven3
1) after installing Maven3ubuntu12.04 through apt-get, you can directly use apt-get to obtain sudo apt-get install maven-y

After installation, enter sudo su to enter root
Use mvn-v to view the Maven version, for example:
After the installation is complete, the default JDK version may be changed.
Because Maven3 is installed along with openjdk.

2 .) modify the system's default jdkupdate-alternatives -- install/usr/bin/java/usr/lib/jvm/jdk1.7.0 _ 80/bin/java 300update-alternatives -- install/usr/bin/javac /usr/lib/jvm/jdk1.7.0 _ 80/bin/javac 300update-alternatives -- config javaupdate-alternatives -- config javac

Use java-version to check again. The JDK version has been changed.

2.4 install and configure Tomcat 7
1 .) apt-get install tomcat7: sudo apt-get install tomcat7-y tomcat7 will be installed in the/var/lib/tomcat7/directory by default. After installation, enter localhost in the browser: 8080 check whether the installation is successful. If yes, the installation is successful.

2) After installing the tomcat7-admin to install it, we also need to install a tomcat7-adminsudo apt-get install tomcat7-admin
3) Modify account: After the installation is complete, we go to the Tomcat 7 conf directory to modify the tomcat-users.xml file cd/var/lib/tomcat7/conf/gedit tomcat-users.xml I'm using here is
  
  
  

4) restart tomcat: sudo/etc/init. d/tomcat7 restart

Open tomcat again in the browser
Click manager webapp and log in with the user we just created

5) modify the default JDK version of JDK to check the Server Information of Tomcat 7. The version may not be our own jdk version. Here we need to modify the JDK version used by tomcat. This step is very important, otherwise there will be many problems.

Sudo gedit/etc/default/tomcat7 Add the following content: JAVA_HOME =/usr/lib/jvm/jdk1.7.0 _ 80 restart tomcat7 again: sudo/etc/init. d/tomcat7 restart

OK. The JDK version of Tomcat 7 has been modified.

2.5 install Mysql
During the installation of sudo apt-get install mysql-server-y, you are required to enter the Database Password. Here, I directly use 123456 and enter the password twice in a row. Go to the database and test mysql-u root-p.

After you enter the password, it indicates that mysql is successfully installed:

Now, all the environments required to build Virtual Judge have been set up!

3. project code implementation

Prepare the four files, that is, the four files downloaded at the beginning:

3.1 Vjudge Packaging
Go to the virtual-judge-master Directory: cd virtual-judge-master/use Maven to package Virtual Judge: mvn clean package

There will be a vjudge. war file, which is the Virtual Judge we have packaged.
Copy the war file to the webapps directory of Tomcat 7.

The package process may be quite long, especially in the case of poor network conditions. If you don't want to wait too long, you can download this file directly.

After you put it in the webapps directory, a vjudge folder is automatically generated. If the folder is not generated, You can decompress it on your own.

3.2 edit the remote_accounts.json File

Add the submission accounts of each OJ to remote_accounts.json.

3.3 edit the config. properties File

If you do not need a proxy or VPN to access OJ outside China, keep the ["direct"] in http_client.json.

3.4 simple deployment of vjudge

Put the remote_accounts.json and http_client.json files in the specified folder.
Put it in the/var/lib/tomcat7/webapps/vjudge/directory.

sudo mv http_client.json /var/lib/tomcat7/webapps/vjudge/sudo mv remote_accounts.json /var/lib/tomcat7/webapps/vjudge/

Change the config. properties file in the/webapps/vjudge/WEB-INF/classes/directory
Change the absolute path of remote_accounts.json and http_client.json to the correct path.

cd /var/lib/tomcat7/webapps/vjudge/WEB-INF/classes/sudo gedit config.properties

PS: If your database password is not 123456, you also need to modify the above root password. The default value is 123456.

3.5 create a vhoj Database

Create a new database in mysql named vhoj,
And import the table vhoj_20141109. SQL (maybe my version is slightly old ).

mysql -u root -p  create database vhoj;  exit; 

mysql -h localhost -u root -p vhoj < vhoj_20141109.sql  

Finally, restart Tomcat 7 to enter the manager
View the Application. You can see that the vjudge is in the running state.

4. Completed Vjudge

Enter localhost: 8080/vjudge in the address bar to enter the vjudge that is successfully built:

By now, Virtual Judge has been successfully built, just enjoy it!

References: http://www.linuxidc.com/Linux/2015-09/123240.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-09/123243.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.