Docker is required for secure code execution. While Wecode can technically use native compilation tools, this poses a severe security risk and is planned to be removed.
Docker CE (Community Edition) installed and running
Web server user must have permission to manage Docker containers
Best for development or simple deployments where the entire application is in one directory.
1
Clone the Repository
cd /var/wwwgit clone https://github.com/truongan/wecode.gitcd wecode
2
Create Database
Create a database and user for Wecode:For MySQL:
CREATE DATABASE wecode;CREATE USER 'wecode_user'@'localhost' IDENTIFIED BY 'your_password';GRANT ALL PRIVILEGES ON wecode.* TO 'wecode_user'@'localhost';FLUSH PRIVILEGES;
-a Admin username (default: "abc")-e Admin email (default: "[email protected]")-u Database username (required)-d Database name (defaults to username)-p Database password (required)-s Site URL with http:// or https:// (required)-h Show help message
4
What install.sh Does
The script automatically:
Downloads and verifies Composer
Runs composer install to install PHP dependencies
Copies .env.example to .env
Updates .env with your database credentials and site URL
Generates Laravel application key with php artisan key:generate
Runs database migrations with php artisan migrate:refresh
Seeds initial data with php artisan db:seed --class=installation_seeding
Creates admin users with php artisan add_admin
The script creates two admin accounts: one default account (truonganpn) and your custom account.
-i Install directory (default: current directory)-o Public directory for index.php (default: ../public_html)-u Database username (required)-p Database password (required)-d Database name (defaults to username)-n Site name to display (default: "Wecode-Judge")-a Default admin username-h Show help message
The last argument is the base URL (required if -n not specified).
4
What setup.sh Does
This script:
Clones the Wecode repository to the install directory
Creates symbolic links from public directory to install/public
Calls install.sh to complete the installation
This method keeps your source code separate from the web-accessible directory, improving security.
If you prefer to configure the database manually instead of using the install scripts:
1
Copy Environment File
cp .env.example .env
2
Edit .env File
Open .env and configure database settings:
.env
APP_NAME=WecodeAPP_ENV=productionAPP_KEY= # Will be generatedAPP_DEBUG=falseAPP_URL=http://your-domain.comDB_CONNECTION=mysql # or pgsql for PostgreSQLDB_HOST=127.0.0.1DB_PORT=3306 # or 5432 for PostgreSQLDB_DATABASE=wecodeDB_USERNAME=wecode_userDB_PASSWORD=your_password
CRITICAL SECURITY STEP: You must move the assignments and tester folders outside the public directory.
1
Move Sensitive Folders
# Create secure directorysudo mkdir -p /var/wecode-data# Move folders from installation directorysudo mv /var/www/wecode/tester /var/wecode-data/sudo mv /var/www/wecode/assignments /var/wecode-data/# Set ownership to web server usersudo chown -R www-data:www-data /var/wecode-data# Set permissions (must be writable by PHP)sudo chmod -R 755 /var/wecode-datasudo chmod -R 775 /var/wecode-data/assignmentssudo chmod -R 775 /var/wecode-data/tester
The assignments folder will store all submitted code files. The tester folder contains test cases and grading scripts. Both must be writable by the web server user.
2
Update Folder Paths in Wecode
Login to Wecode as admin
Navigate to Settings page
Update the paths:
Assignments folder: /var/wecode-data/assignments
Tester folder: /var/wecode-data/tester
Save settings
3
Set File Permissions
Ensure proper permissions on the installation directory:
# Verify www-data is in docker groupgroups www-data# If not, add itsudo usermod -aG docker www-data# Restart web serversudo systemctl restart apache2 # or nginx + php-fpm# Test as www-data usersudo -u www-data docker ps
Enabling shell_exec() has security implications. Ensure Wecode is the only application running on this server, or implement additional security measures.