{"id":162,"date":"2017-01-06T21:14:56","date_gmt":"2017-01-06T11:14:56","guid":{"rendered":"http:\/\/www.codenkeg.com\/blog\/?p=162"},"modified":"2018-03-10T22:13:52","modified_gmt":"2018-03-10T12:13:52","slug":"setting-up-parse-server-on-ubuntu","status":"publish","type":"post","link":"http:\/\/www.codenkeg.com\/blog\/2017\/01\/06\/setting-up-parse-server-on-ubuntu\/","title":{"rendered":"Setting up parse-server on Ubuntu"},"content":{"rendered":"<p><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-run-parse-server-on-ubuntu-14-04\" target=\"_blank\">(Digital Ocean: How To Run Parse Server on Ubuntu 14.04)<\/a><br \/>\n<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-migrate-a-parse-app-to-parse-server-on-ubuntu-14-04\" target=\"_blank\">(Digital Ocean: How To Migrate a Parse App to Parse Server on Ubuntu 14.04)<\/a><br \/>\n<a href=\"https:\/\/github.com\/nodesource\/distributions#installation-instructions\">(GitHub: NodeSource Node.js and io.js Binary Distributions)<\/a><\/p>\n<h2>Before You Begin<\/h2>\n<ol>\n<li>Check for updates<br \/>\n<code>sudo apt-get update && sudo apt-get upgrade<\/code><\/li>\n<\/ol>\n<h2>Install Node.js, Development Tools, other stuff, and parse-server<\/h2>\n<ol>\n<li>Go to user&#8217;s home directory<br \/>\n<code>cd ~<\/code><\/li>\n<li>See <a href=\"https:\/\/github.com\/nodesource\/distributions#installation-instructions\" target=\"_blank\">NodeSource page<\/a> for up-to-date installation instructions<br \/>\n<code>curl -sL https:\/\/deb.nodesource.com\/setup_7.x | sudo -E bash -<\/code><\/li>\n<li>Install nodejs, build-essential and git<br \/>\n<code>sudo apt-get install -y nodejs build-essential git<\/code><\/li>\n<li>Install htop<br \/>\n<code>sudo apt-get install htop<\/code><\/li>\n<li>Install bcrypt<br \/>\n<code>sudo apt-get install bcrypt<\/code><\/li>\n<li>Install tmux to allow processes to run without ssh connection<br \/>\n<code>sudo apt install tmux<\/code><\/li>\n<li>Install parse-server and mongodb-runner (I haven&#8217;t figured out what the runner does)<br \/>\n<code>sudo npm install -g parse-server mongodb-runner<\/code><\/li>\n<\/ol>\n<h2>Setup Parse Cloud Code<\/h2>\n<ol>\n<li>Go to user&#8217;s home directory<br \/>\n<code>cd ~<\/code><\/li>\n<li>Make a cloud directory<br \/>\n<code>mkdir -p ~\/cloud<\/code><\/li>\n<li>Make a <kbd>main.js<\/kbd> file<br \/>\n<code>nano ~\/cloud\/main.js<\/code><\/li>\n<li>Paste\n<pre class=\"lang:js\" title=\"Parse Cloud Code\">Parse.Cloud.define('hello', function(req, res) {\r\n  res.success('Hi');\r\n});<\/pre>\n<\/li>\n<li>Save and exit<\/li>\n<\/ol>\n<h2>Setup a new parse-server app<\/h2>\n<ol>\n<li>Things you need\n<ul>\n<li>App name (long) ${newAppLong}<\/li>\n<li>App name (short) ${newApp}<\/li>\n<li>Password (no funny characters) ${password}<\/li>\n<li>Parse port number ${port}<\/li>\n<li>Parse appId ${appId}<\/li>\n<li>Parse masterKey ${masterKey}<\/li>\n<\/ul>\n<\/li>\n<li>Open port in ufw<br \/>\n<code>sudo ufw allow ${port}<\/code><\/li>\n<li>Add a new user to mongoDB<br \/>\n<code>mongo --port 27017<\/code><br \/>\n<code>use ${newApp}<\/code><br \/>\n<code>db.createUser({user: \"${newApp}\", pwd: \"${password}\", roles: [ { role: \"dbOwner\", db: \"${newApp}\"} ]})<\/code><br \/>\n<code>exit<\/code><\/li>\n<li>Restart MongoDB<br \/>\n<code>sudo service mongod restart<\/code><\/li>\n<li>Configure nginx for ${newApp} (parseapp) as per <a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/24\/setting-up-nginx-on-ubuntu-for-parse-server\/\" target=\"_blank\">Setting up nginx on Ubuntu for parse-server<\/a><\/li>\n<li>Start parse-server on boot<br \/>\n<code>crontab -e<\/code><br \/>\nIf first run, select nano, <kbd>2<\/kbd><br \/>\nAt the bottom of the file add either:<\/p>\n<ul>\n<li>for https:\/\/example.com\/${newApp}\/<br \/>\n<code>@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}\"<\/code><\/li>\n<li>or for https:\/\/${newApp}.example.com\/<br \/>\n<code>@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}\"<\/code><\/li>\n<\/ul>\n<p>Save &#038; exit<\/li>\n<p><!--\t\n\n<li>Start parse-server\n<code>tmux new -s ${newApp} -d<\/code>\n<code>tmux attach -t ${newApp}<\/code>\n<code>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}\"<\/code>\nor\n<code>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}\"<\/code>\n<kbd>ctrl+B<\/kbd> \n<kbd>D<\/kbd> (not <kbd>ctrl+D<\/kbd>)<\/li>\n\n --><\/p>\n<li>Open a new terminal window<\/li>\n<li>Check if npm and node are installed locally<br \/>\n<code>npm -v<\/code><br \/>\n<code>node -v<\/code><\/li>\n<p>If not, download and install from<a href=\"https:\/\/nodejs.org\/\" rel=\"noopener\" target=\"_blank\">https:\/\/nodejs.org\/<\/a><\/p>\n<li>Install parse-dashboard locally<br \/>\n<code>sudo npm install -g parse-dashboard<\/code><\/li>\n<li>Run parse-dashboard locally<br \/>\n<code>parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https:\/\/example.com\/${newApp}\/ --appName \"${newAppLong}\"<\/code><br \/>\nor<br \/>\n<code>parse-dashboard --appId ${appId} --masterKey ${masterKey} --serverURL https:\/\/${newApp}.example.com\/ --appName \"${newAppLong}\"<\/code><\/li>\n<\/ol>\n<h2>Mini series<\/h2>\n<ol>\n<li><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/04\/setting-up-a-server-at-linode\/\" target=\"_blank\">Setting up a server at Linode<\/a><\/li>\n<li><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/06\/install-lets-encrypt-to-create-ssl-certificates\/\" target=\"_blank\">Install Let\u2019s Encrypt to Create SSL Certificates on Ubuntu<\/a><\/li>\n<li><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/06\/setting-up-mongodb-on-ubuntu\/\" target=\"_blank\">Setting up MongoDB on Ubuntu<\/a><\/li>\n<li><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/24\/setting-up-nginx-on-ubuntu-for-parse-server\/\" target=\"_blank\">Setting up nginx on Ubuntu for parse-server<\/a><\/li>\n<li><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/06\/setting-up-parse-server-on-ubuntu\/\" target=\"_blank\">Setting up parse-server on Ubuntu<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>(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 &#038;&#038; sudo apt-get upgrade Install Node.js, Development Tools, other stuff, and parse-server Go to user&#8217;s &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.codenkeg.com\/blog\/2017\/01\/06\/setting-up-parse-server-on-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up parse-server on Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[22],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7VdP6-2C","_links":{"self":[{"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/posts\/162"}],"collection":[{"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":10,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":255,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/posts\/162\/revisions\/255"}],"wp:attachment":[{"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.codenkeg.com\/blog\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}