As the AWS is more and more popular in recent days, and the large increment of nodejs server on web. For this article, I am going to talk about how to set up the nodejs server for mac, to some extends, for the linux.
Use root to log in
Firstly, when we initialize our aws server, we will get our pem, and each time when we log into our server account, it is quite inconvenient, and a better way to solve this problem is try to use root log in.sudo passwd root
And then we need to change the authority of the following path.sudo chmod 777 /etc/ssh/sshd_config
Do not forget to change it back after we finished part one.vi /etc/ssh/sshd_config
PermitRootLogin //change this to the following line
PermitRootLogin yes //delete the comment
PasswordAuthentication no //change no to yes
UsePAM yes //change yes to no
Modify the authority of the previous file.sudo chmod 644 /etc/ssh/sshd_config
Then restart the aws server, this time, you can use root to login. XD
Install mysql
Follow these commands:
- yum install -y mysql-server mysql mysql-deve
- service mysqld start start mysql
- chkconfig mysqld on to ensure that every time when we start our server mysql is started
Install nodejs
Follow these commands:
yum -y install gcc make gcc-c++ openssl-devel wget
wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
tar -zvxf node-v0.10.26.tar.gz
cd node-v0.10.26
make && make install
node -v
to check has nodejs been installed successfully.
Ps. It has been suggested that install from git may be better 0.0
Here is the url: nodejs on git
Install npm
Follow these commands:
ln -s /usr/local/bin/node /usr/bin/node
wget https://npmjs.org/install.sh
sh install.sh
npm -v
to check has npm been installed successfully.
Install screen
When we run node app
, then we can not do anything. I will advice you to install screen, which can provide us to open another screen to control our server.
yum install screen -y
screen -S newscreen
Open a new screen, if you want to exit this screen, for mac user, user control+a, and then press d.screen -r newscreen
to show that screenscreen -ls
list all the screen names out.
Optional part: install git
Follow these commands:
yum install git -y
mkdir openmind
make the project folder for your projectcd openmind
git init
git remote add gitproject "url"
The url should be git urlcd .git/
vi config
- change the url in config to the url of our git project
cd ../
git pull gitproject master
Additional Note:
For reinstall node and npm for mac:sudo curl -L npmjs.org/install.sh | sudo sh