-
-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Parse Server AWS guide #893
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -33,17 +33,14 @@ Check the install was ok, you should see the version installed. | |||||||||||||||||||||||||||||||||
node -v | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Install [npm](https://www.npmjs.com) | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo apt install npm | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Install [yarn](https://yarnpkg.com) | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo npm install yarn –g | ||||||||||||||||||||||||||||||||||
sudo npm install yarn -g | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### Install PostgreSQL Server | ||||||||||||||||||||||||||||||||||
|
@@ -62,89 +59,121 @@ sudo su postgres | |||||||||||||||||||||||||||||||||
psql | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
```sql | ||||||||||||||||||||||||||||||||||
ALTER USER postgres password 'myStrongPassword'; | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Quit psql typing `\q` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Exit postgres user typing `exit` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Navigate to main folder inside postgresql/version/ | ||||||||||||||||||||||||||||||||||
Navigate to main folder inside `postgresql/version/` | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
cd /etc/postgresql/14/main/ | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
We need to edit two files, `pg_hba.conf` and `postgresql.conf` | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo nano pg_hba.conf | ||||||||||||||||||||||||||||||||||
sudo nano -w pg_hba.conf | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Scroll 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} | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. What is the benefit of a table without borders? To me it seems less readable, especially in the example above where the alignment varies. |
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Close the file and save the changes with `Control+X` and `Y` | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo nano postgresql.conf | ||||||||||||||||||||||||||||||||||
sudo nano -w postgresql.conf | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Search for `#listen_addresses='localhost'`, uncomment the line and replace `localhost` for `*` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Close the file and save the changes with `Control+X` and `Y` | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Restart the PostgreSQL server | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo service postgresql restart | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### Setup Parse Server | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Create a directory | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
cd ~ | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Create a folder called parse-server | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
mkdir parse-server | ||||||||||||||||||||||||||||||||||
cd ~ && mkdir parse-server && cd parse-server | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Install Parse Server Locally | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
cd parse-server | ||||||||||||||||||||||||||||||||||
sudo yarn add parse-server | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Run the bash script and follow the instructions, the script have some visual issues and the keys generation doesn't work. | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sh <(curl -fsSL https://raw.githubusercontent.com/parse-community/parse-server/master/bootstrap.sh) | ||||||||||||||||||||||||||||||||||
Comment on lines
-112
to
-114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we abandoning the bash script? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It offers little or no functionality and I decided to install parse-server from npm in this guide (don't remember right now if the bootstrap installs the npm version or the node one..), some functionalities didn't work, and had some visuals faults, I was looking to refactor the bootstrap into a more dynamic one with more options, etc (I think using node installer or something like that, the same I saw in other products), but not sure If I have the knowledge to do it... |
||||||||||||||||||||||||||||||||||
Edit the `package.json` file with your preferences, but do not change the start line inside the scripts. | ||||||||||||||||||||||||||||||||||
```jsonc | ||||||||||||||||||||||||||||||||||
Comment on lines
+112
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
"name": "my-app", | ||||||||||||||||||||||||||||||||||
"description": "parse-server for my App", | ||||||||||||||||||||||||||||||||||
"scripts": { | ||||||||||||||||||||||||||||||||||
"start": "parse-server config.json" | ||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||
"dependencies": { | ||||||||||||||||||||||||||||||||||
"parse-server": "^5.2.1" | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+115
to
+122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
After that, we need to setup the configuration file, use your own `appId`, `masterKey` and `clientKey`, use random strings or some generator tool to create secured keys. | ||||||||||||||||||||||||||||||||||
Close the file and save the changes with `Control+X` and `Y` | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo nano -w config.json | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
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](https://parseplatform.org/parse-server/api/5.2.0/ParseServerOptions.html) for more details. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
```jsonc | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
"appId": "exampleAppId", | ||||||||||||||||||||||||||||||||||
"masterKey": "exampleMasterKey", | ||||||||||||||||||||||||||||||||||
"clientKey": "exampleClientKey", | ||||||||||||||||||||||||||||||||||
"appName": "MyApp", | ||||||||||||||||||||||||||||||||||
"cloud": "./cloud/main", | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we removing the cloud code file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure/don't remember right now, probably because I saw somewhere? or because in this guide I didn't explain how to add the file... ?🤷♂️ |
||||||||||||||||||||||||||||||||||
"serverURL": "http://<IP_OR_DOMAIN>", | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This guide is for AWS so I think it has to be linked to some real ip/domain, (but this guide should work in local linux distribution too... ) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||||||||||||||||||||||||||
"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](https://parseplatform.org/parse-server/api/5.2.0/ParseServerOptions.html) for more details. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Install Parse Server globally | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Start Parse Server using the script command in the package.json | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo npm install -g parse-server | ||||||||||||||||||||||||||||||||||
npm start | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Start Parse Server using the script command in the config.json | ||||||||||||||||||||||||||||||||||
Check 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](https://pm2.keymetrics.io). | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Shutdown Parse Server pressing `Control+C`. | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Check if PM2 is installed | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
npm list --depth 0 -g pm2 | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
If the terminal shows `/usr/lib/(empty)`, means that PM2 is not installed, procced to install PM2 package globally | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
npm start | ||||||||||||||||||||||||||||||||||
sudo npm install pm2 -g | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
or manually with the nohup command and specifying the configuration file, this option will keep the server running even if you close the terminal | ||||||||||||||||||||||||||||||||||
Add Parse Server to PM2 | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
pm2 start npm --name "parse-server" -- start | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Save and syncronize this list | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
nohup parse-server config.json & | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Check if Parse Server is running typing `http://<IP_OR_DOMAIN>:1337` in your browser's address bar, you should see `{"error":"unauthorized"}` | ||||||||||||||||||||||||||||||||||
pm2 save | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
### Setup Parse Dashboard | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
@@ -157,7 +186,7 @@ Once installed, you need to configure Parse Dashboard, go to `/usr/lib/node_modu | |||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
sudo nano -w parse-dashboard-config.json | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
This is an example of parse-dashboard.config.json. | ||||||||||||||||||||||||||||||||||
This is an example of `parse-dashboard.config.json`. | ||||||||||||||||||||||||||||||||||
```jsonc | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
"apps": [{ | ||||||||||||||||||||||||||||||||||
|
@@ -178,10 +207,21 @@ Start Parse Dashboard | |||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
parse-dashboard | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
or with the nohup command and specifying the configuration file, this option will keep the dashboard running even if you close the terminal | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
nohup parse-dashboard --dev --config parse-dashboard-config.json & | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Check 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 | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
pm2 start parse-dashboard | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
Save and syncronize PM2 list | ||||||||||||||||||||||||||||||||||
```bash | ||||||||||||||||||||||||||||||||||
pm2 save | ||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Adding 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`. |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is yarn required in this example? I don't see any yarn command being executed?