Give permission to Nginx server to access a folder
sudo chown -R amir:amir /var/www/mywebsite
This will make sure that the user
amir has the right access to this folder.
Make your user have access to current and future databases in postgresql
For each existing database, you can grant "amir" the ability to connect and other baseline privileges. Here's an example for a single database called "exampledb":
GRANT ALL PRIVILEGES ON DATABASE exampledb TO amir;
Repeat this for each database you want "amir" to access.
Grant Usage and Default Privileges on All Schemas and Tables
For each database, you will also need to grant permissions on all schemas and their tables. You'll need to connect to each database and run the following commands:
Connect to each database
Grant usage on all schemas
GRANT USAGE ON SCHEMA public TO amir;
Grant privileges on all current tables
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO amir;
Optionally, grant privileges on all future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO amir;
Repeat the connection and grant commands for each database that "amir" needs access to.
Make "amir" a Member of the Superuser Role (Optional and with Caution)
To give "amir" permissions to everything across all databases, including the ability to bypass all permission checks, you could grant superuser status. This is a powerful and risky operation, so it should only be done if absolutely necessary and with a clear understanding of the implications.
ALTER ROLE amir WITH SUPERUSER;