系统:Centos8.0
预安装:
mysql 5.5.62
, php7.4.21
, nginx1.20.1
):wget http://soft.vpser.net/lnmp/lnmp1.8.tar.gz -cO lnmp1.8.tar.gz && tar zxf lnmp1.8.tar.gz && cd lnmp1.8 && ./install.sh lnmp
yum install -y git
部署命令:(在root
用户下)
git clone https://github.com/linkscx/qluoj
cd qluoj
vim config/db.php #修改mysql配置,主要是修改密码
./yii install
useradd -m -u 1536 judge #创建一个用于判题的用户
yum install mysql-devel #安装编译的依赖
cd judge
make
./dispatcher
cd ../polygon
make
./polygon
配置nginx.conf
server {
listen 80;
listen [::]:80 default_server;
# 填qluoj/web目录的位置
root /home/wwwroot/qluoj/web;
index index.php;
server_name _;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
# 填find / -name "*php*.sock"的位置
fastcgi_pass unix:/tmp/php-cgi.sock;
}
}
原因:php默认禁用部分函数
解决方法:修改php.ini
,从中找到
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
在disable_functions
前面加分号; 注释掉这句代码
原因:缺少libmysqlclient-dev
和libmysql++\-dev
编译的依赖
解决方法:
yum install mysql-devel
解决方法:关闭防跨目录设置
1.如果网站根目录下有.user.ini
,进入到网站根目录
chattr -i .user.ini
rm -f .user.ini
需要重启php-fpm
2.找到 /usr/local/nginx/conf/fastcgi.conf
里面的 fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
在该行行前添加 #
或删除改行,需要重启nginx
解决方法: 编辑 ./judge/config.ini
和 ./polygon/config.ini
取消注释这句话,
# OJ_MYSQL_UNIX_PORT=/var/lib/mysql/mysql.sock #MySQL 连接套接字路径
并且把OJ_MYSQL_UNIX_PORT
路径换成如下find
命令找到的的结果
find / -name "mysql.sock"
错误信息:
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find -lm
/usr/bin/ld: cannot find -lstdc
collect2: error: ld returned 1 exit status
解决方法:安装glibc-static
和stdlibc++\-static
静态链接
wget http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/glibc-static-2.28-151.el8.x86_64.rpm
rpm -ivh glibc-static-2.28-151.el8.x86_64.rpm --nodeps
wget http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/libstdc++-static-8.4.1-1.el8.x86_64.rpm
rpm -ivh libstdc++-static-8.4.1-1.el8.x86_64.rpm --nodeps
解决方法:
1.把网站根目录下的ilbraries/testlib.h
复制到gcc
头文件目录中(一般是/usr/include)
cp libraries/testlib.h /usr/include/testlib.h
2.找到安装的php
根目录下的etc/php-fpm.conf
配置文件,一般是在/usr/local/php/etc/php-fpm.conf
,可以用find
命令查找
在最后面添加
env[PATH] = /usr/local/bin:/usr/bin:/bin
重启php-fpm
,在前端页面中重新保存spj程序