Skip to main content

Quick Installation

This guide will help you get Wecode installed and running quickly. For detailed installation instructions, see the Installation Guide.

Prerequisites

Before you begin, ensure your Linux server has:
1

Check PHP Version

Wecode requires PHP 8.0.2 or higher. Verify your PHP version:
php -v
PHP must have permission to run shell commands using shell_exec(). Verify this is enabled:
php -r "echo shell_exec('php -v');"
2

Verify Docker Installation

Docker is required for secure code execution. Check if Docker is installed:
docker --version
If not installed, follow the Docker installation guide.
3

Check Database

Ensure MySQL or PostgreSQL is installed and running:
# For MySQL
mysql --version

# For PostgreSQL
psql --version
Create a database for Wecode:
# MySQL
mysql -u root -p -e "CREATE DATABASE wecode;"

# PostgreSQL
createdb wecode
4

Install Composer

Composer will be installed automatically by the install script, but you can install it manually if needed:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Installation Steps

1

Clone the Repository

Download the latest release from GitHub:
cd /var/www
git clone https://github.com/truongan/wecode.git
cd wecode
2

Run the Install Script

Execute the automated installation script with your database credentials:
./install.sh -u your_db_user -d wecode -p your_db_password -s "http://your-domain.com"
Script Options:
  • -u: Database username (required)
  • -d: Database name (defaults to username if not specified)
  • -p: Database password (required)
  • -s: Site URL with http:// or https:// (required)
  • -a: Admin username (optional, defaults to “abc”)
  • -e: Admin email (optional, defaults to “[email protected]”)
The install script will automatically:
  • Download and install Composer
  • Install PHP dependencies
  • Copy and configure .env file
  • Generate application key
  • Run database migrations
  • Create an admin user
3

Configure Web Server

Point your web server to the public directory:For Apache:
<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot /var/www/wecode/public
    
    <Directory /var/www/wecode/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
For Nginx:
server {
    listen 80;
    server_name your-domain.com;
    root /var/www/wecode/public;
    
    index index.php;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
4

Configure Docker Permissions

Allow the web server user to manage Docker:
# Add www-data (or your web server user) to the docker group
sudo usermod -aG docker www-data

# Restart web server
sudo systemctl restart apache2  # or nginx
This step is critical for Wecode to execute submitted code in Docker containers.
5

Secure Important Folders

Move sensitive folders outside the public directory:
# Create secure directory
sudo mkdir -p /var/wecode-data

# Move folders
sudo mv tester /var/wecode-data/
sudo mv assignments /var/wecode-data/

# Set permissions
sudo chown -R www-data:www-data /var/wecode-data
sudo chmod -R 755 /var/wecode-data
The assignments folder will contain all student submissions. It must be outside the public web directory to prevent unauthorized access.
After moving the folders, update the paths in the Wecode Settings page (accessible after login).

First Login

1

Access the Web Interface

Open your browser and navigate to your Wecode URL:
http://your-domain.com
2

Login as Admin

Use the credentials you specified during installation:
  • Username: The value you provided with -a flag (default: “abc”)
  • Password: The value you provided with -p flag
  • Email: The value you provided with -e flag (default: “[email protected]”)
3

Configure Folder Paths

Go to Settings and update the paths for:
  • Tester folder: /var/wecode-data/tester
  • Assignments folder: /var/wecode-data/assignments

Create Your First Assignment

1

Navigate to Assignments

From the admin dashboard, click on Assignments or New Assignment.
2

Configure Assignment Details

Fill in:
  • Assignment name: e.g., “Hello World”
  • Description: Upload a PDF or write in Markdown/HTML
  • Start/End dates: When students can submit
  • Allowed languages: C, C++, Java, Python, etc.
3

Set Up Test Cases

Choose your grading method:Output Comparison:
  • Provide input and expected output pairs
  • Wecode will run the code and compare output
Tester Code:
  • Upload custom test code
  • More flexible for complex validation
4

Configure Limits

Set resource limits:
  • Time limit: Maximum execution time (e.g., 1 second)
  • Memory limit: Maximum memory usage (e.g., 256 MB)
5

Publish the Assignment

Save and publish the assignment to make it visible to students.

Submit Your First Code

1

Login as Student

Create a test student account or login with a student account.
2

Select Assignment

Navigate to the assignment you just created.
3

Write and Submit Code

Write your solution code or upload a source file, then click Submit.
4

View Results

After the judge processes your submission, you’ll see:
  • Status: Accepted, Wrong Answer, Time Limit Exceeded, etc.
  • Test case results: Which test cases passed/failed
  • Execution time and memory: Resource usage
  • Score: Points earned

Next Steps

Installation Guide

Learn about advanced installation options and troubleshooting

Security Guide

Secure your Wecode installation
For production environments, make sure to:
  • Use HTTPS with a valid SSL certificate
  • Set APP_ENV=production in .env
  • Set APP_DEBUG=false in .env
  • Configure proper firewall rules
  • Regular backups of database and assignment files

Build docs developers (and LLMs) love