Here are the steps:
- Log into your AWS account or create a new one AWS Account
- Go to AWS EC2 Dashboard
- Launch Instances
- On Application and OS Images (Amazon Machine Image) select
Ubuntu - On Instance Type select
t2.micro(is ok for testing and small projects which is Free tier eligible) - Create or select an existing
key pair. (If you create a new one clickDownload Key Pair) - Click
Launch Instance - On EC2 Dashboard select the new created instance and click
Security - On Security Groups, click on the security group
- On Inbound Rules tab, click
Edit Inbound Rules - Click
Add ruleand selectPostgreSQLfrom the dropdown menu andAnywhere-IPv4. - Click
Save rules - On EC2 Dashboard select the new created instance and click
Connect - Click
SSH Clientand follow the instructions
Once logged into the ec2 instance we perform the following tasks:
Update the local package manager apt
sudo apt updateInstall NodeJS
sudo apt install nodejsCheck the install was ok, you should see the version installed.
node -vInstall npm
sudo apt install npmInstall yarn
sudo npm install yarn -gInstall PostgreSQL
sudo apt-get -y install postgresqlOnce is installed, create a password for the user postgres
sudo su postgrespsqlALTER USER postgres password 'myStrongPassword';Quit psql typing \q
Exit postgres user typing exit
Navigate to main folder inside postgresql/version/
cd /etc/postgresql/14/main/We need to edit two files, pg_hba.conf and postgresql.conf
sudo nano -w pg_hba.confScroll down the file and Add host, all, all, 0.0.0.0/0, md5, has to be the first line before local, all, postgres, , peer
| TYPE | DATABASE | USER | ADDRESS | METHOD |
|---|---|---|---|---|
| host | all | all | 0.0.0.0/0 | md5 |
| local | all | postgres | peer | |
| {: .docs_table} |
Close the file and save the changes with Control+X and Y
sudo nano -w postgresql.confSearch for #listen_addresses='localhost', uncomment the line and replace localhost for *
Close the file and save the changes with Control+X and Y
Restart the PostgreSQL server
sudo service postgresql restartCreate a folder called parse-server
cd ~ && mkdir parse-server && cd parse-serverInstall Parse Server Locally
sudo yarn add parse-serverEdit the package.json file with your preferences, but do not change the start line inside the scripts.
Close the file and save the changes with Control+X and Y
After that, we need to create a configuration file, use your own appId, masterKey and clientKey, use random strings or some generator tool to create secured keys.
sudo nano -w config.json{
"appId": "exampleAppId",
"masterKey": "exampleMasterKey",
"appName": "MyApp",
"serverURL": "http://<IP_OR_DOMAIN>",
"mountPath": "/parse",
"publicServerURL": "http://<IP_OR_DOMAIN>",
"databaseURI": "postgres://postgres:myStrongPassword@localhost:5432/postgres"
}Close the file and save the changes with Control+X and Y
This are the basic options of the config.json file, for the full list you can type parse-server --help or refer to the full options document for more details.
Start Parse Server using the script command in the package.json
npm startCheck if Parse Server is running typing http://<IP_OR_DOMAIN>:1337 in your browser's address bar, you should see {"error":"unauthorized"}, that means the server is running.
To daemonized parse-server to keep it running and alive all the time, you can use the package PM2.
Shutdown Parse Server pressing Control+C.
Check if PM2 is installed
npm list --depth 0 -g pm2If the terminal shows /usr/lib/(empty), means that PM2 is not installed, procced to install PM2 package globally
sudo npm install pm2 -gAdd Parse Server to PM2
pm2 start npm --name "parse-server" -- startSave and syncronize this list
pm2 saveInstall Parse Dashboard globally
sudo npm install -g parse-dashboardOnce installed, you need to configure Parse Dashboard, go to /usr/lib/node_modules/parse-dashboard/Parse-Dashboard/ and edit the file parse-dashboard-config.json
sudo nano -w parse-dashboard-config.jsonThis is an example of parse-dashboard.config.json.
{
"apps": [{
"serverURL": "http://example.com:1337/parse",
"appId": "exampleAppId",
"masterKey": "exampleMasterKey",
"allowInsecureHTTP": "true",
"appName": "MyApp"
}],
"users": [{
"user": "admin",
"pass": "password"
}]
}Start Parse Dashboard
parse-dashboardCheck if Parse Dashboard is running typing http://<IP_OR_DOMAIN>:4040 in your browser's address bar, you should see the login form, use the user and pass that you set in the parse-dashboard-config.json file.
Shutdown Parse Dashboard pressing Control+C.
Add Parse Dashboard to the process manager PM2
pm2 start parse-dashboardSave and syncronize PM2 list
pm2 saveAdding Parse Server and Parse Dashboard to PM2, will ensure that if the server restarts or reboot for some reason, this two apps will be relaunched automatically.
PM2 stores the logs in a subfolder called logs where the apps are. To sneak peek the logs you can run pm2 logs in the terminal.
Note: if you are using a secure certificate in your host, be sure to modify the urls related to your configuration in the examples above from http to https.
{ "name": "my-app", "description": "parse-server for my App", "scripts": { "start": "parse-server config.json" }, "dependencies": { "parse-server": "^5.2.1" } }