我正在Ubuntu 18.04上的笔记本电脑上工作,并且想像使用服务器一样尝试使用pgadmin
和Apache
。我遵循this tutorial并按照指示进行操作,但我使用conda创建的虚拟环境除外:
conda create -n pgadmin python=3.6
对于/etc/apache2/sites-available/pgadmin4.conf
中的ServerName,我只是使用了从hostname -I
获得的第一个IP W.X.Y.Z地址:
<VirtualHost *>
ServerName W.X.Y.Z
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/sammy/python_envs/pgadmin
WSGIScriptAlias / /home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi
<Directory "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/">
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
仅使用笔记本电脑,默认的Apache网站就可以在浏览器上的该IP上正常运行,但是,在激活gadmin4网站(sudo a2ensite pgadmin4.conf
)后使用相同的IP时,我收到了来自Apache的错误消息:< / p>
内部服务器错误服务器遇到内部错误或 配置错误,无法完成您的请求。
请通过[未提供地址]与服务器管理员联系以 告知他们该错误发生的时间以及您的操作 在此错误之前执行。
有关此错误的更多信息可能在服务器错误中可用 日志。
位于W.X.Y.Z端口80的Apache / 2.4.29(Ubuntu)服务器
Apache检查(apachectl configtest
)看起来不错:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK
来自Apache(/var/log/apache2/error.log
)的完整错误日志包含以下内容:
[Wed Dec 26 14:32:08.810269 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] mod_wsgi (pid=59825): Target WSGI script '/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi' cannot be loaded as Python module.
[Wed Dec 26 14:32:08.810825 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] mod_wsgi (pid=59825): Exception occurred processing WSGI script '/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi'.
[Wed Dec 26 14:32:08.811011 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] Traceback (most recent call last):
[Wed Dec 26 14:32:08.811061 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi", line 36, in <module>
[Wed Dec 26 14:32:08.811097 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from pgAdmin4 import app as application
[Wed Dec 26 14:32:08.811107 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 70, in <module>
[Wed Dec 26 14:32:08.811110 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] app = create_app()
[Wed Dec 26 14:32:08.811115 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 374, in create_app
[Wed Dec 26 14:32:08.811131 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] driver.init_app(app)
[Wed Dec 26 14:32:08.811135 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/__init__.py", line 40, in init_app
[Wed Dec 26 14:32:08.811137 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] DriverRegistry.load_drivers()
[Wed Dec 26 14:32:08.811142 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/registry.py", line 88, in load_drivers
[Wed Dec 26 14:32:08.811144 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] module = import_module(module_name)
[Wed Dec 26 14:32:08.811148 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/importlib/__init__.py", line 126, in import_module
[Wed Dec 26 14:32:08.811151 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Dec 26 14:32:08.811154 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/psycopg2/__init__.py", line 27, in <module>
[Wed Dec 26 14:32:08.811157 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from .server_manager import ServerManager
[Wed Dec 26 14:32:08.811161 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/psycopg2/server_manager.py", line 27, in <module>
[Wed Dec 26 14:32:08.811174 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
[Wed Dec 26 14:32:08.811179 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/sshtunnel.py", line 25, in <module>
[Wed Dec 26 14:32:08.811181 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] import paramiko
[Wed Dec 26 14:32:08.811185 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/__init__.py", line 22, in <module>
[Wed Dec 26 14:32:08.811187 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from paramiko.transport import SecurityOptions, Transport
[Wed Dec 26 14:32:08.811190 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/transport.py", line 38, in <module>
[Wed Dec 26 14:32:08.811193 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from paramiko.auth_handler import AuthHandler
[Wed Dec 26 14:32:08.811196 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/auth_handler.py", line 72, in <module>
[Wed Dec 26 14:32:08.811198 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
[Wed Dec 26 14:32:08.811201 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/ssh_gss.py", line 45, in <module>
[Wed Dec 26 14:32:08.811204 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from pyasn1.type.univ import ObjectIdentifier
[Wed Dec 26 14:32:08.811207 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pyasn1/type/univ.py", line 13, in <module>
[Wed Dec 26 14:32:08.811209 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] from pyasn1.compat import integer
[Wed Dec 26 14:32:08.811213 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pyasn1/compat/integer.py", line 12, in <module>
[Wed Dec 26 14:32:08.811215 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] implementation = platform.python_implementation()
[Wed Dec 26 14:32:08.811218 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/platform.py", line 1265, in python_implementation
[Wed Dec 26 14:32:08.811221 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] return _sys_version()[0]
[Wed Dec 26 14:32:08.811224 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] File "/home/sammy/python_envs/pgadmin/lib/python3.6/platform.py", line 1223, in _sys_version
[Wed Dec 26 14:32:08.811227 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] repr(sys_version))
[Wed Dec 26 14:32:08.811239 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38044] ValueError: failed to parse CPython sys.version: '3.6.7 (default, Oct 22 2018, 11:32:17) \\n[GCC 8.2.0]'
[Wed Dec 26 14:32:09.642066 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] mod_wsgi (pid=59825): Target WSGI script '/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi' cannot be loaded as Python module.
[Wed Dec 26 14:32:09.642149 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] mod_wsgi (pid=59825): Exception occurred processing WSGI script '/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi'.
[Wed Dec 26 14:32:09.642554 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] Traceback (most recent call last):
[Wed Dec 26 14:32:09.642631 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.wsgi", line 36, in <module>
[Wed Dec 26 14:32:09.642646 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from pgAdmin4 import app as application
[Wed Dec 26 14:32:09.642652 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py", line 70, in <module>
[Wed Dec 26 14:32:09.642655 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] app = create_app()
[Wed Dec 26 14:32:09.642659 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/__init__.py", line 374, in create_app
[Wed Dec 26 14:32:09.642662 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] driver.init_app(app)
[Wed Dec 26 14:32:09.642666 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/__init__.py", line 40, in init_app
[Wed Dec 26 14:32:09.642669 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] DriverRegistry.load_drivers()
[Wed Dec 26 14:32:09.642673 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/registry.py", line 88, in load_drivers
[Wed Dec 26 14:32:09.642675 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] module = import_module(module_name)
[Wed Dec 26 14:32:09.642679 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/importlib/__init__.py", line 126, in import_module
[Wed Dec 26 14:32:09.642682 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Dec 26 14:32:09.642686 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/psycopg2/__init__.py", line 27, in <module>
[Wed Dec 26 14:32:09.642689 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from .server_manager import ServerManager
[Wed Dec 26 14:32:09.642693 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgadmin/utils/driver/psycopg2/server_manager.py", line 27, in <module>
[Wed Dec 26 14:32:09.642696 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from sshtunnel import SSHTunnelForwarder, BaseSSHTunnelForwarderError
[Wed Dec 26 14:32:09.642699 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/sshtunnel.py", line 25, in <module>
[Wed Dec 26 14:32:09.642702 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] import paramiko
[Wed Dec 26 14:32:09.642706 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/__init__.py", line 22, in <module>
[Wed Dec 26 14:32:09.642708 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from paramiko.transport import SecurityOptions, Transport
[Wed Dec 26 14:32:09.642712 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/transport.py", line 38, in <module>
[Wed Dec 26 14:32:09.642715 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from paramiko.auth_handler import AuthHandler
[Wed Dec 26 14:32:09.642718 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/auth_handler.py", line 72, in <module>
[Wed Dec 26 14:32:09.642721 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from paramiko.ssh_gss import GSSAuth, GSS_EXCEPTIONS
[Wed Dec 26 14:32:09.642724 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/paramiko/ssh_gss.py", line 45, in <module>
[Wed Dec 26 14:32:09.642730 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from pyasn1.type.univ import ObjectIdentifier
[Wed Dec 26 14:32:09.642735 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pyasn1/type/univ.py", line 13, in <module>
[Wed Dec 26 14:32:09.642737 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] from pyasn1.compat import integer
[Wed Dec 26 14:32:09.642741 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/pyasn1/compat/integer.py", line 12, in <module>
[Wed Dec 26 14:32:09.642744 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] implementation = platform.python_implementation()
[Wed Dec 26 14:32:09.642748 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/platform.py", line 1265, in python_implementation
[Wed Dec 26 14:32:09.642751 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] return _sys_version()[0]
[Wed Dec 26 14:32:09.642755 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] File "/home/sammy/python_envs/pgadmin/lib/python3.6/platform.py", line 1223, in _sys_version
[Wed Dec 26 14:32:09.642757 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] repr(sys_version))
[Wed Dec 26 14:32:09.642772 2018] [wsgi:error] [pid 59825] [remote W.X.Y.Z:38046] ValueError: failed to parse CPython sys.version: '3.6.7 (default, Oct 22 2018, 11:32:17) \\n[GCC 8.2.0]'
在conda环境中我的软件包的完整列表如下:
# packages in environment at /home/michae/python_envs/pgadmin:
#
# Name Version Build Channel
alembic 1.0.5 <pip>
argparse 1.4.0 <pip>
asn1crypto 0.24.0 <pip>
Babel 2.6.0 <pip>
bcrypt 3.1.5 <pip>
blinker 1.4 <pip>
ca-certificates 2018.11.29 ha4d7672_0 conda-forge
certifi 2018.11.29 py36_1000 conda-forge
cffi 1.11.5 <pip>
Click 7.0 <pip>
cryptography 2.4.2 <pip>
cython 0.29.2 py36hfc679d8_0 conda-forge
extras 1.0.0 <pip>
fixtures 3.0.0 <pip>
Flask 0.12.4 <pip>
Flask-BabelEx 0.9.3 <pip>
Flask-Gravatar 0.5.0 <pip>
Flask-HTMLmin 1.3.2 <pip>
Flask-Login 0.3.2 <pip>
Flask-Mail 0.9.1 <pip>
Flask-Migrate 2.1.1 <pip>
Flask-Paranoid 0.2.0 <pip>
Flask-Principal 0.4.0 <pip>
Flask-Security 3.0.0 <pip>
Flask-SQLAlchemy 2.3.2 <pip>
Flask-WTF 0.14.2 <pip>
html5lib 1.0.1 <pip>
htmlmin 0.1.12 <pip>
idna 2.8 <pip>
itsdangerous 1.1.0 <pip>
Jinja2 2.10 <pip>
libffi 3.2.1 hfc679d8_5 conda-forge
libgcc-ng 7.2.0 hdf63c60_3 conda-forge
libstdcxx-ng 7.2.0 hdf63c60_3 conda-forge
linecache2 1.0.0 <pip>
Mako 1.0.7 <pip>
MarkupSafe 1.1.0 <pip>
ncurses 6.1 hfc679d8_2 conda-forge
openssl 1.0.2p h470a237_1 conda-forge
paramiko 2.4.2 <pip>
passlib 1.7.1 <pip>
pbr 3.1.1 <pip>
pgadmin4 3.6 <pip>
pip 18.1 py36_1000 conda-forge
psutil 5.4.7 <pip>
psycopg2 2.7.6.1 <pip>
pyasn1 0.4.4 <pip>
pycparser 2.19 <pip>
pycrypto 2.6.1 <pip>
PyNaCl 1.3.0 <pip>
pyrsistent 0.14.2 <pip>
python 3.6.7 h5001a0f_1 conda-forge
python-dateutil 2.7.5 <pip>
python-editor 1.0.3 <pip>
python-mimeparse 1.6.0 <pip>
pytz 2018.3 <pip>
readline 7.0 haf1bffa_1 conda-forge
setuptools 40.6.3 py36_0 conda-forge
simplejson 3.13.2 <pip>
six 1.12.0 <pip>
speaklater 1.3 <pip>
SQLAlchemy 1.2.15 <pip>
sqlite 3.26.0 hb1c47c0_0 conda-forge
sqlparse 0.2.4 <pip>
sshtunnel 0.1.4 <pip>
testtools 2.3.0 <pip>
tk 8.6.9 ha92aebf_0 conda-forge
traceback2 1.4.0 <pip>
unittest2 1.1.0 <pip>
webencodings 0.5.1 <pip>
Werkzeug 0.14.1 <pip>
wheel 0.32.3 py36_0 conda-forge
WTForms 2.1 <pip>
xz 5.2.4 h470a237_1 conda-forge
zlib 1.2.11 h470a237_3 conda-forge
还请注意,在没有Apache的情况下“直接”使用pgadmin
应用程序时,即简单地将/var/{lib,log}/pgadmin4
的所有权从www-data
更改为sammy
并运行下面的命令,工作正常:
source activate pgadmin
python ~/python_envs/pgadmin/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
我不是专家,但是Apache conf文件似乎存在一些问题,导致某些python版本冲突。当直接从环境执行并绕过Apache时,这些冲突不会发生。我对如何解决它一无所知,任何帮助将不胜感激。
根据this post的建议,我尝试在虚拟环境中运行pip install mod_wsgi
并将mod_wsgi-express module-config
的输出复制到Apache conf文件(在我的情况下为LoadModule wsgi_module "/home/sammy/python_envs/pgadmin/lib/python3.6/site-packages/mod_wsgi/server/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so"
),但是没有运气,同样的错误。