In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use Shell scripts to quickly build the Nodejs development environment under Ubuntu, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Nodejs is really very popular, has been tossed around before, but has never seriously recorded anything. Try to build its development environment under ubuntu. There is a shortcut that allows the system to automatically install what you need. Let's generate a shell script to do the following:
Install the latest node,node package manager under git, Forever and Cloud9IDE tools (optional), mongodb 10gen
Note: the proper operation of the script requires a newer version of Ubuntu and needs to be networked because it connects to the network to download all dependent packages installed sequentially.
1. Script code:
#! / bin/sh
Echo 'System Update'
Apt-get update
Echo 'Update completed'
Apt-get install libssl-dev git-core pkg-config build-essential curl
Echo 'Clone Node.js'
Cd / usr/src
Git clone https://github.com/joyent/node
Echo 'Node.js clone completed'
Echo 'Install Node.js'
Cd node
. / configure & & make & & make install
Echo 'Node.js install completed'
Echo 'Install Node Package Manager'
Curl http://npmjs.org/install.sh | sh
Echo 'NPM install completed'
Echo 'Install Forever'
Npm install forever
Echo 'Forever install completed'
Echo 'Install Cloud9IDE'
Git clone git://github.com/ajaxorg/cloud9.git
Echo 'Cloud9IDE install completed'
Echo 'Install MongoDB'
Sudo apt-key adv-keyserver keyserver.ubuntu.com-recv 7F0CEB10
Echo "deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen" > > / etc/apt/sources.list
Sudo apt-key adv-keyserver keyserver.ubuntu.com-recv 7F0CEB10
Sudo apt-get update
Sudo apt-get install mongodb-10gen
Echo 'MongoDB install completed.'
two。 Save the script to a file:
The code is as follows:
$cd ~ /
$nano-w node.sh
Paste the above code into the node.sh file, save it with ctrl+o, and exit nano with ctrl+x. If you don't have nano installed, please google it.
3. Execute the script:
The code is as follows:
$chmod axix node.sh & & sudo. / node.sh
Once installed, take a look at the node version: node-v to see if the installation is successful.
4. Set up the test:
The code is as follows:
Mkdir node_project
Cd node_project
Nano-w server.js
Here is the famous nodejs server code:
The code is as follows:
Var http = require ('http')
Http.createServer (function (req, res) {
Res.writeHead (200,{ 'Content-Type':' text/plain'})
Res.end ('Hello World\ n')
}) .customers (1337, "127.0.0.1")
Console.log ('Server running at http://127.0.0.1:1337/');
Run the code: node server.js
Open in browser: http://127.0.0.1:1337
The above is all the contents of the article "how to use Shell scripts to quickly build a Nodejs development environment under Ubuntu". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.