How to set up the AWS for nodejs? (mac)

2016-01-19

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:

  1. yum install -y mysql-server mysql mysql-deve
  2. service mysqld start start mysql
  3. chkconfig mysqld on to ensure that every time when we start our server mysql is started

Install nodejs

Follow these commands:

  1. yum -y install gcc make gcc-c++ openssl-devel wget
  2. wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz
  3. tar -zvxf node-v0.10.26.tar.gz
  4. cd node-v0.10.26
  5. make && make install
  6. 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:

  1. ln -s /usr/local/bin/node /usr/bin/node
  2. wget https://npmjs.org/install.sh
  3. sh install.sh
  4. 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.

  1. yum install screen -y
  2. screen -S newscreen Open a new screen, if you want to exit this screen, for mac user, user control+a, and then press d.
  3. screen -r newscreen to show that screen
  4. screen -ls list all the screen names out.

Optional part: install git

Follow these commands:

  1. yum install git -y
  2. mkdir openmind make the project folder for your project
  3. cd openmind
  4. git init
  5. git remote add gitproject "url" The url should be git url
  6. cd .git/
  7. vi config
  8. change the url in config to the url of our git project
  9. cd ../
  10. git pull gitproject master

Additional Note:

For reinstall node and npm for mac:
sudo curl -L npmjs.org/install.sh | sudo sh


Comments: