如下範例服務器操做系統使用:Centos7.2_X8.6_64_Litehtml
軟件使用:Mysql5.6java
Nginx1.8.1node
Nodejs6.9.5mysql
Redis3.2.3nginx
代碼和相關環境能夠在這裏下載git
https://code.csdn.net/typesdk_code/typesdk_server/tree/masterredis
1、安裝完Centos7.x以後,安裝Git,直接從源碼庫克隆相關程序sql
一、 安裝git數據庫
yum install -y git
二、 從git上克隆代碼npm
git clone https://code.csdn.net/typesdk_code/typesdk_server.git
2、安裝Mysql並導入數據庫(root用戶僅本地登入,未開放遠程,密碼爲typesdk.com)
一、 安裝mysql5.6,這裏使用官方源安裝
cd typesdk_server/Tools/ rpm -ivh mysql57-community-release-el7-9.noarch.rpm cp mysql-community.repo /etc/yum.repos.d/mysql-community.repo yum install -y mysql-server mkdir -p /data/typesdk_server/mysql_data chown -R mysql.mysql /data/typesdk_server/mysql_data cp /etc/my.cnf /etc/my.cnf.bak >/etc/my.cnf vi /etc/my.cnf
如下是配置文件全文,直接複製拷貝進去
[mysqld] datadir=/data/typesdk_server/mysql_data socket=/var/lib/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid character-set-server=utf8 [client] default-character-set=utf8 [mysql] default-character-set=utf8
二、 啓動數據庫
service mysql start
三、 導入數據庫
mysql < ../SdkServer_free_git/typesdk_server.sql mysqladmin -u root password "typesdk.com"
3、安裝redis並導入數據(redis僅本地登入,未開放遠程,密碼爲typesdk.com)
一、 使用RPM安裝redis
rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm rpm -ivh redis-3.2.3-1.el7.x86_64.rpm mkdir -p /data/typesdk_server/redis_data chown -R redis.redis /data/typesdk_server/redis_data cp /etc/redis.conf /etc/redis.conf.bak >/etc/redis.conf vi /etc/redis.conf
如下是配置文件全文,直接複製拷貝進去
bind 127.0.0.1 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize no supervised no pidfile /var/run/redis_6379.pid loglevel notice logfile /var/log/redis/redis.log databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename sdk.rdb dir /data/typesdk_server/redis_data slave-serve-stale-data yes slave-read-only yes requirepass typesdk.com repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
二、 啓動redis
service redis start
三、 導入redis數據庫
sh ../SdkServer_free_git/init_redis.sh
特別注意init_redis.sh裏的redis配置信息必須配置正確,apikey爲sdk服務器與遊戲服務器通信的密鑰,請根據實際狀況修改爲一致,其餘渠道相關參數請看腳本註釋
TypeSdk打包工具中有圖形化配置工具,也能夠用那個工具生成後同步
4、安裝配置nginx
一、 rpm安裝nginx
rpm -ivh nginx-1.8.1-1.el7.ngx.x86_64.rpm mkdir -p /data/typesdk_server/nginx_html/config cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak mkdir -p /data/typesdk_server/nginx_html/config/ cp -rf Nginx_SwitchConfig/1001/ /data/typesdk_server/nginx_html/config/ >/etc/nginx/nginx.conf vi /etc/nginx/nginx.conf
如下是配置文件全文,直接複製拷貝進去
#user nobody; worker_processes auto; events { worker_connections 102400; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; server { listen 80; #server_name your.domain.name; location /config { root /data/typesdk_server/nginx_html; index index.html index.htm; } location / { proxy_pass http://127.0.0.1:40000; } location /getIp { default_type application/json; return 200 '{"ip":"$remote_addr"}'; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
二、 啓動nginx
service nginx start
5、安裝node環境並配置TypeSdkServer
一、 rpm安裝node
rpm -ivh nodejs-6.9.5-1nodesource.el7.centos.x86_64.rpm npm config set registry http://registry.cnpmjs.org cp -rf ../SdkServer_free_git/ /data/typesdk_server/ chmod +x /data/typesdk_server/SdkServer_free_git/node_modules/pm2/bin/pm2 ln -s /data/typesdk_server/SdkServer_free_git/node_modules/pm2/bin/pm2 /usr/bin/pm2
特別注意/data/typesdk_server/SdkServer_free_git/config.json文件
請按照安裝的mysql和redis的配置來修改,如直接使用以上配置則不須要修改
二、 啓動TypeSdkServer
cd /data/typesdk_server/SdkServer_free_git/bin/ pm2 start www
6、檢查是否安裝完成
打開瀏覽器訪問如下幾個接口
以上兩個接口會出現json
http://IP/config/1001/3/config.txt
以上能夠讀取配置文件
以上能夠得到客戶端IP地址
都正常出現就說明server已經部署完成