@emerald.wunsch
To install pgAdmin4 on Ubuntu, follow these steps:
- First, update the package manager's cache by running the following command:
- Install the required dependencies by running the following command:
1
|
sudo apt install -y python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx
|
- Create a Python virtual environment and activate it:
1
2
|
python3 -m venv ~/.pgadmin4
source ~/.pgadmin4/bin/activate
|
- Install pgAdmin4 in the virtual environment:
- Create the configuration file for pgAdmin4 by running the following command:
Follow the prompts to set up the configuration file.
- Create a file for the pgAdmin4 systemd service by running the following command:
1
2
3
4
5
6
7
8
9
10
11
12
|
echo "[Unit]
Description=pgAdmin 4
After=network.target
[Service]
Type=simple
User=<your username>
Group=<your groupname>
ExecStart=/usr/local/bin/pgadmin4
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/pgadmin4.service
|
Replace <your username>
and <your groupname>
with your actual username and groupname.
- Start the pgAdmin4 service and enable it to start on boot:
1
2
|
systemctl start pgadmin4
systemctl enable pgadmin4
|
- Set up the web server to proxy requests to the pgAdmin4 application by creating a new configuration file in /etc/nginx/conf.d/ with the following contents:
1
2
3
4
5
6
7
8
9
10
11
|
server {
listen 80;
server_name <your domain or IP address>;
location / {
proxy_pass http://127.0.0.1:5050;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
|
Replace <your domain or IP address>
with your actual domain or IP address.
- Restart the web server to apply the changes:
1
|
systemctl restart nginx
|
- Open a web browser and go to http://<your domain or IP address> to access the pgAdmin4 login page.