How to build a node.js development environment on Linux virtual machine

PHPz
Release: 2023-05-28 22:43:39
forward
1909 people have browsed it

1. Install the linux system

(You can skip this step if you have installed linux)

Recommended virtual machine options: virtualbox or vmware ( Professional version permanent activation code: 5a02h-au243-tzj49-gtc7k-3c61n)
I use vmware here.
After installing vmware, click New Virtual Machine, select to install the operating system later, and then configure it. The virtual machine settings are as follows:

{

Client operating system: other;

Version: other 64-bit;

Virtual machine name: node.js ;

Location: d:\vm\node.js ;

Other defaults;

}

The virtual machine is now built, and the configuration is as shown shown.

How to build a node.js development environment on Linux virtual machine

#There is a problem that needs attention: it is the network adapter of the virtual machine. I choose bridge mode here. In this mode, the operating system virtualized by vmware is like an independent host in the LAN (the host and the virtual machine are in a peer-to-peer status), and it can access any machine in the network. (My host IP here is 192.168.1.49 and the virtual machine IP is 192.168.1.59). If your network environment is not suitable for bridging, please select NAT mode.

Then download the image. I choose centos as the system. Of course, other Linux systems are also available. Directly click the first one on Baidu centos download, and then download dvdiso. About 4GB.

After downloading the image, click Virtual Machine Settings and select the iso image file in the cd/dvd tab.

Click Start, go to our virtual machine, and select the first one to start the installation.

1. During the installation process, use the default language (english), and then click continue to continue.

2. Click here

How to build a node.js development environment on Linux virtual machine

# to select basic web server, select development tools on the right, and then click done to return. How to build a node.js development environment on Linux virtual machine

3. Click

How to build a node.js development environment on Linux virtual machine

Although the default and selection are

How to build a node.js development environment on Linux virtual machine

But you still have to click again to select

and then click the button in the lower right corner to start the installation.

While waiting for the installation, click

How to build a node.js development environment on Linux virtual machine

to start setting the administrator password. After setting up, wait for the installation to complete, about 3-5 minutes. After the installation is complete, click the reboot button to restart.

Username after restart: root Password: The password just set during the installation process.

At this point centos installation is complete, let’s simply make some settings.

Use vi to modify the network card configuration file in the etc/sysconfig/network-scripts/ directory, and modify the last onboot to yes. Because by default in centos7, the network card is turned off. After the modification is completed, wq save and exit. As shown in the figure below
How to build a node.js development environment on Linux virtual machine
After modifying the configuration file, enter the command systemctl restart network to restart the virtual machine network.

Enter the command ifconfig and you can see that the IP address has been obtained. How to build a node.js development environment on Linux virtual machine
If you are worried, you can also try pinging. At this time, the virtual machine has been connected to the external network.

2. Nodejs and related software installation

Write an xshell installation first. (Optional, not installing will not affect nodejs development)

xshell: xshell can be used to access remote servers under different systems under the windows interface, so as to better achieve the purpose of remote control terminals.

Personally, I feel it is easier to use. After the installation is completed, click New, enter the name node, host node, port number 22, and then enter the login name root and password to enter centos. Because the virtual machine here is bridged, so that the IP of the virtual machine will not change in the future, I added 192.168.1.59 node at the end of the c:\windows\system32\drivers\etc\hosts file. In the future, the IP address of the virtual machine will be fixed here to facilitate subsequent development.

/*****************I am the willful dividing line*******************************/

Now install a few things in centos (must!)

1. Install an epel and enter the command

yum install epel-release
Copy after login

2. Install nodejs, enter the command

yum install nodejs
Copy after login

After waiting for the download and installation to complete, enter the command node --version to check whether the version number is installed.

3. Install the mongodb server and enter the command

yum install mongodb-server
Copy after login

4. Install the mongodb client and enter the command

yum install mongodb
Copy after login

等待下载安装完成后,输入命令mongo --version查看版本号是否安装完成

5.安装redis,输入命令

yum install redis
Copy after login

等待下载安装完成后,输入命令redis-cli --version查看版本号是否安装完成

三.node测试运行

下面简单写个小程序来运行一下。

vim test.js

var name = "qin";
console.log("hello "+name);
Copy after login

wq保存退出,输入命令node test.js ,即可看到结果。

How to build a node.js development environment on Linux virtual machine

The above is the detailed content of How to build a node.js development environment on Linux virtual machine. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!