How to install pgadmin in ubuntu?

by emerald.wunsch , in category: Installation & Upgrades , 2 years ago

How to install pgadmin in ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by mose , 2 years ago

@emerald.wunsch 

To install pgAdmin4 on Ubuntu, follow these steps:

  1. First, make sure that you have the latest version of the package manager apt by running the following command:
1
sudo apt update


  1. Next, install the necessary dependencies by running the following command:
1
sudo apt install python3-pip python3-dev libpq-dev postgresql postgresql-contrib


  1. Now, you can install pgAdmin4 using pip, the Python package manager. Run the following command to install pgAdmin4:
1
pip3 install pgadmin4


  1. After the installation is complete, create a configuration file for pgAdmin4 by running the following command:
1
sudo nano /etc/pgadmin4/config_local.py


  1. Add the following lines to the configuration file and save it:
1
2
3
4
5
6
7
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
SERVER_MODE = False


  1. Create the necessary directories by running the following command:
1
mkdir ~/.pgadmin


  1. Finally, start the pgAdmin4 server by running the following command:
1
pgadmin4


This will start the pgAdmin4 server on your local machine. You can then access it by opening a web browser and navigating to http://localhost:5050.

by alyson_bogan , 2 years ago

@emerald.wunsch 

To install pgAdmin4 on Ubuntu, follow these steps:

  1. First, update the package manager's cache by running the following command:
1
sudo apt update


  1. Install the required dependencies by running the following command:
1
sudo apt install -y python3-pip python3-dev libpq-dev postgresql postgresql-contrib nginx


  1. Create a Python virtual environment and activate it:
1
2
python3 -m venv ~/.pgadmin4
source ~/.pgadmin4/bin/activate


  1. Install pgAdmin4 in the virtual environment:
1
pip install pgadmin4


  1. Create the configuration file for pgAdmin4 by running the following command:
1
pgadmin4-config-setup


Follow the prompts to set up the configuration file.

  1. 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.

  1. Start the pgAdmin4 service and enable it to start on boot:
1
2
systemctl start pgadmin4
systemctl enable pgadmin4


  1. 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.

  1. Restart the web server to apply the changes:
1
systemctl restart nginx


  1. Open a web browser and go to http://<your domain or IP address> to access the pgAdmin4 login page.