mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
20151116-1 选题
This commit is contained in:
parent
41fa51d4b2
commit
89dc32b3f5
@ -0,0 +1,90 @@
|
||||
Linux FAQs with Answers--How to install Node.js on Linux
|
||||
================================================================================
|
||||
> **Question**: How can I install Node.js on [insert your Linux distro]?
|
||||
|
||||
[Node.js][1] is a server-side software platform built on Google's V8 JavaScript engine. Node.js has become a popular choice for building high-performance server-side applications all in JavaScript. What makes Node.js even more attractive for backend server development is the [huge ecosystem][2] of Node.js libraries and applications. Node.js comes with a command line utility called npm which allows you to easily install, version-control, and manage dependencies of Node.js libraries and applications from the vast npm online repository.
|
||||
|
||||
In this tutorial, I will describe **how to install Node.js on major Linux distros including Debian, Ubuntu, Fedora and CentOS**.
|
||||
|
||||
Node.js is available as a pre-built package on some distros (e.g., Fedora or Ubuntu), while you need to install it from its source on other distros. As Node.js is fast evolving, it is recommended to install the latest Node.js from its source, instead of installing an outdated pre-built package. The lasted Node.js comes with npm (Node.js package manager) bundled, allowing you to install external Node.js modules easily.
|
||||
|
||||
### Install Node.js on Debian ###
|
||||
|
||||
Starting from Debian 8 (Jessie), Node.js is available in the official repositories. Thus you can install it with:
|
||||
|
||||
$ sudo apt-get install npm
|
||||
|
||||
On Debian 7 (Wheezy) or earlier, you can install Node.js from its source as follows.
|
||||
|
||||
$ sudo apt-get install python g++ make
|
||||
$ wget http://nodejs.org/dist/node-latest.tar.gz
|
||||
$ tar xvfvz node-latest.tar.gz
|
||||
$ cd node-v0.10.21 (replace a version with your own)
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
### Install Node.js on Ubuntu or Linux Mint ###
|
||||
|
||||
Node.js is included in Ubuntu (13.04 and higher). Thus installation is straightforward. The following will install Node.js and npm.
|
||||
|
||||
$ sudo apt-get install npm
|
||||
$ sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||
|
||||
While stock Ubuntu ships Node.js, you can install a more recent version from [its PPA][3].
|
||||
|
||||
$ sudo apt-get install python-software-properties python g++ make
|
||||
$ sudo add-apt-repository -y ppa:chris-lea/node.js
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install npm
|
||||
|
||||
### Install Node.js on Fedora ###
|
||||
|
||||
Node.js is included in the base repository of Fedora. Therefore you can use yum to install Node.js on Fedora.
|
||||
|
||||
$ sudo yum install npm
|
||||
|
||||
If you want to install the latest version of Node.js, you can build it from its source as follows.
|
||||
|
||||
$ sudo yum groupinstall 'Development Tools'
|
||||
$ wget http://nodejs.org/dist/node-latest.tar.gz
|
||||
$ tar xvfvz node-latest.tar.gz
|
||||
$ cd node-v0.10.21 (replace a version with your own)
|
||||
$ ./configure
|
||||
$ make
|
||||
$ sudo make install
|
||||
|
||||
### Install Node.js on CentOS or RHEL ###
|
||||
|
||||
To install Node.js with yum package manager on CentOS, first enable EPEL repository, and then run:
|
||||
|
||||
$ sudo yum install npm
|
||||
|
||||
If you want to build the latest Node.js on CentOS, follow the same procedure as in Fedora.
|
||||
|
||||
### Install Node.js on Arch Linux ###
|
||||
|
||||
Node.js is available in the Arch Linux community repository. Thus installation is as simple as running:
|
||||
|
||||
$ sudo pacman -S nodejs npm
|
||||
|
||||
### Check the Version of Node.js ###
|
||||
|
||||
Once you have installed Node.js, you can check Node.js version as follows.
|
||||
|
||||
$ node --version
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-node-js-linux.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://nodejs.org/
|
||||
[2]:https://www.npmjs.com/
|
||||
[3]:https://launchpad.net/~chris-lea/+archive/node.js
|
@ -0,0 +1,48 @@
|
||||
Linux FAQs with Answers--How to set JAVA_HOME environment variable automatically on Linux
|
||||
================================================================================
|
||||
> **Question**: I need to compile a Java program on my Linux box. For that I already installed JDK (Java Development Kit), and now I'm trying to set JAVA_HOME environment variable to point to the installed JDK. What is the recommended way to set JAVA_HOME environment variable on Linux?
|
||||
|
||||
Many Java programs or Java-based IDE environments require JAVA_HOME environment variable being set. This environment variable is supposed to point to the top directory where the Java development kit (JDK) or Java runtime environment (JRE) is installed. The JDK contains everything the JRE offers, but also provides additional binaries and libraries needed to compile Java programs (e.g., compilers, debugger, JavaDoc). While the JDK is needed to build Java applications, the JRE alone is sufficient to simply run already built Java programs.
|
||||
|
||||
When you are trying to set JAVA_HOME environment variable, the complication is that JAVA_HOME variable will change depending on (1) whether you installed JDK or JRE, (2) which version of JDK/JRE you installed, and (3) whether you installed Oracle JDK or Open JDK.
|
||||
|
||||
So whenever your build or run-time environment changes (e.g., upgrade to a newer JDK), you need to adjust JAVA_HOME accordingly, which is cumbersome.
|
||||
|
||||
The following export commands will allow you to set JAVA_HOME environment variable automatically regardless of these factors.
|
||||
|
||||
If you installed JRE:
|
||||
|
||||
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
|
||||
|
||||
If you installed JDK:
|
||||
|
||||
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac))))
|
||||
|
||||
Place either of the above commands in ~/.bashrc (or /etc/profile) depending on you installed JDK or JRE, and it will set JAVA_HOME permanently.
|
||||
|
||||
Note that "readlink -f" command is used to get the canonical path since java or javac can be set up with multiple symlinks.
|
||||
|
||||
For example, if you installed Oracle JRE 7, the first export command will automatically set JAVA_HOME to:
|
||||
|
||||
/usr/lib/jvm/java-7-oracle/jre
|
||||
|
||||
If you installed Open JDK version 8, the second export command will set JAVA_HOME to:
|
||||
|
||||
/usr/lib/jvm/java-8-openjdk-amd64
|
||||
|
||||
![](https://c1.staticflickr.com/1/700/22961948071_c73a3261dd_c.jpg)
|
||||
|
||||
In short, these export commands will automatically update JAVA_HOME variable as you re-install/upgrade your JDK/JRE packages or [change default Java version][1]. No need to adjust JAVA_HOME manually.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/set-java_home-environment-variable-linux.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://ask.xmodulo.com/change-default-java-version-linux.html
|
Loading…
Reference in New Issue
Block a user