以Server的模式运行pgAdmin4
pgAdmin4 是随PostgreSQL9.6推出的新一代PostgreSQL管理工具。 pgAdmin4默认是以python的server端和qtwebkit的客户端的组合但桌面工具发布的,README中也说了可以以独立的Server模式运行,本文(以python2.7为例)就介绍下Ubunte(CentOS相差不多)下如何编译并以Server模式运行它。 首先安装virtualenv虚拟环境
1 2 3 4 |
sudo pip install virtualenvwrapper virtualenv pgadmin4 cd pgadmin4/ source bin/activate |
下载pgAdmin4的源代码包,两张模式
1 2 3 |
wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/source/pgadmin4-1.1.tar.gz tar xf pgadmin4-1.1.tar.gz cd pgadmin4-1.1/ |
或者
1 2 |
git clone git://git.postgresql.org/git/pgadmin4.git cd pgadmin4 |
requirements_py2.txt有个小bug,fix先,安装前确保PostgreSQL 开发库已经安装,否则报pg_config未找到的错误,具体安装方法如下,
1 2 3 |
sudo apt-get install libpq-dev #如果是CentOS,可以使用下面的命令, #yum install postgresql-devel |
然后安装依赖库
1 2 |
sed -i 's/;.*//' requirements_py2.txt pip install -r requirements_py2.txt |
安装pgAdmin4,按提示输入邮箱地址和密码,
1 |
python web/setup.py |
1 2 3 4 5 6 7 8 9 10 11 |
(pgadmin4)witwall:~/pgadmin4/pgadmin4-1.1 $ python web/setup.py pgAdmin 4 - Application Initialisation ====================================== The configuration database - '/home/ubuntu/.pgadmin/pgadmin4.db' does not exist. Entering initial setup mode... NOTE: Configuring authentication for SERVER mode. Enter the email address and password to use for the initial pgAdmin user account: Email address: pg@alitrack.com Password: Retype password: The configuration database has been created at /home/ubuntu/.pgadmin/pgadmin4.db |
到这一步,就算基本安装完成,可以运行了,
1 |
python web/pgAdmin4.py |
然后你会发现,只能本机访问,端口是5050,这不是我想要的,
1 |
Starting pgAdmin 4. Please navigate to http://localhost:5050 in your browser. |
…