首 頁 閱覽室 館友 個人圖書館 賬號 新版TeamTalk完整部署教程 2015-08-04 oskycar 原文連接 閱 2740 轉 48 轉藏到個人圖書館分享到微信 新版TeamTalk部署教程 新版TeamTalk已經在2015年03月28日發佈了,目前版本定爲1.0.0版本,後續版本號會按照以下規則進行: 一、版本規則按照x.y.z的形式進行。 二、各端小bug修復則版本號中z增長。 三、有新的feature增長,則版本號中y增長。 四、有重大更新及不兼容更新,則版本號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 virtualbox IP 下面咱們正式開始: 一、更新操做系統 更新操做系統: 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 執行上面命令後,會檢查一些更新,會出現以下圖: update1 後面會詢問是否安裝更新,有可能會詢問你是否須要導入密鑰之類的,輸入y便可,以下圖所示: update2 二、刪除已經安裝的軟件 爲了減小一些沒必要要的麻煩,咱們須要先卸載系統自帶的一些軟件,譬如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}'` 以下圖所示: remove 三、安裝必要的依賴軟件 因爲我選擇的是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 過程以下圖所示: install1 以下圖安裝結束: install2 四、安裝mysql 本次安裝的mysql版本是5.6.選擇從搜狐源下載,編譯過程漫長。 4.1 下載 wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.23.tar.gz download mysql 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<<EOF /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安裝成功: 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 /usr/bin/mysql ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe 登錄mysql: mysql -uroot -p 修改密碼(假定密碼爲:test123): use mysql; update user set password=password('$mysqlrootpwd') where user='root'; flush privileges; 退出,從新登錄: mysql -uroot -p 整個過程以下圖: mysql 4.9 結束 至此,mysql 已經安裝結束。退出到上一層目錄 cd ../ 五、安裝PHP 本次安裝的PHP是php 5.3.28,選擇從搜狐源下載。 5.1 下載PHP wget http://mirrors.sohu.com/php/php-5.3.28.tar.gz 5.2 安裝依賴 安裝依賴的庫,我選擇從chinaunix.net下載的,速度也還能夠。 5.2.1 libiconv wget http://down1.chinaunix.net/distfiles/libiconv-1.14.tar.gz tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure make -j 2&& make install cd .. 5.2.2 libmcrypt wget http://down1.chinaunix.net/distfiles/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure make -j 2&& make install ldconfig cd libltdl/ ./configure --enable-ltdl-install make && make install cd ../../ 5.2.3 mhash wget http://down1.chinaunix.net/distfiles/mhash-0.9.3.tar.gz tar -zxvf mhash-0.9.3.tar.gz cd mhash-0.9.3 ./configure make -j 2 && make install cd ../ 5.2.4 其餘 5.3 解壓編譯 tar -zxvf php-5.3.28.tar.gz cd php-5.3.28 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo make -j 2 ZEND_EXTRA_LIBS='-liconv' && make install 5.4 配置php cp php.ini-production /usr/local/php/etc/php.ini sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/php/etc/php.ini sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php/etc/php.ini sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php/etc/php.ini sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php/etc/php.ini sed -i 's/register_long_arrays = On/;register_long_arrays = On/g' /usr/local/php/etc/php.ini sed -i 's/magic_quotes_gpc = On/;magic_quotes_gpc = On/g' /usr/local/php/etc/php.ini sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php/etc/php.ini 5.5 後期配置 ln -s /usr/local/php/bin/php /usr/bin/php ln -s /usr/local/php/bin/phpize /usr/bin/phpize ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm cd .. 5.6 安裝ZendGuardLoader mkdir -p /usr/local/zend/ wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ cat >>/usr/local/php/etc/php.ini<<EOF ;eaccelerator ;ionCube [Zend Optimizer] zend_extension=/usr/local/zend/ZendGuardLoader.so zend_loader.enable=1 zend_loader.disable_licensing=0 zend_loader.obfuscation_level_support=3 zend_loader.license_path= EOF cd .. 5.7 修改php-fpm配置文件 cat >/usr/local/php/etc/php-fpm.conf<<EOF [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 request_terminate_timeout = 100 request_slowlog_timeout = 0 slowlog = var/log/slow.log EOF 5.8 建立php-fpm啓動腳本 vim /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm 如下是一份參考: #! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit 1 ;; esac 5.9 啓動php-fpm groupadd www useradd -s /sbin/nologin -g www www /etc/init.d/php-fpm start 見到以下圖表明啓動成功: php 6 安裝nginx 6.1 下載nginx wget http://mirrors.sohu.com/nginx/nginx-1.6.0.tar.gz 6.2 安裝依賴 6.2.1 pcre wget http://down1.chinaunix.net/distfiles/pcre-8.12.tar.bz2 tar -jxvf pcre-8.12.tar.bz2 cd pcre-8.12 ./configure make -j 2 && make install cd .. 6.3 解壓編譯nginx tar -zxvf nginx-1.6.0.tar.gz cd nginx-1.6.0 ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 make -j 2 && make install cd .. ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx 6.4 配置nginx /usr/local/nginx/conf/nginx.conf 下面是一份參考配置: user www www; worker_processes auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; 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]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; #log format 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 default; #listen [::]:80 default ipv6only=on; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot/default; #error_page 404 /404.html; location ~ [^/]\.php(/|$) { # comment try_files $uri =404; to enable pathinfo try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; #include pathinfo.conf; } location /nginx_status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /home/wwwlogs/access.log access; } include vhost/*.conf; } 6.5 後期配置 mkdir -p /home/wwwroot/default chmod +w /home/wwwroot/default mkdir -p /home/wwwlogs chmod 777 /home/wwwlogs chown -R www:www /home/wwwroot/default 6.6 編寫nginx啓動腳本 vim /etc/init.d/nginx chmod +x /etc/init.d/nginx 下面是一份參考配置: #! /bin/sh # chkconfig: 2345 55 25 # Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and # run 'update-rc.d -f nginx defaults', or use the appropriate command on your # distro. For CentOS/Redhat run: 'chkconfig --add nginx' ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO # Author: licess # website: http://lnmp.org PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=nginx NGINX_BIN=/usr/local/nginx/sbin/$NAME CONFIGFILE=/usr/local/nginx/conf/$NAME.conf PIDFILE=/usr/local/nginx/logs/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME case "$1" in start) echo -n "Starting $NAME... " if netstat -tnpl | grep -q nginx;then echo "$NAME (pid `pidof $NAME`) already running." exit 1 fi $NGINX_BIN -c $CONFIGFILE if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Stoping $NAME... " if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi $NGINX_BIN -s stop if [ "$?" != 0 ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if netstat -tnpl | grep -q nginx; then PID=`pidof nginx` echo "$NAME (pid $PID) is running..." else echo "$NAME is stopped" exit 0 fi ;; force-quit) echo -n "Terminating $NAME... " if ! netstat -tnpl | grep -q nginx; then echo "$NAME is not running." exit 1 fi kill `pidof $NAME` if [ "$?" != 0 ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $SCRIPTNAME stop sleep 1 $SCRIPTNAME start ;; reload) echo -n "Reload service $NAME... " if netstat -tnpl | grep -q nginx; then $NGINX_BIN -s reload echo " done" else echo "$NAME is not running, can't reload." exit 1 fi ;; configtest) echo -n "Test $NAME configure files... " $NGINX_BIN -t ;; *) echo "Usage: $SCRIPTNAME {start|stop|force-quit|restart|reload|status|configtest}" exit 1 ;; esac 6.6 測試nginx 6.6.1 寫php測試代碼 cat >/home/wwwroot/default/index.php<<EOFjavascript
EOF 6.6.2 啓動nginx /etc/init.d/nginx start ps -ef|grep nginx 見到下圖,表明啓動成功: nginx 若是你開啓了selinux,請關閉,不然訪問不了: sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 臨時關閉selinux: setenforce 0 關閉防火牆: service iptables stop 經過瀏覽器訪問下,以下圖: index 7 設置開機啓動 chkconfig --level 345 php-fpm on chkconfig --level 345 nginx on chkconfig --level 345 mysql on 7 安裝redis 7.1 下載redis wget http://download.redis.io/releases/redis-2.8.19.tar.gz 這裏會快不少: wget http://download.redis.io/releases/redis-2.8.19.tar.gz 7.2 解壓編譯redis tar -zxvf redis-2.8.19.tar.gz cd redis-2.8.19 make PREFIX=/usr/local/redis install 7.3 配置redis mkdir -p /usr/local/redis/etc/ cp redis.conf /usr/local/redis/etc/ sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/etc/redis.conf cd .. 7.4 編寫redis啓動腳本 vim /etc/init.d/redis chmod +x /etc/init.d/redis 下面是一份參考配置: #! /bin/bash # # redis - this script starts and stops the redis-server daemon # # chkconfig: 2345 80 90 # description: Redis is a persistent key-value database # ### BEGIN INIT INFO # Provides: redis # Required-Start: $syslog # Required-Stop: $syslog # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: redis-server daemon # Description: redis-server daemon ### END INIT INFO REDISPORT=6379 EXEC=/usr/local/redis/bin/redis-server REDIS_CLI=/usr/local/redis/bin/redis-cli PIDFILE=/var/run/redis.pid CONF="/usr/local/redis/etc/redis.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $REDIS_CLI -p $REDISPORT shutdown while [ -x ${PIDFILE} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; restart) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart}" >&2 exit 1 esac 7.5 啓動redis /etc/init.d/redis start 查看redis是否啓動 ps -ef|grep redis 若是看到以下圖,恭喜你,啓動成功: redis 8 升級gcc,gdb等(很是漫長,若是系統中自帶的g++支持C++11,可跳過此步驟) 8.1 下載gcc4.9.2 使用日本的源可能會快些: wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.gz 8.2 解壓編譯gcc4.9.2 tar -zxvf gcc-4.9.2.tar.gz cd gcc-4.9.2 ./contrib/download_prerequisites mkdir gcc-build-4.9.2 cd gcc-build-4.9.2 ../configure --prefix=/usr -enable-checking=release -enable-languages=c,c++ -disable-multilib make -j 2 && make install cd ../../ 8.3 下載termcap wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz 8.4 解壓編譯termcap tar -zxvf termcap-1.3.1.tar.gz cd termcap-1.3.1 ./configure --prefix=/usr make -j 2 && make install 8.5 下載gdb wget http://ftp.gnu.org/gnu/gdb/gdb-7.9.tar.gz 8.6 解壓編譯gdb tar -zxvf gdb-7.9.tar.gz cd gdb-7.9 ./configure --prefix=/usr make -j 2 && make install 9 重啓電腦 shutdown -r now 10 安裝PB 10.1 下載pb wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz 10.2 解壓編譯pb tar -zxvf protobuf-2.6.1 cd protobuf-2.6.1 ./configure --prefix=/usr/local/protobuf make -j 2 && make install 11 下載TeamTalk代碼 git clone https://github.com/mogujie/TeamTalk.git 12 生成pb文件 12.1 拷貝pb相關文件 拷貝pb的庫、頭文件到TeamTalk相關目錄中: mkdir -p /root/TeamTalk/server/src/base/pb/lib/linux/ cp /usr/local/protobuf/lib/libprotobuf-lite.a /root/TeamTalk/server/src/base/pb/lib/linux/ cp -r /usr/local/protobuf/include/* /root/TeamTalk/server/src/base/pb/ 12.2 生成pb協議 cd /root/TeamTalk/pb 執行: export PATH=$PATH:/usr/local/protobuf/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/protobuf/lib sh create.sh 生成協議相關源碼文件。 再執行: sh sync.sh 將相關文件拷貝到server 目錄下。 13 安裝依賴 cd /root/TeamTalk/server/src sh make_log4cxx.sh sh make_hiredis.sh 14 編譯server 14.1 編譯 因爲咱們是源碼安裝mysql的,因此對db_proxy_server中的CMakeList作必定的修改. 原來: SET(MYSQL_INCLUDE_DIR /usr/include/mysql) SET(MYSQL_LIB /usr/lib64/mysql) 修改成: SET(MYSQL_INCLUDE_DIR /usr/local/mysql/include) SET(MYSQL_LIB /usr/local/mysql/lib) 進入server目錄下,執行: sh build.sh version 1.0.0 若是一切順利,你將會看到以下畫面: compile success 15 配置server(時間太晚了,明天再來寫吧) 配置就以本機192.168.1.150 爲例。 15.1 配置文件說明: 15.1.1 login_server ClientListenIP=0.0.0.0 # can use multiple ip, seperate by ';' ClientPort=8008 HttpListenIP=0.0.0.0 HttpPort=8080 MsgServerListenIP=0.0.0.0 # can use multiple ip, seperate by ';' MsgServerPort=8100 msfs=http://127.0.0.1:8700/ discovery=http://127.0.0.1/api/discovery ClientListenIP:目前已經做廢。 ClientPort:與上一個配套,一樣做廢。 HttpListenIP:供客戶端過來獲取msg_server及其餘參數的接口地址,走http協議。 HttpPort:與上一個配套使用。 MsgServerListenIP:用於監聽msg_server上報信息使用。 MsgServerPort:與上一個配套使用。msg_server啓動的時候回來鏈接該ip:port,以上報本身的信息。 在運行過程當中,也會實時將本身的信息彙報給login_server。 msfs:小文件存儲的地址,該配置是提供給客戶端獲取參數時使用。 discovery:發現內容獲取地址,該配置是提供給客戶端獲取參數時使用。 參考配置: ClientListenIP=192.168.1.150 ClientPort=8008 HttpListenIP=192.168.1.150 HttpPort=8080 MsgServerListenIP=192.168.1.150 MsgServerPort=8100 msfs=http://192.168.1.150:8700/ discovery=http://192.168.1.150/api/discovery 15.1.2 route_server ListenIP=0.0.0.0 # Listening IP ListenMsgPort=8200 # Listening Port for MsgServer route_server配置比較簡單,一個監聽ip,一個監聽port就OK了,供msg_server鏈接上來用。 參考配置: ListenIP=192.168.1.150 ListenMsgPort=8200 15.1.3 http_msg_server ListenIP=0.0.0.0 ListenPort=8400 ConcurrentDBConnCnt=4 DBServerIP1=127.0.0.1 DBServerPort1=10600 DBServerIP2=127.0.0.1 DBServerPort2=10600 RouteServerIP1=localhost RouteServerPort1=8200 #RouteServerIP2=localhost #RouteServerPort2=8201 ListenIP:監聽IP,供其餘人來調用http_msg_server接口,好比,php在建立羣組的時候,就會來調用http_msg_server的接口。 ListenPort:監聽端口,與上一個配套使用。 ConcurrentDBConnCnt:DB數目,目前必須配置爲2的整數倍,是歷史遺留問題,後期會修復。 DBServerIP(x):db_proxy_server監聽的IP,http_msg_server會主動去鏈接。 DBServerPort(x):db_proxy_server監聽的Port RouteServerIP(x):route_server監聽的IP,http_msg_server會主動去鏈接。 RouteServer(x):route_server監聽的Port 參考配置: ListenIP=192.168.1.150 ListenPort=8400 ConcurrentDBConnCnt=4 DBServerIP1=192.168.1.150 DBServerPort1=10600 DBServerIP2=192.168.1.150 DBServerPort2=10600 RouteServerIP1=192.168.1.150 RouteServerPort1=8200 15.1.4 msg_server ListenIP=0.0.0.0 ListenPort=8000 ConcurrentDBConnCnt=2 DBServerIP1=127.0.0.1 DBServerPort1=10600 DBServerIP2=127.0.0.1 DBServerPort2=10600 LoginServerIP1=127.0.0.1 LoginServerPort1=8100 #LoginServerIP2=localhost #LoginServerPort2=8101 RouteServerIP1=127.0.0.1 RouteServerPort1=8200 #RouteServerIP2=localhost #RouteServerPort2=8201 PushServerIP1=127.0.0.1 PushServerPort1=8500 FileServerIP1=127.0.0.1 FileServerPort1=8600 #FileServerIP2=localhost #FileServerPort2=8601 IpAddr1=127.0.0.1 #電信IP IpAddr2=127.0.0.1 #網通IP MaxConnCnt=100000 #AES 密鑰 aesKey=12345678901234567890123456789012 ListenIP:監聽客戶端鏈接上來的IP。 ListenPort:與上一個配套使用,監聽客戶端鏈接的port。 ConcurrentDBConnCnt:db_proxy_server個數,同http_msg_server 同樣。 DBServerIP(x):db_proxy_server監聽的ip,msg_server主動去鏈接。 DBServerPort(x):db_proxy_server監聽的port。 LoginServerIP(x):login_server監聽的ip,msg_server會主動去鏈接,彙報本機信息。 LoginServerPort(x):login_server監聽的port。 RouteServerIP(x):route_server監聽的IP,msg_server主動去鏈接。 RouteServerPort(x):route_server監聽的port。 PushServerIP(x):push_server監聽的IP,msg_server會主動去鏈接,給ios系統推送消息。 PushServerPort(x):push_server監聽的port。 FileServerIP(x):file_server監聽的IP,msg_server會主動去鏈接,用於文件傳輸,暫時未用到。 FileServerPort(x):file_server監聽的port。 IpAddr1:msg_server監聽的ip,用於彙報給login_server,便於login_server在客戶端請求的時候返回給客戶端。注意,這個ip必定要是客戶端能鏈接的ip,以前發現好多人配置成127.0.0.1,這是不行的。 IpAddr2:同上。 aesKey:消息文本加密密鑰.這裏配置主要在msg_server向push_server推送的時候須要將加密的消息進行解密。 參考配置: ListenIP=192.168.1.150 ListenPort=8000 ConcurrentDBConnCnt=2 DBServerIP1=192.168.1.150 DBServerPort1=10600 DBServerIP2=192.168.1.150 DBServerPort2=10600 LoginServerIP1=192.168.1.150 LoginServerPort1=8100 RouteServerIP1=192.168.1.150 RouteServerPort1=8200 PushServerIP1=192.168.1.150 PushServerPort1=8500 FileServerIP1=192.168.1.150 FileServerPort1=8600 IpAddr1=192.168.1.150 #電信IP IpAddr2=192.168.1.150 #網通IP MaxConnCnt=100000 #AES 密鑰 aesKey=12345678901234567890123456789012 15.1.5 db_proxy_server ListenIP=127.0.0.1 ListenPort=10600 ThreadNum=48 # double the number of CPU core MsfsSite=127.0.0.1 #configure for mysql DBInstances=teamtalk_master,teamtalk_slave #teamtalk_master teamtalk_master_host=127.0.0.1 teamtalk_master_port=3306 teamtalk_master_dbname=teamtalk teamtalk_master_username=root teamtalk_master_password=12345 teamtalk_master_maxconncnt=16 #teamtalk_slave teamtalk_slave_host=127.0.0.1 teamtalk_slave_port=3306 teamtalk_slave_dbname=teamtalk teamtalk_slave_username=root teamtalk_slave_password=12345 teamtalk_slave_maxconncnt=16 #configure for unread CacheInstances=unread,group_set,token,group_member #未讀消息計數器的redis unread_host=127.0.0.1 unread_port=6379 unread_db=1 unread_maxconncnt=16 #羣組設置redis group_set_host=127.0.0.1 group_set_port=6379 group_set_db=2 group_set_maxconncnt=16 #deviceToken redis token_host=127.0.0.1 token_port=6379 token_db=4 token_maxconncnt=16 #GroupMember group_member_host=127.0.0.1 group_member_port=6379 group_member_db=5 group_member_maxconncnt=48 #AES 密鑰 aesKey=12345678901234567890123456789012 ListenIP:db_proxy_server監聽的IP。 ListenPort:db_proxy_server監聽的port ThreadNum:工做線程個數。 MsfsSite:配置msfs服務器的地址,用於發送語音的時候上傳保存語音文本。 DBInstances:db實例名稱。通常配置一主一從便可,其餘根據本身的需求修改。 (xxxx)_host:xxxx實例的ip (xxxx)_port:xxxx實例的port (xxxx)_dbname:xxxx實例的scheme名稱 (xxxx)_username:xxxx實例的用戶名 (xxxx)_password:xxxx實例的密碼 (xxxx)_maxconncnt:xxxx實例最大鏈接數 CacheInstances:cache實例名稱。 (xxxx)_host:xxxx實例的ip (xxxx)_port:xxxx實例的port (xxxx)_db:xxxx實例的db (xxxx)_maxconncnt:xxxx aesKey:消息加密密鑰。 目前咱們db實例配置的一主一從,cache實例配置了5個實例,分別是: unread:主要用於未讀計數。 group_set:羣組設置。設置屏蔽羣組。 token:主要用於保存ios系統的token。 group_member:保存羣成員信息。 參考配置: ListenIP=192.168.1.150 ListenPort=10600 ThreadNum=48 # double the number of CPU core MsfsSite=http://192.168.1.150:8700/ #configure for mysql DBInstances=teamtalk_master,teamtalk_slave #teamtalk_master teamtalk_master_host=192.168.1.150 teamtalk_master_port=3306 teamtalk_master_dbname=teamtalk teamtalk_master_username=teamtalk teamtalk_master_password=test@123 teamtalk_master_maxconncnt=16 #teamtalk_slave teamtalk_slave_host=192.168.1.150 teamtalk_slave_port=3306 teamtalk_slave_dbname=teamtalk teamtalk_slave_username=teamtalk teamtalk_slave_password=test@123 teamtalk_slave_maxconncnt=16 #configure for unread CacheInstances=unread,group_set,token,group_member #未讀消息計數器的redis unread_host=192.168.1.150 unread_port=6379 unread_db=1 unread_maxconncnt=16 #羣組設置redis group_set_host=192.168.1.150 group_set_port=6379 group_set_db=2 group_set_maxconncnt=16 #deviceToken redis token_host=192.168.1.150 token_port=6379 token_db=4 token_maxconncnt=16 #GroupMember group_member_host=192.168.1.150 group_member_port=6379 group_member_db=5 group_member_maxconncnt=48 #AES 密鑰 aesKey=12345678901234567890123456789012 1六、更新 16.1 導入mysql 登錄mysql: mysql -uroot -p 輸入密碼:test123. 建立TeamTalk數據庫: create database teamtalk 見到以下: mysql> create database teamtalk; Query OK, 1 row affected (0.00 sec) 建立成功。 建立teamtalk用戶並給teamtalk用戶受權teamtalk的操做: grant select,insert,update,delete on teamtalk.* to 'teamtalk'@'%' identified by 'test@123 '; flush privileges; 導入數據庫. use teamtalk; source /root/TeamTalk/auto_setup/mariadb/conf/ttopen.sql; show tables; 以下: mysql> show tables; +--------------------+ | Tables_in_teamtalk | +--------------------+ | IMAdmin | | IMAudio | | IMDepart | | IMDiscovery | | IMGroup | | IMGroupMember | | IMGroupMessage_0 | | IMGroupMessage_1 | | IMGroupMessage_2 | | IMGroupMessage_3 | | IMGroupMessage_4 | | IMGroupMessage_5 | | IMGroupMessage_6 | | IMGroupMessage_7 | | IMMessage_0 | | IMMessage_1 | | IMMessage_2 | | IMMessage_3 | | IMMessage_4 | | IMMessage_5 | | IMMessage_6 | | IMMessage_7 | | IMRecentSession | | IMRelationShip | | IMUser | +--------------------+ 25 rows in set (0.00 sec) mysql> 16.2 修改php 執行以下命令: cd /home/wwwroot/default cp -r /root/TeamTalk/php/* /home/wwwroot/default 修改config.php: vim application/config/config.php 修改第18-19行: $config['msfs_url'] = 'http://192.168.1.150:8700/'; $config['http_url'] = 'http://192.168.1.150:8400'; 修改database.php vim application/config/database.php 修改52-54行: $db['default']['hostname'] = '192.168.1.150'; $db['default']['username'] = 'tamtalk'; $db['default']['password'] = 'test@123 '; $db['default']['database'] = 'teamtalk'; 訪問後,看到以下圖: success 16.3 修改nginx.conf 以前給出的配置有點問題,新配置以下: user www www; worker_processes auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; 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 192.168.1.150; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/default; location ~ \.php($|/) { fastcgi_pass unix:/tmp/php-cgi.sock; 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; } } } 1七、測試 在後臺添加test用戶,運行ios 模擬器,登錄看到以下圖 ios 1八、virtualBox 環境 置於怎麼加載虛擬機,怎麼運行虛擬機請自行百度,谷歌。 18.1 我虛擬機的環境 連接: http://pan.baidu.com/s/1sjx8g49 密碼: 4572 18.2 虛擬機硬盤 因網盤大小限制1G,因此將虛擬機硬盤切分紅3個文件上傳: 連接: http://pan.baidu.com/s/1mgDXvwW 密碼: tgzp 請使用以下命令合併解壓: cat CentOS-hd.tar.gz.* > CentOS-hd.tar.gz tar -zxvf CentOS-hd.tar.gz 18.3 帳號信息 虛擬機帳號信息以下: linux帳號密碼:root/123456 mysql root帳號密碼:root/test123 mysql teamtalk帳號密碼:teamtalk/test@123 php 後臺帳號密碼:admin/admin 測試用戶帳號密碼:test/test 18.4 運行 啓動虛擬機後,運行以下命令: ps -ef|grep server 若是看到以下: [root@zhyh ~]# ps -ef|grep server root 1653 1 0 22:13 ? 00:00:05 /usr/local/redis/bin/redis-server *:6379 root 1658 1 1 22:13 ? 00:00:21 ./db_proxy_server root 1717 1 0 22:13 ? 00:00:02 ./http_msg_server root 1729 1 0 22:13 ? 00:00:02 ./route_server root 1737 1 0 22:14 ? 00:00:02 ./login_server root 1757 1 0 22:15 ? 00:00:02 ./msg_server root 1788 1774 0 22:34 pts/2 00:00:00 grep server 若是沒有發現:db_proxy_server, http_msg_server,route_server,login_server,msg_server的進程,請執行以下命令啓動: cd /usr/local/teamtalk cd xxxx ../daeml xxxx xxx表明相應的程序名。經過查看:xxxx/log/default.log 查看程序錯誤。 18.5 redis,php,nginx,mysql的啓動,中止與重啓 /etc/init.d/redis {start|stop|restart} /etc/init.d/php-fpm {start|stop|force-quit|restart|reload} /etc/init.d/nginx {start|stop|force-quit|restart|reload|status|configtest} /etc/init.d/mysql {start|stop|restart|reload|force-reload|status} [ MySQL server options ] 7 打賞 若是您以爲這篇文章對您有幫助,歡迎您給我打賞。經過微信掃一掃,便可。 轉藏到個人圖書館 獻花(0) 分享到微信 以文找文 來自: oskycar > 《Linux》 推薦給朋友 舉報 上一篇:SVN經常使用命令說明 下一篇:TeamTalk服務器佈署 猜你喜歡 相似文章更多 LNMP環境搭建指引 lnmp環境搭建教程 LEMP構建高性能WEB服務器(CentOS+Nginx... 麪霸的八月:小米麪試記(1) 在Fedora 11中安裝Nginx+MySQL+PHP5(Fa... fedora11+nginx+php+mysql+ssh安裝 Ubuntu11.10 源碼編譯安裝PHP5.3.8 Nginx+PHP的測試---5.3.3已包括fpm - 回... 熱門推廣 發表評論: 共 1 條評論 hushizhao15-10-14 15:32 1 頂 踩 0 很好 回覆 oskycar圖書館 103 館藏 1033 TA的最新館藏 在OpenCV中自適應肯定canny算法的分割門限 Deep Learning模型之:CNN卷積神經網絡(一)深度解析CNN Deep Learning論文筆記之(四)CNN卷積神經網絡推導和實現 基於AdaBoost算法的實時目標跟蹤 [轉] Adaboost 算法的原理與推導(讀書筆記) 淺談 Adaboost 算法 更多 推薦閱讀 TeamTalk服務器佈署 teamtalk服務端之完美一鍵部署腳本(ubuntu) 安裝 postgresql + proj + geos + postgis 轉個帖子: 1,關閉NetworkManager服務,打開networ | Linux貼站 Windows下使用VS2008編譯OpenCV 2.1 添加Intel TBB和Pyth... Gettext Deep Learning(深度學習)學習筆記整理系列之(二) Java Zxing生成二維碼解決中文編碼問題 GetWindowLong函數(最好的解釋資料,絕對值得一看,此函數在子類化技巧時候常常用到) 更多 關閉 關閉php