Installing pgAdmin 4 on Ubuntu Desktop 16.04

前端之家收集整理的这篇文章主要介绍了Installing pgAdmin 4 on Ubuntu Desktop 16.04前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

pgAdmin 4 v1.0 released on 2016-09-29.

As I was asked about how to install that it can be easily launched like other programs from Ubuntu launcher,I decided to share this with you.

pgAdmin 4 runs with Python 2.

So make sure that you have Python 2 installed on your system. Also we will use pip and virtualenv and for package management and isolating the python environment required to run pgAdmin 4. Run the commands below to install the requirements.

#requirements_install.sh

sudo apt-get install python2.7-dev virtualenv python-pip libpq-dev

Create a directory to init our isolated python environment there.

Let's pick up ~/apps/pgadmin4/ for instance.

#virtualenv_activation.sh

mkdir -p ~/apps/pgadmin4/
cd ~/apps/pgadmin4
virtualenv venv -p /usr/bin/python2.7
source ./venv/bin/activate

Now that you have cloned the environment,you should download and install the wheel package of pgAdmin 4 from here .

#pgadmin4_install.sh

wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl
pip install pgadmin4-1.4-py2.py3-none-any.whl

pgAdmin4 needs config_local.py to run.

This file can be cloned from the existing config.py from current installation path.

#clone_config.sh

cp ./venv/lib/python2.7/site-packages/pgadmin4/config.py \
./venv/lib/python2.7/site-packages/pgadmin4/config_local.py

You can change the initial values for SECRET_KEY,SECURITY_PASSWORD_SALT and CSRF_SESSION_KEY manually in this file.

Test your installation by running:

#test_installation.sh

python ./venv/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py

You may be prompted to enter email and password for new user registeration.

Once you have provided the needed information,you can access the app by browsing http://127.0.0.1:5050/

Now that we are sure about the success in running pgAdmin 4 by calling the prevIoUs command,let's create an Ubuntu launcher for this application.

Create pgAdmin4.sh and pgAdmin4.desktop files:

#create_launcher.sh

touch pgAdmin4.sh pgAdmin4.desktop
chmod +x pgAdmin4.sh pgAdmin4.desktop

Put the contents below in pgAdmin4.sh:

pgAdmin4.sh

#! /bin/bash
source ~/apps/pgadmin4/venv/bin/activate
python ~/apps/pgadmin4/venv/local/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py &

sleep 5; sensible-browser http://127.0.0.1:5050

Put the contents below in pgAdmin4.desktop:

#pgAdmin4.desktop

[Desktop Entry]
Name=pgAdmin 4
Exec=/home/user/apps/pgadmin4/pgAdmin4.sh
Icon=/home/user/apps/pgadmin4/pgadmin.svg
Type=Application
Categories=Database;
Terminal=false

Link pgAdmin4.desktop to ~/.local/share/applications/ that Ubuntu can autoload the launcher.

#link_launcher.sh

ln -s ~/apps/pgadmin4/pgAdmin4.desktop ~/.local/share/applications/

Download pgAdmin icon . and save it to ~/apps/pagadmin4/ as pgadmin.svg.

You can also use the command below:

#download_svg_icon.sh

wget http://kiahosseini.github.io/assets/image/pgadmin4_install/pgadmin.svg

That's all.

It should now open your browser[tab] loading http://127.0.0.1:5050.

You may see an error in loading the page. Try to refresh the page in this case. It may take longer to launch the server. Be patient!

猜你在找的Ubuntu相关文章