原创

[大圣西游H5]游戏私服Linux端 docker部署

1.大圣西游H5私服介绍

1.分前端和服务端
2.前端就是登陆注册以及gm后台
3.服务端就是游戏数据,游戏数据在内存里。数据会持久化到mysql xntg1库里面
4.用不用docker安装思路是一样的,家里的服务器要重装系统,我这次重新用docker部署

Demo 地址 http://xy.fireflyi.com/

前端代码

服务端

1.安装环境准备

1.mysql
2.docker
3.docker-composer

2.服务端搭建

docker-composer.yml

version: '3'
services:
    dsxyserve:
        build: .
        privileged: "true"
        volumes:
            - "$PWD/dsxy:/export/app/dsxy"
        ports:
            - "5201:5201"
        restart: always
        networks:
            lsh:
                aliases:
                    - dsxyServe
networks:
    lsh:
        external: true

Dockerfile文件

FROM centos:latest

RUN yum -y update
RUN yum install -y unzip
RUN yum -y install net-tools telnet make automake zlib zlib-devel gcc-c++ libtool  openssl openssl-devel pcre pcre-devel 
RUN yum install -y mysql wget

RUN mkdir -p /export/app/dsxy

#解决error while loading shared libraries: libssl.so.10
RUN ln -s /usr/lib64/libssl.so.1.1 /usr/lib64/libssl.so.10
#解决error while loading shared libraries: libtcmalloc.so.4
RUN cd ~ && wget http://mirror.centos.org/centos/7/os/x86_64/Packages/gperftools-libs-2.6.1-1.el7.x86_64.rpm
RUN cd ~ && rpm -ivh gperftools-libs-2.6.1-1.el7.x86_64.rpm 

ENTRYPOINT ["/usr/sbin/init"]

构建启动即可
进入容器 执行 sh /export/app/dsxy/startServer.sh,正常启动则5201端口开启

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:10201           0.0.0.0:*               LISTEN      175/App             
tcp        0      0 0.0.0.0:9998            0.0.0.0:*               LISTEN      202/App             
tcp        0      0 0.0.0.0:8111            0.0.0.0:*               LISTEN      229/App             
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN      202/App             
tcp        0      0 0.0.0.0:8112            0.0.0.0:*               LISTEN      229/App             
tcp        0      0 0.0.0.0:5201            0.0.0.0:*               LISTEN      175/App             
tcp        0      0 127.0.0.11:43249        0.0.0.0:*               LISTEN      -

修改xml配置

root/server/sh/configure.xml 【IP修改地址:第17行、第18行和第20行】【数据库密码修改地址:第19行】
/root/server/sh/configure_center.xml 【IP修改地址:第14行和第15行】【数据库密码修改地址:第16行
/root/server/sh/configure_cross.xml.xml 【IP修改地址:第14行、第15行和第17行】

3.前端搭建

docker-compose.yml

version: '3'
services:
    php: 
        build: .
        ports:
          - "9000:9000"
        restart: always
        privileged: "true"
        volumes:
            - "$PWD/nginx/html:/var/www/html"
        networks:
            lsh:
                aliases:
                    - php56
    nginx:
        image: nginx:1.17.8
        depends_on:
            - "php"
        volumes:
            - "$PWD/nginx/conf.d:/etc/nginx/conf.d"
            - "$PWD/nginx/html:/var/www/html"
        privileged: "true"
        ports:
            - "8011:80"
        restart: always
        networks: 
            - lsh
networks:
    lsh:
        external: true

nginx.conf文件配置

# #user  nobody;
# worker_processes  1;

# #error_log  logs/error.log;
# #error_log  logs/error.log  notice;
# #error_log  logs/error.log  info;

# #pid        logs/nginx.pid;
# events {
#     worker_connections  1024;
# }

server {
    listen       80;
    server_name  localhost;
    location / {
        root   /var/www/html;
        index  index.html index.htm index.php;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/html;
    }

    location ~ .*\.(php)$ {
        fastcgi_pass   php56:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
             include        fastcgi_params;
              index  index.html index.htm;
         #include  fastcgi.conf;
    }
}

Docker文件

FROM php:5.6-fpm

RUN apt-get update 
RUN apt-get install -y iputils-ping
RUN docker-php-ext-install mysqli
RUN docker-php-ext-enable mysqli

ws地址配置 index.php,自己改

//调试服务器ip列表
    var serverList = [
        "fireflyi1区|127.0.0.1:5201",
        "Q6025606|127.0.0.1:5201",
    ];

启动直接浏览器 http://127.0.0.1:8011/dsxy/index.php?order=gm打开页面

4.数据库

1、总共需要3个库user,xntg1,center库
2、直接导入即可

mysql -uroot -p你的数据库密码
Grant all privileges  on *.* to root@'%' identified by "你的数据库密码";
FLUSH PRIVILEGES;

4.5 报错解决

export/App/dsxy/root/server/sh/../libc++/App: error while loading shared libraries: libtcmalloc.so.4: cannot open shared object file: No such file or directory
export/App/dsxy/root/server/sh/../libc++/App: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory

参考 https://www.fireflyi.com/article/90

5.GM后台

6.游戏预览

1.登录游戏

2.选择服务器

3.游戏画面 给自己冲了几千亿元宝 我是真强

正文到此结束
本文目录