pgAdmin 4 服务器模式端口

问题描述

按照 this 教程,我已经在服务器模式下成功安装了 pgAdmin4。但是,我的 IP 地址可以在认端口上访问 pgAdmin4。我想使用另一个端口(如 8081)进行访问。我尝试修改 /etc/apache2/sites-available/pgadmin4.conf 的内容,但没有成功。提前致谢

<VirtualHost *:8081>
ServerName my_ip

WsgiDaemonProcess pgadmin processes=1 threads=25 python-home=/home/user/environments/my_env
WsgiScriptAlias / /home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi

<Directory "/home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/">
    WsgiProcessGroup pgadmin
    WsgiApplicationGroup %{GLOBAL}
    Require all granted
</Directory>

解决方法

我自己找到了解决方案。

步骤是:

  1. 配置 Apache 以侦听您要服务的每个端口。在ports.conf 文件中添加Listen 8081sudo nano /etc/apache2/ports.conf
  2. 修改pgadmin4.conf的内容如下 sudo nano /etc/apache2/sites-available/pgadmin4.conf

类型

<VirtualHost my_ip:8081>
ServerName my_ip:8081

WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/user/environments/my_env
WSGIScriptAlias / /home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi

<Directory "/home/user/environments/my_env/lib/python3.6/site-packages/pgadmin4/">
    WSGIProcessGroup pgadmin
    WSGIApplicationGroup %{GLOBAL}
    Require all granted
</Directory>
  1. 重启apache