(Digital Ocean: How To Run Parse Server on Ubuntu 14.04)
(Digital Ocean: How To Migrate a Parse App to Parse Server on Ubuntu 14.04)
(GitHub: NodeSource Node.js and io.js Binary Distributions)
Before You Begin
- Check for updates
sudo apt-get update && sudo apt-get upgrade
Install Node.js, Development Tools, other stuff, and parse-server
- Go to user’s home directory
cd ~
- See NodeSource page for up-to-date installation instructions
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
- Install nodejs, build-essential and git
sudo apt-get install -y nodejs build-essential git
- Install htop
sudo apt-get install htop
- Install bcrypt
sudo apt-get install bcrypt
- Install tmux to allow processes to run without ssh connection
sudo apt install tmux
- Install parse-server and mongodb-runner (I haven’t figured out what the runner does)
sudo npm install -g parse-server mongodb-runner
Setup Parse Cloud Code
- Go to user’s home directory
cd ~
- Make a cloud directory
mkdir -p ~/cloud
- Make a main.js file
nano ~/cloud/main.js
- Paste
Parse.Cloud.define('hello', function(req, res) { res.success('Hi'); });
- Save and exit
Setup a new parse-server app
- Things you need
- App name (long) ${newAppLong}
- App name (short) ${newApp}
- Password (no funny characters) ${password}
- Parse port number ${port}
- Parse appId ${appId}
- Parse masterKey ${masterKey}
- Open port in ufw
sudo ufw allow ${port}
- Add a new user to mongoDB
mongo --port 27017
use ${newApp}
db.createUser({user: "${newApp}", pwd: "${password}", roles: [ { role: "dbOwner", db: "${newApp}"} ]})
exit
- Restart MongoDB
sudo service mongod restart
- Configure nginx for ${newApp} (parseapp) as per Setting up nginx on Ubuntu for parse-server
- Start parse-server on boot
crontab -e
If first run, select nano, 2
At the bottom of the file add either:- for https://example.com/${newApp}/
@reboot tmux new-session -s test -d parse-server --port ${port} --appId ${appId} --masterKey ${masterKey} --databaseURI mongodb://${newApp}:${password}@localhost:27017/${newApp} --cloud /home/parse/cloud/main.js --serverURL https://example.com/${newApp}/ --appName "${newAppLong}"
- or for https://${newApp}.example.com/
@reboot tmux new-session -s test -d parse-server --port ${port} --appId ${appId} --masterKey ${masterKey} --databaseURI mongodb://${newApp}:${password}@localhost:27017/${newApp} --cloud /home/${currentUser}/cloud/main.js --serverURL https://${newApp}.example.com/ --appName "${newAppLong}"
Save & exit
- for https://example.com/${newApp}/
- Open a new terminal window
- Check if npm and node are installed locally
npm -v
node -v
- Install parse-dashboard locally
sudo npm install -g parse-dashboard
- Run parse-dashboard locally
parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https://example.com/${newApp}/ --appName "${newAppLong}"
or
parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https://${newApp}.example.com/ --appName "${newAppLong}"
If not, download and install fromhttps://nodejs.org/
One Reply to “Setting up parse-server on Ubuntu”
Comments are closed.