因為試drupal 的node integration , 用virtual box 裝centos 6建立nodejs環境,記錄一下.
-------------------------------------------------------------------
- 先安裝php5.3 , mysql, phpmyadmin 及其它extension packages
- yum -y update
- su -c 'rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm' //設置一下 EPEL
- yum repolist
- yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-mcrypt php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
- /sbin/chkconfig httpd on
- /sbin/chkconfig –-add mysqld
- /sbin/chkconfig mysqld on
- /sbin/service httpd start
- /sbin/service mysqld start
- mysqladmin -u root password ‘password’
- mysql -u root -p //新密碼
- mysql> DROP DATABASE test;
- mysql> DELETE FROM mysql.user WHERE user = ”;
- mysql> FLUSH PRIVILEGES;
- 因為只是測試,把firewall都關了
- service iptables stop
- echo 0 >/selinux/enforce
- setenforce 0
- service sshd start //用putty,winscp比較方便
- winscp上傳phpmyadmin 到/var/www/html/
- config.sample.inc.php改名config.inc.php及修改.
- $cfg['blowfish_secret'] = ”;//改口令
- $cfg['Servers'][$i]['controluser'] = ‘pma’; //改username
- $cfg['Servers'][$i]['controlpass'] = ‘pmapass’; //改password
- // $cfg['Servers'][$i]['pmadb'] = ‘phpmyadmin’;
- // $cfg['Servers'][$i]['bookmarktable'] = ‘pma_bookmark’;
- // $cfg['Servers'][$i]['relation'] = ‘pma_relation’;
- // $cfg['Servers'][$i]['table_info'] = ‘pma_table_info’;
- // $cfg['Servers'][$i]['table_coords'] = ‘pma_table_coords’;
- // $cfg['Servers'][$i]['pdf_pages'] = ‘pma_pdf_pages’;
- // $cfg['Servers'][$i]['column_info'] = ‘pma_column_info’;
- // $cfg['Servers'][$i]['history'] = ‘pma_history’;
- // $cfg['Servers'][$i]['designer_coords'] = ‘pma_designer_coords’;
- 去掉comment //
- -------------------------------------------------------------------
- 安裝git
- yum install git
- 因為nodejs的版本經常更新,所以開發時可能要轉換不同的nodejs 版本.
- 所以要用nvm .
- git clone git:///creationix/nvm.git ~/.nvm
- . ~/.nvm/nvm.sh
- yum install gcc-c++ openssl-devel //裝nodejs 時要用
- nvm install v0.6.7 //安裝0.6.7版本 , 預設會裝最新的0.7.0pre
- nvm ls //顯示已裝的版本 current: v0.6.7
- cd ~/.nvm/v0.6.7/bin
- curl http://npmjs.org/ | sh //裝0.6.7相容的npm , nvm比nave的好處就是可以獨立的nodejs版本裝相應的npm
- --------------------------------------
- 裝多一個nodejs v0.4.7版本
- nvm install v0.4.7
- cd ~/.nvm/v0.4.7/bin
- curl http://npmjs.org/ | sh
- nvm ls //列出已安裝nodejs版本
- nvm use v0.4.7 //選用想要版本
- --------------------------------------
- cd /usr/local/
- mkdir node
- 下載一個用socket.io 的realtime chat 作測試
- wget http:///wp-content/lessons/realtimeChat-Socket-IO/realtimeChat_SocketIO.zip
- unzip realtimeChat_SocketIO.zip -d ./realtimechat
- cd realtimechat //看到兩個檔client.html , index.js
- npm install socket.io@0.8.7 //因為用到socket.io
- vim index.js //把最底的app.listen(1337,'127.0.0.1'); 改做你想要的port位,ip.我用virtual box 所以localhost不行,要改用內網ip 192.168.1.xxx
- node index.js //看到info - socket.io started
- 到http://192.168.1.xxx:1337 測試吧!
- -------------------------------------------------------------------
- nodejs 測試完畢,裝drupal
- wget --quiet -O - http:///files/projects/drush-7.x-4.4.tar.gz | sudo tar -zxf - -C /usr/local/share
- ln -s /usr/local/share/drush/drush /usr/local/bin/drush
- chmod 755 -R /var/www/html
- chown apache -R /var/www/html
- chgrp apache -R /var/www/html
- cd /var/www/html
- drush dl drupal-7.10
- 安裝drupalchat , nodejs integration modules
- copy drupalchat_nodejs.server.extension.js 到nodejs module folder入面
- cd /var/www/html/drupal-7.10/sites/all/modules/nodejs
- npm install -d //安裝socket.io,connect,express,request
- copy一個nodejs.config.js
- -------------------------------------------------------
- settings = {
- scheme: 'http',
- port: 8080,
- host: '192.168.1.113',
- resource: '/socket.io',
- serviceKey: '',
- backend: {
- port: 80,
- host: '192.168.1.113',
- scheme: 'http',
- basePath: '',
- messagePath: '/nodejs/message'
- },
- debug: false,
- sslKeyPath: '',
- sslCertPath: '',
- baseAuthPath: '/nodejs/',
- publishUrl: 'publish',
- kickUserUrl: 'user/kick/:uid',
- logoutUserUrl: 'user/logout/:authtoken',
- addUserToChannelUrl: 'user/channel/add/:channel/:uid',
- removeUserFromChannelUrl: 'user/channel/remove/:channel/:uid',
- addChannelUrl: 'channel/add/:channel',
- removeChannelUrl: 'channel/remove/:channel',
- setUserPresenceListUrl: 'user/presence-list/:uid/:uidList',
- addAuthTokenToChannelUrl: 'authtoken/channel/add/:channel/:uid',
- removeAuthTokenFromChannelUrl: 'authtoken/channel/remove/:channel/:uid',
- toggleDebugUrl: 'debug/toggle',
- contentTokenUrl: 'content/token',
- publishMessageToContentChannelUrl: 'content/token/message',
- "extensions":['drupalchat_nodejs.server.extension.js'],
- clientsCanWriteToChannels: false,
- clientsCanWriteToClients: false,
- transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling'],
- jsMinification: true,
- jsEtag: true,
- logLevel: 1
- };
- ----------------------------------------------------------------------
- node server.js
- 成功了..
















