Supplementary Note:
If we need to be able to access the Nodejs Web site through the browser, generally use Nginx to establish a server, and then set a reverse proxy vhost
server{
Listen 80;
server_name meizi.im www.meizi.im d.meizi.im mz.zhaoyingyong.com mz.naodui.com;
Location/
{
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header remote-host $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Client_max_body_size 50m;
Client_body_buffer_size 256k;
Proxy_connect_timeout 30;
Proxy_send_timeout 30;
Proxy_read_timeout 60;
Proxy_buffer_size 256k;
Proxy_buffers 4 256k;
Proxy_busy_buffers_size 256k;
Proxy_temp_file_write_size 256k;
Proxy_next_upstream Error timeout Invalid_header http_500 http_503 http_404;
Proxy_max_temp_file_size 128m;
Proxy_pass http://127.0.0.1:8081;
}
Access_log/alidata/meizitulog/access.log;
}
Then run app.js to open 8081 node run
I. Installation of NODEJS
Yum-y install gcc gcc-c++ openssl-devel cd/alidata/src/
wget http://nodejs.org/dist/v0.12.3/node-v0.12.3.tar.gz
Tar zxvf node-v0.12.3.tar.gz
CD node-v0.12.3
./configure--prefix=/alidata/node-v0.12.3
Make
Make install
Vim/etc/profile
:/alidata/node-v0.12.3/node_modules:/alidata/node-v0.12.3/bin/
Source/etc/profile-Reboot Effective
NODE-V--Test if the installation was successful
Installing the Express framework
NPM Install Express-g
Install Forever background Manager
It is not possible to manage a remote site directly through the node command, which makes it impossible to keep the site running. We use forever to solve this problem, it can be nodejs application of the way the daemon process, we can also set the Nodejs application to start with the system to run automatically.
NPM Install FOREVER-GD
Install Jade,mogodb
NPM Install Jade Mongoose-g
Install seven cows, como
NPM Install Qiniu como
Second, install MongoDB
1. Installation MongoDB
Cd/alidata/src
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.8.tgz
TAR-ZXVF TAR-ZXVF mongodb-linux-x86_64-2.4.8.tgz
Ln-s mongodb-linux-x86_64-2.4.8 MongoDB
Cd.. /
Mkdir-p/alidata/mongodata/db
Mkdir-p/alidata/mongodata/logs
/alidata/src/mongodb/bin/mongod--dbpath=/alidata/mongodata/db--logpath=/alidata/mongodata/logs/mongodb.log-- Logappend
Cd/alidata/src/mongodb/bin
Without the--dbpath,mongodb, the data file will be placed in the/data/db.
2. Set Boot up
"The following operation is set MongoDB boot, I did not succeed, I was using the following Add environment variable mode"
Cp/alidata/src/mongodb/mogo/etc/init.d/mongod
chmod +x/etc/init.d/mongod
Chkconfig--add Mongod
Chkconfig Mongod on
Service Mongod Start
Pay attention to mongodb.conf.
NPM install-g Node-gyp
"The way the experiment was done."
echo "/alidata/src/mongodb-linux-x86_64-2.4.8/bin/mongod--dbpath=/alidata/mongodata/db--port=27017--logpath=/ Alidata/mongodata/logs/mongodb.log--logappend--auth ">>/etc/rc.local
or direct vim/etc/rc.local will
/alidata/src/mongodb-linux-x86_64-2.4.8/bin/mongod--dbpath=/alidata/mongodata/db--port=27017--logpath=/alidata /mongodata/logs/mongodb.log--logappend--auth
Just put it in the back.
In addition, we use the MONGO command to log in MongoDB and go to the directory where the MONGO command is being executed./mongo, this is not a bit of a hassle. So, we can simplify this, copy the command file to/usr/bin, so that you can use the MONGO command in any directory. or use environment variables
Vim/etc/profile
After the change is done
Execute command source/etc/profile to take effect
echo $PATH View Effective
So you can use MONGO to manipulate MONGO's
3. Use
go to the MongoDB directory and use the command line./mongo can enter MONGO Shell mode
Close MongoDB can only use admin account on admin to operate, otherwise will error