新版TeamTalk部署教程
新版TeamTalk已经在2015年03月28日发布了,目前版本定为1.0.0版本,后续版本号会按照如下规则进行:
1、版本规则按照x.y.z的形式进行。
2、各端小bug修复则版本号中z增加。
3、有新的feature增加,则版本号中y增加。
4、有重大更新及不兼容更新,则版本号x增加。
本教程会在VirtualBox 虚拟机中进行安装部署一整套服务端,并做记录,给大家做个参考,后面会将整个虚拟机打包上传到网盘中,为那些不想自己亲自部署的人一个可用环境。
这篇博客中,不会使用一键部署脚本,我会一步一步手动去部署。另外我会尽量选择源码安装mysql,php,nginx等,后面所有的安装在/usr/local/目录下。(源码安装很多参考了军哥(http://www.lnmp.org)的脚本,在此表示感谢)。
真个部署过程从晚上8:00开始到半夜将近2:00(由于时间太晚了,明天还要上班,所以配置那块后面再写),耗时近6个小时,所以本文也耗时5个多小时才完成,希望可以帮助到大家。
更新:
2015年04月02日更新
更新了配置文件说明
2015年04月07日更新
更新了数据库导入,及问题修复。
2015年05月05日
修复mysql下载不了问题,感谢@Gene反馈。
我的环境如下:
虚拟机:VirtualBox 4.3.18
CPU:2核
内存:2GB
硬盘:10GB
操作系统:CentOS 6.5 x64
IP:192.168.1.150
下面我们正式开始:
1、更新操作系统
更新操作系统:
CentOS 使用如下命令:
yum update
Ubuntu 使用如下命令:
apt-get update
该命令会执行更新,会消耗一段时间,国内用户,建议使用科大源或者163,搜狐等都可以,这会为大家节省很多时间,具体使用方法,可以见相关的页面:
163源帮助:http://mirrors.163.com/.help/centos.html
:http://mirrors.163.com/.help/ubuntu.html
搜狐源帮助:http://mirrors.sohu.com/help/centos.html
:http://mirrors.sohu.com/help/ubuntu.html
科大源帮助:https://lug.ustc.edu.cn/wiki/mirrors/help/centos
:https://lug.ustc.edu.cn/wiki/mirrors/help/ubuntu
执行上面命令后,会检查一些更新,会出现如下图:
后面会询问是否安装更新,有可能会询问你是否需要导入密钥之类的,输入y即可,如下图所示:
2、删除已经安装的软件
为了减少一些不必要的麻烦,我们需要先卸载系统自带的一些软件,譬如mysql,nginx,php,执行以下命令:
CentOS 执行如下命令:
yum -y remove httpd* php* mysql-server mysql mysql-libs php-mysql
Ubuntu 使用如下命令:
apt-get remove -y apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php5 php5-common php5-cgi php5-mysql php5-curl php5-gd
killall apache2
dpkg -l |grep mysql
dpkg -P libmysqlclient15off libmysqlclient15-dev mysql-common
dpkg -l |grep apache
dpkg -P apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common
dpkg -l |grep php
dpkg -P php5 php5-common php5-cgi php5-mysql php5-curl php5-gd
apt-get purge `dpkg -l | grep php| awk '{print $2}'`
如下图所示:
3、安装必要的依赖软件
由于我选择的是CentOS 最小化安装,所以系统中很多软件是没有安装的,需要我手动安装。
执行如下命令安装一些依赖软件:
CentOS 使用如下命令:
yum -y install wget vim git texinfo patch make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils
ubuntu 使用如下命令:
apt-get autoremove -y
apt-get -fy install
apt-get install -y build-essential gcc g++ make
apt-get install -y --force-yes wget vim git texinfo patch build-essential gcc g++ make cmake automake autoconf re2c wget cron bzip2 libzip-dev libc6-dev file rcconf flex vim nano bison m4 gawk less make cpp binutils diffutils unzip tar bzip2 libbz2-dev unrar p7zip libncurses5-dev libncurses5 libncurses5-dev libncurses5-dev libtool libevent-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlibc openssl libsasl2-dev libltdl3-dev libltdl-dev libmcrypt-dev zlib1g zlib1g-dev libbz2-1.0 libbz2-dev libglib2.0-0 libglib2.0-dev libpng3 libjpeg62 libjpeg62-dev libjpeg-dev libpng-dev libpng12-0 libpng12-dev curl libcurl3 libmhash2 libmhash-dev libpq-dev libpq5 gettext libncurses5-dev libcurl4-gnutls-dev libjpeg-dev libpng12-dev libxml2-dev zlib1g-dev libfreetype6 libfreetype6-dev libssl-dev libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev mcrypt libcap-dev diffutils ca-certificates debian-keyring debian-archive-keyring;
apt-get -fy install
apt-get -y autoremove
过程如下图所示:
如下图安装结束:
4、安装mysql
本次安装的mysql版本是5.6.选择从搜狐源下载,编译过程漫长。
4.1 下载
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.23.tar.gz
4.2 解压编译
执行如下命令:
tar -zxvf mysql-5.6.23.tar.gz
cd mysql-5.6.23
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1
make -j 2 && make install
编译将是一个漫长得过程。。。不同的机器性能等待时间不同。
make的-j参数可以使make进行并行编译编译。我cpu的个数是2,所以指定为2.
4.3 添加mysql用户
groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql
4.4 修改配置文件
vim /etc/my.cnf
下面给出一份参考配置(只是测试用,如果要用于生产环境,请自行调配):
# Example MySQL config file for medium systems.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
default-character-set=utf8mb4
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
bind-address=127.0.0.1
port = 3306
socket = /tmp/mysql.sock
datadir = /usr/local/mysql/var
collation-server = utf8mb4_general_ci
character-set-server = utf8mb4
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin
# binary logging format - mixed recommended
binlog_format=mixed
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/mysql/var
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set=utf8mb4
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
4.5 初始化mysql
/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql/.
cp support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
cat > /etc/ld.so.conf.d/mysql.conf<
/usr/local/mysql/lib
/usr/local/lib
EOF
ldconfig
4.6 启动mysql
/etc/init.d/mysql start
4.7 查看mysql进程
ps -ef|grep mysql
如果看到下图,恭喜你,mysql安装成功:
4.8 后期配置
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/bin/mysql