CentOS 5.5 下安装Countly Web Server过程记录

1. 系统更新与中文语言包安装

2. 基本环境配置:

2.1. NodeJS安装

  1. 依赖项安装

    yum -y install gcc gcc-c++ openssl-devel
  2. 下载并解压安装 nodejs

    cd /opt
    wget –c http://nodejs.org/dist/v0.12.4/node-v0.12.4.tar.gz
    tar zxvf node-v0.12.4.tar.gz
    cd node-v0.12.4
    ./configure --prefix=/usr/local/nodejs
    make && make install

    注意此时会有错误输出信息:

    ./configure  File "./configure", line 442
    fpu = 'vfpv3' if armv7 else 'vfpv2'
    ^ SyntaxError: invalid syntax

    这是因为Python当前版本 2.4.3 不够,需要升级Python

  3. 升级Python:

    cd /opt
    wget -c http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
    tar jxvf Python-2.7.3.tar.bz2
    cd Python-2.7.3
    ./configure
    make && make install

    正常情况下即使python2.7安装成功后,系统默认指向的python仍然是2.4.3版本,考虑到yum是基于python2.4.3才能正常工作,不敢轻易卸载。
    解决方法:

    • 建立软连接
      mv /usr/bin/python /usr/bin/python.bak
      ln -s /usr/local/bin/python2.7 /usr/bin/python
    • 使yum配置指向特定版本python2.4
      vi /usr/bin/yum

      将第一行显示的#/usr/bin/python修改为#/usr/bin/python2.4
      保存修改:wq

  4. 继续上面的步骤重新安装NodeJS:

    cd /opt/node-v0.12.4
    ./configure --prefix=/usr/local/nodejs
    make && make install

    注意,又有新的错误:

    ImportError: No module named bz2
    make[1]: *** [/opt/node-v0.12.4/out/Release/obj/gen/libraries.cc] 错误 1
    make[1]: Leaving directory '/opt/node-v0.12.4/out'
    make: *** [node] 错误 2

    这个错误是由于python中没有装bz2的库导致的

  5. 继续安装bz2

    yum install -y bzip2*
    cd /opt/Python-2.7.2/Modules/zlib
    ./configure
    make && make install

    重新安装python

    cd /opt/Python-2.7.2/
    python2.7 setup.py install
  6. 继续上面的步骤重新安装NodeJS:

    cd /opt/node-v0.12.4
    ./configure --prefix=/usr/local/nodejs
    make && make install

    这次应该可以安装成功了

  7. 配置NodeJS环境变量

    • 进入profile编辑环境变量
      vim /etc/profile

      export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 一行的【上面】添加如下内容:

      #set for nodejs 
      export NODE_HOME=/usr/local/nodejs
      export PATH=$NODE_HOME/bin:$PATH

      :wq保存并退出,编译/etc/profile 使配置生效

      source /etc/profile

      输入测试:

      node -v

      得到版本号v0.12.4

2.2 Ngnix安装

  1. 在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel 和libevent

    yum install pcre-devel  libevent  openssl
    yum -y install zlib zlib-devel  pcre
  2. 下载、解压安装Nginx

    wget -c http://nginx.org/download/nginx-1.8.0.tar.gz
    tar –zxv –f nginx-1.8.0.tar.gz
    cd nginx-1.8.0
    ./configure --prefix=/usr/local/nginx
    make && make install
  3. 测试nginx
    开启:

    /usr/local/nginx/sbin/nginx

    测试http访问

    curl localhost

    得到以下输出信息表示成功安装并开启nginx

    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
       body {
           width: 35em;
           margin: 0 auto;
           font-family: Tahoma, Verdana, Arial, sans-serif;
       }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>
    </pre>

3. 安装Countly Web Server

  1. 下载到/opt,并解压

    cd /opt
    wget –c https://github.com/Countly/countly-server/archive/master.zip
    unzip countly-server-master.zip
    mv ./countly-server-master ./countly
  2. 复制countly web配置文件,并修改配置

    cd /opt/countly/frontend/express/
    cp config.sample.js  config.js
    vi config.js

    mongodb服务器地址host修改为192.168.8.16,保存并退出
    :wq

  3. 复制api配置文件,并修改mongodb host

    cd ../../api/
    cp config.sample.js  config.js
    vi config.js

    mongodb服务器地址host修改为192.168.8.16,保存并退出
    :wq

  4. 复制 countly.config.js

    cd /opt/countly/frontend/express/public/javascripts/countly/
    cp countly.config.sample.js  countly.config.js
  5. 此时如果执行node /opt/countly/api/api.js node会报错误,没有time 组件,需要安装time组件
    使用淘宝提供的源进行安装

    npm --registry http://registry.cnpmjs.org/ install time

    这个时间比较长,会进行node-gyp rebuild,安装完成后,就可以测试node /opt/countly/api/api.jsnode /opt/countly/frontend/express/app.js

4. 配置服务自启动

4.1 安装supervisor 进程管理,设置自启动

  1. 下载并安装supervisor

    cd /opt && wget -c --no-check-certificate https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.1.tar.gz
    tar zxvf supervisor-3.1.1.tar.gz
    cd supervisor-3.1.1
    python setup.py install

    如果出现错误:

    Traceback (most recent call last):
     File "setup.py", line 32, in <module>
       from setuptools import setup, find_packages
    ImportError: No module named setuptools
  2. 下载安装python组件:setuptools17.0

    unzip setuptools-17.0.zip
    cd setuptools-17.0
    python setup.py install
  3. 继续用python安装 supervisor

    cd /opt/supervisor-3.1.1
    python setup.py install
  4. 编辑countly-supervisor.conf
    vi /opt/countly/bin/config/supervisord.conf

    %(here)s/../..%(here)s 替换为/opt/countly,保存修改:wq

  5. 配置supervisor文件
    echo_supervisord_conf > /etc/supervisord.conf
    vi /etc/supervisord.conf

    将最后两行取消注释,改为:

    [include]
    files = /opt/countly/bin/config/supervisord.conf

    保存 :wq

  6. 配置supervisor 自启动

    vi /etc/init.d/supervisor

    添加加入代码:

    #!/bin/bash 
    # supervisor Startup script for the Countly HTTP Server 
    # it is v.0.0.2 version. 
    # chkconfig: - 85 15 
    # description: Countly 
    # processname: supervisor 
    # pidfile: /var/run/supervisor.pid 
    # config: /etc/supervisord.conf 
     
    supervisordd=/usr/local/bin/supervisord
    supervisor_config=/etc/supervisord.conf
    supervisor_pid=/var/run/supervisor.pid
     
    RETVAL=0
    prog="supervisor"
    # Source function library. 
    . /etc/rc.d/init.d/functions
    # Source networking configuration. 
    . /etc/sysconfig/network
    # Check that networking is up. 
     
    [ ${NETWORKING} = "no" ] && exit 0
    [ -x $supervisordd ] || exit 0
    # Start supervisor daemons functions. 
    start() {
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/nodejs/bin
    if [ -e $supervisor_pid ];then
      echo "supervisor already running...."
      exit 1
    fi
      echo  $"Starting $prog with conf:$supervisor_config"
    daemon $supervisordd --configuration ${supervisor_config}
      RETVAL=$?
      echo
      [ $RETVAL = 0 ] && touch /var/lock/subsys/supervisor
      return $RETVAL
    }
     
    # Stop supervisor daemons functions. 
    stop() {
           echo -n $"Stopping $prog: "
           killproc $supervisordd
           RETVAL=$?
           echo
           [ $RETVAL = 0 ] && rm -f /var/lock/subsys/supervisor /var/run/supervisor.pid
    }
     
    # reload supervisor service functions. 
    reload() {
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/nodejs/bin
       echo -n $"Reloading $prog: "
       #kill -HUP `cat ${supervisor_pid}` 
       killproc $supervisordd -HUP
       RETVAL=$?
       echo
    }
     
    # See how we were called. 
    case "$1" in
    start)
           start
           ;;
    stop)
           stop
           ;;
    reload)
           reload
           ;;
    restart)
           stop
           start
           ;;
    status)
           status $prog
           RETVAL=$?
           ;;
    *)
           echo $"Usage: $prog {start|stop|restart|reload|status|help}"
           exit 1
    esac
    exit $RETVAL

    保存修改 :wq
    设置文件属性为可执行

    chmod a+x /etc/init.d/supervisor

    测试:

    service supervisor start

    可以看到:

    Starting supervisor with conf:/etc/supervisord.conf
     
                                                              [确定]
  7. 添加到开机启动项中:
    vi /etc/rc.local

    加入:

    /etc/init.d/supervisor start

    保存 :wq

4.2 配置Nginx自启动

  1. 添加nginx脚本

    vi /etc/init.d/nginx

    加入下面的内容:

    #!/bin/bash 
    # nginx Startup script for the Nginx HTTP Server 
    # it is v.0.0.2 version. 
    # chkconfig: - 85 15 
    # description: Nginx is a high-performance web and proxy server. 
    #              It has a lot of features, but it's not for everyone. 
    # processname: nginx 
    # pidfile: /var/run/nginx.pid 
    # config: /usr/local/nginx/conf/nginx.conf 
    nginxd=/usr/local/nginx/sbin/nginx
    nginx_config=/usr/local/nginx/conf/nginx.conf
    nginx_pid=/var/run/nginx.pid
    RETVAL=0
    prog="nginx"
    # Source function library. 
    . /etc/rc.d/init.d/functions
    # Source networking configuration. 
    . /etc/sysconfig/network
    # Check that networking is up. 
    [ ${NETWORKING} = "no" ] && exit 0
    [ -x $nginxd ] || exit 0
    # Start nginx daemons functions. 
    start() {
    if [ -e $nginx_pid ];then
      echo "nginx already running...."
      exit 1
    fi
      echo -n $"Starting $prog: "
      daemon $nginxd -c ${nginx_config}
      RETVAL=$?
      echo
      [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
      return $RETVAL
    }
    # Stop nginx daemons functions. 
    stop() {
           echo -n $"Stopping $prog: "
           killproc $nginxd
           RETVAL=$?
           echo
           [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
    }
    # reload nginx service functions. 
    reload() {
       echo -n $"Reloading $prog: "
       #kill -HUP `cat ${nginx_pid}` 
       killproc $nginxd -HUP
       RETVAL=$?
       echo
    }
    # See how we were called. 
    case "$1" in
    start)
           start
           ;;
    stop)
           stop
           ;;
    reload)
           reload
           ;;
    restart)
           stop
           start
           ;;
    status)
           status $prog
           RETVAL=$?
           ;;
    *)
           echo $"Usage: $prog {start|stop|restart|reload|status|help}"
           exit 1
    esac
    exit $RETVAL

    保存并退出:wq
    设置文件的访问权限(a+x ==> all user can execute 所有用户可执行)

    chmod a+x /etc/init.d/nginx
  2. 添加到开机启动项中

    vi /etc/rc.local

    加入一行/etc/init.d/nginx start保存并退出,下次重启会生效。

  3. 完成所有配置,重启服务器。

    reboot
  4. 重新打开terminal输入:

    curl localhost

    得到:

    Moved Temporarily. Redirecting to /login

5. 说明

过程中参考了这些文章
安装中文语言支持包
http://www.xshell.net/linux/GNOM.html

CentOS安装NodeJS
http://zhaohe162.blog.163.com/blog/static/38216797201402234212981/

给nodejs的npm更换源
http://blog.sina.com.cn/s/blog_77a8ce670101cdd3.html

升级CentOS5.6_X64 python2.4.3到2.7
http://hxl2009.blog.51cto.com/779549/1031310

python中没有装bz2的库
http://flyer2010.iteye.com/blog/1699946

配置环境变量
http://blog.csdn.net/zhaoweitco/article/details/12677089

CentOS 5.5 下安装Countly Web Server过程记录的更多相关文章

  1. Centos 7.0 下安装 Zabbix server 3.0服务器的安装及 监控主机的加入(1)

    一.本系列分为6部分 1.Centos 7.0 下安装 Zabbix server 3.0服务器的安装及 监控主机的加入 2.Centos 6.5 下安装 Zabbix server 3.0服务器的安 ...

  2. Centos 7.3下 Linux For SQL Server安装及配置介绍

    Centos 7.3下 Linux For SQL Server安装及配置介绍 高文龙关注13人评论2828人阅读2017-03-05 21:46:21 Centos 7.3下Linux For SQ ...

  3. CentOS 6.3下 安装 Mono 3.2 和Jexus 5.4

    最新更新参看: Centos 7.0 安装Mono 3.4 和 Jexus 5.6 2012年初写过一篇<32和64位的CentOS 6.0下 安装 Mono 2.10.8 和Jexus 5.0 ...

  4. yum安装Apache Web Server后各个文件存放位置

    yum安装Apache Web Server后各个文件存放位置   用yum安装apache软件: yum -y install httpd 安装完成后,来查看理解yum安装软件的过程和安装路径.   ...

  5. centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记

    centos 6.5下安装mysql+nginx+redmine 3.1.0 笔记 目录[-] 过程 1.安装RVM 2.利用rvm安装 Ruby 1.9.3 并设为默认 3.安装rails 4.安装 ...

  6. linux/win7下安装websphere application server

    说明: 1.参考网址:http://www.ibm.com/developerworks/cn/aix/library/au-wasonlinux/ 2.在ibm官网上下载websphere appl ...

  7. Centos 5.5下安装samba

    1.安装: Centos 5.5下安装samba,具体步骤如下: [root@bogon ~]# rpm -q samba Package samba is not installed [root@b ...

  8. CentOS 6.6下安装配置Tomcat环境

    本文转载至:http://www.linuxidc.com/Linux/2015-08/122234.htm 实验系统:CentOS 6.6_x86_64 实验前提:防火墙和selinux都关闭 实验 ...

  9. CentOS 6.3下安装Vsftp,虚拟用户

    CentOS 6.3下安装Vsftp,虚拟用户一.安装:1.安装Vsftpd服务相关部件:[root@linuxidc.com ~]# yum install vsftpd*Dependencies ...

随机推荐

  1. Java Cookie和Session(转载)

    一.cookie机制和session机制的区别 具体来说cookie机制采用的是在客户端保持状态的方案,而session机制采用的是在服务器端保持状态的方案. 同时我们也看到,由于才服务器端保持状态的 ...

  2. vi命令的使用

    <转:http://linux.vbird.org/linux_basic/0310vi.php> 基本上 vi 共分为三种模式,分别是『一般模式』.『编辑模式』与『指令列命令模式』. 圖 ...

  3. CentOS 安装 Chrome

    cd  /etc/yum.repos.d/ vi  google.repo [gogle] name=Google-x86_64 baseurl=http://dl.google.com/linux/ ...

  4. ASPxGridView中DetailRow的使用

    ASPxGridView是一个方便的数据显示控件,可是自动的绑定我们所需要的数据,但是有时,当数据属性过多时,我们并不一定要把所有的信息提供给所有的人,当有人需要这些数据时可以自动的进行查看,这时就可 ...

  5. Eclipse CDT 代码高亮配置

    效果图如下: 配置生效方式: 找到CDT的workspace目录中如下文件 X:\workspace\.metadata\.plugins\org.eclipse.core.runtime\.sett ...

  6. Codeforces 633D

    题意: 给定n,和一个长度为n的序列. 让你在这n个数中找长度尽可能长的fib数列. 思路: 这题的数字是在1e9范围内的,所以最长的可能存在的fib数列官方的解释是90左右.有一种情况除外,就是0的 ...

  7. LeetCode Lowest Common Ancestor of a Binary Serach Tree

    Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...

  8. Sqoop导数据出现的问题

    sqoop导数据卡住在INFO mapreduce.Job: Running job: job_1447835049223_0010 查yarn日志全是: INFO org.apache.hadoop ...

  9. (转) C# textbox 限制输入问题

    原理:e.handled代表这次按键动作是否交由用户自己处理,如果为true代表由用户处理,系统不再过问,这里的应用是拦截,即通知系统我要处理这个数据,但又不处理(丢弃数据),从而实现拦截的效果. 在 ...

  10. JavaScript对象的创建之构造函数

    通过构造函数的方式创建和基于工厂的创建类似,最大的区别就是函数的名称就是类的名称,按照java的约定,第一个字母大写. 使用构造函数创建对象时,在函数内部是通过this关键字来完成属性的定义. fun ...