Ubuntu部署TeamTalk文档

Ubuntu16.04 64bit 部署TeamTalk文档
  1. 准备
    • ubuntu16.04 64bit
    • root用户
    • apt-get update
  2. 安装mysql(5.7.29)
    • apt-get install mysql-server (出现输入密码,输入回车)
    • apt-get install mysql-client
    • apt-get install libmysqlclient-dev
  3. 安装Nginx(1.16.1)
    • 下载:wget http://nginx.org/download/nginx-1.16.1.tar.gz

    • 安装依赖

      • apt-get install gcc g++ autoconf automake
      • apt-get install zlib1g-dev openssl libssl-dev libpcre3 libpcre3-dev
    • 编译安装
      tar xvf nginx-1.16.1.tar.gz
      cd nginx-1.16.1
      ./configure --with-stream
      make
      make install
      ldconfig

    • 配置nginx.conf
      vi /usr/local/nginx/conf/nginx.conf #直接替换所有内容

      user  root;
      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 {
      	use epoll;
          worker_connections  1024;
      	multi_accept on;
      }
      
      
      http {
          include       mime.types;
          default_type  application/octet-stream;
      	
      	server_names_hash_bucket_size 128;
          client_header_buffer_size 32k;
          large_client_header_buffers 4 32k;
          client_max_body_size 50m;
          sendfile        on;
          tcp_nopush     on;
          keepalive_timeout 60;
          tcp_nodelay on;
          fastcgi_connect_timeout 300;
          fastcgi_send_timeout 300;
          fastcgi_read_timeout 300;
          fastcgi_buffer_size 64k;
          fastcgi_buffers 4 64k;
          fastcgi_busy_buffers_size 128k;
          fastcgi_temp_file_write_size 256k;
          gzip on;
          gzip_min_length  1k;
          gzip_buffers     4 16k;
          gzip_http_version 1.0;
          gzip_comp_level 2;
          gzip_types       text/plain application/x-javascript text/css application/xml;
          gzip_vary on;
          gzip_proxied        expired no-cache no-store private auth;
          gzip_disable        "MSIE [1-6]\.";
          server_tokens off;
          log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" $http_x_forwarded_for';
      
          server {
              listen       80;
              server_name  localhost;
      		root         /home/hsl/TeamTalk/php;
              #charset koi8-r;
      
              #access_log  logs/host.access.log  main;
      
              location / {
                  index  index.html index.htm index.php;
              }
      
              #error_page  404              /404.html;
      
              # redirect server error pages to the static page /50x.html
              #
              error_page   500 502 503 504  /50x.html;
              location = /50x.html {
                  root   html;
              }
      
              # proxy the PHP scripts to Apache listening on 127.0.0.1:80
              #
              #location ~ \.php$ {
              #    proxy_pass   http://127.0.0.1;
              #}
      
              # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
              #
              #location ~ \.php$ {
              location ~ \.php($|/) {
                  fastcgi_pass   unix:/run/php/php5.6-fpm.sock; #www.conf中listen值
                  fastcgi_index  index.php;
                  fastcgi_split_path_info ^(.+\.php)(.*)$;
                  fastcgi_param   PATH_INFO $fastcgi_path_info;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                  include        fastcgi_params;
              }
      		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
      			expires      30d;
      		}
       
      		location ~ .*\.(js|css)?$ {
      			expires      12h;
      		}
      		if (!-e $request_filename) {
      			rewrite ^/(.*)$ /index.php/$1 last;
      			break;
      		}
      
              # deny access to .htaccess files, if Apache's document root
              # concurs with nginx's one
              #
              #location ~ /\.ht {
              #    deny  all;
              #}
          }
      
      
          # another virtual host using mix of IP-, name-, and port-based configuration
          #
          #server {
          #    listen       8000;
          #    listen       somename:8080;
          #    server_name  somename  alias  another.alias;
      
          #    location / {
          #        root   html;
          #        index  index.html index.htm;
          #    }
          #}
      
      
          # HTTPS server
          #
          #server {
          #    listen       443 ssl;
          #    server_name  localhost;
      
          #    ssl_certificate      cert.pem;
          #    ssl_certificate_key  cert.key;
      
          #    ssl_session_cache    shared:SSL:1m;
          #    ssl_session_timeout  5m;
      
          #    ssl_ciphers  HIGH:!aNULL:!MD5;
          #    ssl_prefer_server_ciphers  on;
      
          #    location / {
          #        root   html;
          #        index  index.html index.htm;
          #    }
          #}
      
      }
      
    • 启动
      vi /usr/lib/systemd/system/nginx.service
      [Unit]
      Description=nginx - high performance web server
      After=network.target remote-fs.target nss-lookup.target

      	[Service]
      	Type=forking
      	ExecStart=/usr/local/nginx/sbin/nginx
      	ExecReload=/usr/local/nginx/sbin/nginx -s reload
      	ExecStop=/usr/local/nginx/sbin/nginx -s stop
      
      	[Install]
      	WantedBy=multi-user.target
      systemctl daemon-reload //重新加载服务
      
      systemctl start nginx  //启动
      systemctl stop nginx  //停止
      systemctl reload nginx  //重启 可以不用停止nginx服务,使修改的配置生效
      systemctl restart nginx  //重启
      systemctl enable nginx  //设置开机启动
      systemctl disable nginx  //禁用开机启动
      systemctl status nginx  //查看服务状态
      
  4. 安装PHP(5.6)
    • 安装程序包及依赖库
      方法一:
      apt-get install python-software-properties
      apt-get install software-properties-common
      add-apt-repository ppa:ondrej/php
      apt-get update
      apt-get upgrade
      apt-get install php5.6-fpm php5.6-mysql
      方法二:
      从安装包中安装:php_ubuntu16.04_deb
      多次执行以下命令直到成功(因为依赖关系有先后顺序)
      dpkg -i *.deb
    • 注意:php7.0不兼容次Web,因为数据库连接接口不兼容
  5. 启动Web
    • 配置
      1. TeamTalk/php/application/config/config.php
      $config[‘msfs_url’] = ‘http://127.0.0.1:8700/’; //‘http://msfs.teamtalk.im:8700/’;
      $config[‘http_url’] = ‘http://127.0.0.1:8400’; //‘http://10.11.5.171:8400’;
      2. TeamTalk/php/application/config/database.php
    • 导入数据库
      1. TeamTalk/auto_setup/mariadb/conf/ttopen.sql
      mysql -u root -p < ttopen.sql
    • 把程序放入nginx配置网站路径下
  6. redis
    • 安装
      1. wget http://download.redis.io/releases/redis-5.0.5.tar.gz
      2. tar xvf redis-5.0.5.tar.gz
      3. sudo mv redis-5.0.5 /usr/local/redis
      4. sudo make MALLOC=libc && make
      5. sudo make install (安装到/usr/bin/目录)
    • 配置
      vi /usr/local/redis/redis.conf
      1. 增加密码:(忽略此步骤,TeamTalk不需要密码)
      去掉requirepass前面#注释
      修改成自己密码:requirepass admin
      2. 开启远程
      去掉bind 127.0.0.1前面#注释
      3. 守护进程启动
      daemonize no (no改为yes)
    • 启动:redis-server /usr/local/redis/redis.conf
    • 测试:redis-cli -a admin
      $redis-cli -a admin
      127.0.0.1:6379> ping
      PONG
      127.0.0.1:6379>
  7. 编译server程序
    • 进入server/src目录

    • 准备

      • 安装依赖包
        1. apt install cmake libcurl4-openssl-dev
        2. apt-get install uuid-dev
        3. apt-get install libexpat1-dev libxml2-dev (apr-util会依赖)
      • ./make_log4cxx.sh
        报错后安装依赖
        下载地址:http://apr.apache.org/download.cgi
        1. 安装apr(1.7.0)
        tar xvf apr-1.7.0.tar.gz
        ./configure --prefix=/usr/apr
        make
        make install
        2.安装apr-util(1.6.1)
        tar xvf apr-util-1.6.1.tar.gz
        ./configure --prefix=/usr/apr-util --with-apr=/usr/apr
        make
        make install
        还报错:build_log4cxx()里修改apr与apr-util路径为刚才的安装路径
      • ./make_hiredis.sh
      • ./make_protobuf.sh
    • 编译

      • ./build_ubuntu.sh version 1.0.0
    • 配置IP及其它信息
      运行:sync_lib_for_zip.sh 把所需要的依赖加载到当前目录
      1. db_proxy_server/dbproxyserver.conf
      2. file_server/fileserver.conf
      3. http_msg_server/httpmsgserver.conf
      4. login_server/loginserver.conf
      5. msfs/msfs.conf.example 改为 msfs.conf
      6. msg_server/msgserver.conf
      7. push_server/pushserver.conf
      8. route_server/routeserver.conf

      9. vi ~/.bashrc 最后添加
      	export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
      
    • 启动
      ./restart.sh login_server
      ./restart.sh msg_server
      ./restart.sh route_server
      ./restart.sh db_proxy_server
      ./restart.sh file_server
      ./restart.sh push_server
      ./restart.sh msfs (不支持的话就进如msfs目录执行:…/daeml msfs)

  8. python模拟终端
    • 依赖:pip install protobuf==3.5.1
  9. 待续…

你可能感兴趣的:(其它)