校园圈子论坛交友系统app小程序H5源码交付(附带部分源码)

74 阅读1分钟

数据库设计

4.1 主要数据表结构

-- 用户表 CREATE TABLE users ( id bigint unsigned NOT NULL AUTO_INCREMENT, username varchar(50) NOT NULL COMMENT '学号/工号', password varchar(255) NOT NULL, name varchar(50) NOT NULL COMMENT '真实姓名', role enum('student','teacher','admin') NOT NULL, created_at timestamp NULL DEFAULT NULL, updated_at timestamp NULL DEFAULT NULL, PRIMARY KEY (id), UNIQUE KEY users_username_unique (username) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

校园.png -- 课程表 CREATE TABLE courses ( id bigint unsigned NOT NULL AUTO_INCREMENT, course_code varchar(20) NOT NULL COMMENT '课程代码', name varchar(100) NOT NULL COMMENT '课程名称', credit tinyint unsigned NOT NULL COMMENT '学分', teacher_id bigint unsigned NOT NULL COMMENT '授课教师', class_time varchar(100) DEFAULT NULL COMMENT '上课时间', classroom varchar(50) DEFAULT NULL COMMENT '教室', PRIMARY KEY (id), KEY courses_teacher_id_foreign (teacher_id), CONSTRAINT courses_teacher_id_foreign FOREIGN KEY (teacher_id) REFERENCES users (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- 用户-课程关联表 CREATE TABLE user_courses ( user_id bigint unsigned NOT NULL, course_id bigint unsigned NOT NULL, score decimal(5,2) DEFAULT NULL COMMENT '成绩', PRIMARY KEY (user_id,course_id), KEY user_courses_course_id_foreign (course_id), CONSTRAINT user_courses_course_id_foreign FOREIGN KEY (course_id) REFERENCES courses (id), CONSTRAINT user_courses_user_id_foreign FOREIGN KEY (user_id) REFERENCES users (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

系统部署

5.1 服务器环境配置

Ubuntu服务器基础配置

sudo apt update sudo apt install -y nginx mysql-server php-fpm php-mysql php-redis redis-server

PHP扩展安装

sudo apt install -y php-curl php-gd php-mbstring php-xml php-zip

配置Nginx

sudo nano /etc/nginx/sites-available/campus.conf

示例Nginx配置

server { listen 80; server_name campus.example.com; root /var/www/campus-system/public;

index index.php index.html;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}

location ~ /\.ht {
    deny all;
}

}