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. 待續…
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章