依賴項安裝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