依赖项安装javascript
yum -y install gcc gcc-c++ openssl-devel
下载并解压安装 nodejshtml
cd /optwget –c http://nodejs.org/dist/v0.12.4/node-v0.12.4.tar.gztar zxvf node-v0.12.4.tar.gzcd node-v0.12.4./configure --prefix=/usr/local/nodejsmake && make install
注意此时会有错误输出信息:java
这是由于Python当前版本 2.4.3 不够,须要升级Pythonnode
升级Python:python
正常状况下即便python2.7安装成功后,系统默认指向的python仍然是2.4.3版本,考虑到yum是基于python2.4.3才能正常工做,不敢轻易卸载。 解决方法:linux
mv /usr/bin/python /usr/bin/python.bakln -s /usr/local/bin/python2.7 /usr/bin/python
将第一行显示的vi /usr/bin/yum
#/usr/bin/python
修改成#/usr/bin/python2.4
保存修改:wq
继续上面的步骤从新安装NodeJS:nginx
注意,又有新的错误:c++
ImportError: No module named bz2make[1]: *** [/opt/node-v0.12.4/out/Release/obj/gen/libraries.cc] 错误 1make[1]: Leaving directory '/opt/node-v0.12.4/out'make: *** [node] 错误 2
这个错误是因为python中没有装bz2的库致使的git
继续安装bz2github
yum install -y bzip2*cd /opt/Python-2.7.2/Modules/zlib./configuremake && make install
从新安装python
继续上面的步骤从新安装NodeJS:
此次应该能够安装成功了
配置NodeJS环境变量
在vim /etc/profile
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
一行的【上面】添加以下内容:#set for nodejsexport NODE_HOME=/usr/local/nodejsexport PATH=$NODE_HOME/bin:$PATH
:wq
保存并退出,编译/etc/profile 使配置生效输入测试:source /etc/profile
获得版本号node -v
v0.12.4
在安装nginx前,须要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel 和libevent
yum install pcre-devel libevent opensslyum -y install zlib zlib-devel pcre
下载、解压安装Nginx
wget -c http://nginx.org/download/nginx-1.8.0.tar.gztar –zxv –f nginx-1.8.0.tar.gzcd nginx-1.8.0./configure --prefix=/usr/local/nginxmake && make install
测试nginx 开启:
/usr/local/nginx/sbin/nginx
测试http访问
curl localhost
获得如下输出信息表示成功安装并开启nginx
<!DOCTYPE html><html><head><title>Welcome to nginx!</title><style>body</style></head><body><h1>Welcome to nginx!</h1><p>If you see this page, the nginx web server is successfully installed andworking. 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
下载到/opt,并解压
cd /optwget –c https://github.com/Countly/countly-server/archive/master.zipunzip countly-server-master.zipmv ./countly-server-master ./countly
复制countly web配置文件,并修改配置
cd /opt/countly/frontend/express/cp config.sample.js config.jsvi config.js
将mongodb
服务器地址host
修改成192.168.8.16
,保存并退出 :wq
复制api配置文件,并修改mongodb host
cd ../../api/cp config.sample.js config.jsvi config.js
将mongodb
服务器地址host
修改成192.168.8.16
,保存并退出 :wq
复制 countly.config.js
cd /opt/countly/frontend/express/public/javascripts/countly/cp countly.config.sample.js countly.config.js
此时若是执行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.js
和 node /opt/countly/frontend/express/app.js
了
下载并安装supervisor
cd /opt && wget -c --no-check-certificate https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.1.tar.gztar zxvf supervisor-3.1.1.tar.gzcd supervisor-3.1.1python setup.py install
若是出现错误:
Traceback :File "setup.py", line 32, in <module>from setuptools import setup, find_packagesImportError: No module named setuptools
下载安装python组件:setuptools17.0
unzip setuptools-17.0.zipcd setuptools-17.0python setup.py install
继续用python安装 supervisor
cd /opt/supervisor-3.1.1python setup.py install
将vi /opt/countly/bin/config/supervisord.conf
%(here)s/../..
和%(here)s
替换为/opt/countly
,保存修改:wq
将最后两行取消注释,改成:echo_supervisord_conf > /etc/supervisord.confvi /etc/supervisord.conf
保存
:wq
配置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.confsupervisordd=/usr/local/bin/supervisordsupervisor_config=/etc/supervisord.confsupervisor_pid=/var/run/supervisor.pidRETVAL=0prog="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.# Stop supervisor daemons functions.# reload supervisor service functions.# See how we were called.
保存修改 :wq
设置文件属性为可执行
chmod a+x /etc/init.d/supervisor
测试:
service supervisor start
能够看到:
Starting supervisor with conf:/etc/supervisord.conf[肯定]
加入:vi /etc/rc.local
保存/etc/init.d/supervisor start
:wq
添加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.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="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.# Stop nginx daemons functions.# reload nginx service functions.# See how we were called.
保存并退出:wq
设置文件的访问权限(a+x
==> all user can execute 全部用户可执行)
chmod a+x /etc/init.d/nginx
添加到开机启动项中
vi /etc/rc.local
加入一行/etc/init.d/nginx start
保存并退出,下次重启会生效。
完成全部配置,重启服务器。
reboot
从新打开terminal输入:
curl localhost
获得:
Moved Temporarily. Redirecting to /login
过程当中参考了这些文章 安装中文语言支持包 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