Skip to content

Instantly share code, notes, and snippets.

@jayjariwala
Last active June 15, 2018 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayjariwala/c4e5b0442506e8cc38ea7f7b3024c42e to your computer and use it in GitHub Desktop.
Save jayjariwala/c4e5b0442506e8cc38ea7f7b3024c42e to your computer and use it in GitHub Desktop.
Apostrophe in Production on Digital Ocean or any linux server
1) Create a droplet
You will recieve an email with root password information.
2) login using ssh though your local remote terminal (find your ipaddress on the digital ocean droplet control panel) or use ssh authentication
ssh root@ipaddress
password:write from email
change password upon first login
3) Once login as a root. update latest ubuntu packages
sudo apt-get install update
sudo apt-get install upgrade
4) Add a non-root user with root previlagies
sudo adduser student
setup password
fillout the user details or leave it blank
5) Assign Sudo privilages to the new user
usermod -aG sudo student
6) login as a non-root user (exit -out from root user and ressh or ssh in new terminal window)
ssh student@ipaddress
enter new user password
sucessfully loggedin
7) Setup sshkeys for the new user account so you dont have to enter password everytime to login from the same developer machine.
i) Generate an an ssh-keypair on your local developer machine
ssh-keygen
ii) copy the generated public key from /.ssh/id_rsa.pub file on the developer machine
cat /.ssh/id_rsa.pub
copy the content
iii) On the cloud linux machine on student user create a new folder & file to store sshkey
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
Paste the copied ssh key from the developer machine
chmod 600 ~/.ssh/authorized_keys
exit
8) try login back in with student user name this time it wont ask you for a password.
10) Disable password login (recommanded to make it more secure)
login though root user account
sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
PubkeyAuthentication yes
ChallengeResponseAuthentication no
sudo systemctl reload sshd
now exit the ssh session and logback in though student account using sshkey authernication.
9) Setting up a basic firewall and allowing ssh connections to login
sudo ufw app list
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status
10) nodejs by adding the ppa
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential
11) Intall mongodb
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
** verify if the mongoddb service is running or not
cat /var/log/mongodb/mongod.log
12) Install nginx
sudo apt-get install nginx
13) Allow nginx to access port 80
sudo ufw allow "Nginx HTTP"
or
sudo ufw allow "Nginx HTTPS" for secure site
14) Install imagemagick
sudo apt-get install imagemagick
sudo chmod -R a+r /usr/lib/node_modules/
15) Install mechanic to mange nginx reverse proxy
npm install -g mechanic
# Used to run things indefinitely restarting as needed
npm install -g forever
16) Deoply application using StageCoach deployment system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment