I. NPM installation (command line installation)
1: Install node. js first
Sudo apt-Get install Python-software-Properties
Sudo add-Apt-repository PPA: Chris-Lea/node. js
Sudo apt-Get update
Sudo apt-Get install nodejs
Currently, only stable versions of node. js can be installed through PPA.
View the version after installation:
~ $ Node -- version
If RedHat is installed from the source code, the following error is reported:
FPU ='Vfpv3' IfArmv7Else 'Vfpv2'This error!
This indicates that the Python version is too low. Upgrade python.
2: Install NPM
Next:
Ubuntu:
Curl https://npmjs.org/install.sh | sudo sh
Note: For permission reasons, you must add sudo. But add sudo to SH instead of curl.
In addition, if curl is not installed, run the following command to install it:
Sudo apt-Get install curl
Warning: Find: '/usr/lib/node': the file or directory does not exist.
My directory is clearly/usr/lib/nodejs. Why? Let's talk about the problem later.
Recently, when NPM is installed on Redhat, the system prompts that ndoe. JS is not found,
However, I did install it through the source code. The default path is/usr/local/bin. But NPM InstallationProgramThe prompt says that the value of path still output is not found. The path/usr/local/bin does not exist in the output path. But I use echo $ path.
It turned out to be sudo SH, and his $ PATH had only a few poor ones. SH is all there. So I changed the installation command.
Curl https://npmjs.org/install.sh | sh runs successfully and nginx forwards socket. Io successfully.
If this is not done, I tried to download https://npmjs.org/install.shran and install it later. But nginxressed socket.iois always unsuccessful.
Question to be resolved?
1: Why is there a difference between sudo SH and sh? I am working under the root user.
2: Why does nginx fail forwarding in the first case.
3: Install NPM install mysql-libmysqlclient
The error mysql_config cannot be found.
Installation: libmysqld-Dev, and libmysqlclient-Dev. APT-Get install libmysqld-Dev, libmysqlclient-Dev
4: An error occurred while installing mysql-libmysqlclient.
/Src/mysql_bindings_result.cc: In the static member function'StaticMysqlresult: fetch_options mysqlresult: getfetchoptions (V8: Local <V8: Object>:../Src/mysql_bindings_result.cc:235:25: Warning: the member 'mysqlresult: fetch_options: results_as_array 'lacks the initial value [-wmissing-field-initializers].
5:
Mysqlconnectionqueued. prototype = new bindings. mysqlconnection (); ^ typeerror: cannot read property 'mysqlconnection' of null at object. <anonymous> (/home/Zhy/node_modules/MySQL-libmysqlclient/lib/mysql-libmysqlclient.js: 208: 47)
This error has not been resolved yet, I open is from the official website on the top of the node-v0.10.1 and then configure make mkae install. Later I went through the first 1 to 3 steps. This may be a conflict. In the node-v0.10.1 with make uninstall or not. No source code compilation and installation is used on another machine, and the program can be successfully run in the previous steps 1 to 3. Alas, it's big. The Compilation Time of the source code is also special.
Find the solution: uninstall nodejs apt-Get remove nodejs. recompile the source file and install it. At this time, I do not know why I installed it under/usr/local/bin. The command line prompts you to execute node again.
Bash:/usr/bin/node not found. it turns out that there is a bash hash table. In a terminal command window, it will record some of the commands that you have successfully executed. In the same terminal, it will not search for the commands again when it is executed next time. Directly execute the command in the hash table path. Close the terminal and re-open the terminal to execute the node command. Then install mysql-libmysqlclient.NPM install mysql-libmysqlclient. The program is successfully tested.
RedHat Installation
RedHat install redis (it feels troublesome)
I wrote on the official website to copy the file to/usr/local/bin in this way, but I can automatically copy the file to the directory after the source code is compiled.
Sudo CP utils/redis_init_script/etc/init. d/redis
Sudo CP redis. CONF/etc/redis/6378. conf
VI/etc/redis/6378. conf: daemonize YesLoglevel noticelogfile/VaR/Log/Redis. logdir/VaR/Lib/redis
Port 6378
Then add service redis start to/etc/rc. Local. Start redis
Run nodejs in the background
The simplest way to run the nodejs application in the background is:
Nohup node your_app.js &
However, forever can do more things, such as recording output and error logs separately. For example, it can be used as an API in Js.
We simply use it in the command line.
Installation is simple:
Sudo NPM install forever-G
Use forever to start the daemon:
Forever start server. js
Disable the daemon process:
Forever stop server. js
To record output logs and errors:
Forever start-l forever. Log-O out. Log-e err. log server. js
When you run it again, the system will prompt that the forever. log already exists. Use-a to append the log.
Forever start-l forever. Log-O out. Log-e err. Log-a server. js