pgAdmin 4 服务器模式端口

pgAdmin 4 server mode port

按照 this 教程,我已经在服务器模式下成功安装了 pgAdmin4。但是,pgAdmin4 可以通过默认端口上的我的 IP 地址访问。我想使用另一个端口访问,如 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