在Ubuntu虚拟机上搭建青岛OJ

源码地址为:https://github.com/QingdaoU/OnlineJudge

可参考的文档为:https://github.com/QingdaoU/OnlineJudgeDeploy/tree/2.0

我的虚拟机上之前没有安装任何东西,就是依靠下面命令完成搭建青岛OJ

一、安装所依赖的环境

sudo apt-get update && sudo apt-get install -y vim python-pip curl git

sudo apt-get install docker-compose

二、使用Git克隆项目并完成部署

git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy

sudo docker-compose up -d(root用户使用该命令)或sudo -E docker-compose up -d(非root用户使用该命令)


/*
我是用的  sudo docker-compose up -d  这个命令
*/

有可能虚拟机之前并没有安装过git这个命令,我们可以通过下面命令安装

sudo apt-get install git
//或者
sudo apt install git

三、出现问题

1、

使用docker时报错“net/http: TLS handshake timeout”

2、

Ubuntu中Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend)问题的解决

3、

遇到第1个问题要修改Ubuntu文件内容,但是可能会涉及权限不够问题,这个时候一般就要在命令行下用vi命令修改文件内容

vi、wc、gzip、bzip2、tar、yum安装、dpek、用户信息操作等命令

4、

错误信息:ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

解决办法:
docker-compose up -d(root用户使用)
非root执行会出现这个异常

非root应该执行这条命令
sudo -E docker-compose up -d

如果一直提示这个问题可以重启虚拟机试试。。。我就是这样试过的。。。

5、

错误信息:ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/


解决办法:修改docker-compose.yml中的version由3改为2

四、登录OJ

用户名和密码分别是:root和rootroot

浏览器默认打开为:http://127.0.0.1

回送地址:127.0.0.1。 也是本机地址,等效于localhost或本机IP。一般用于测试使用。例如:ping 127.0.0.1来测试本机TCP/IP是否正常。

五、在自己主机访问这个虚拟机上的OJ

我的虚拟器版本是:VMware Workstation 15 Player

好多人处理这个问题都是要设置网络编辑器网络适配器

我搜了半天有人说Player是没有网络编辑器的

 谁能理解我此时内心的痛。。。。。。(此处略去一万字)

我给找了几个看起来还可以的博客(都是解决   “这个让自己主机访问这个虚拟机上的OJ”   这个问题的)

https://blog.csdn.net/qq_17534301/article/details/80925503

https://jingyan.baidu.com/article/46650658e1cc84f549e5f806.html

Ubuntu上查看ip地址用

ifconfig -a

如果没有安装ifconfig这个命令的话会提示你安装哪个东西,你照着安装就可以了

解释:

ens32 表示第一块网卡

inet addr 用来表示网卡的IP地址,此网卡的 IP地址是192.168.150.131

更多解释看下面这个链接

https://blog.csdn.net/dodod2012/article/details/80422729

总的来说我还是没有解决这个问题,等我解决之后我会更新博客的。。。

猜你喜欢

转载自www.cnblogs.com/kongbursi-2292702937/p/12128973.html