Install pgAdmin 4 in Server Mode: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(20 intermediate revisions by the same user not shown)
Line 1: Line 1:
<source lang="bash">
'''Linux'''
<syntaxhighlight lang="bash">
apt install libgmp3-dev libpq-dev libapache2-mod-wsgi-py3
apt install libgmp3-dev libpq-dev libapache2-mod-wsgi-py3
</source>
</syntaxhighlight>


<source lang="bash">
<syntaxhighlight lang="bash">
mkdir ~/environments
mkdir ~/environments
apt install python3-venv
apt install python3-venv
python3 -m venv ~/environments/pgadmin4
python3 -m venv ~/environments/pgadmin4
source ~/environments/pgadmin4/bin/activate
source ~/environments/pgadmin4/bin/activate
</source>
</syntaxhighlight>


'''Windows'''
  '''run as administrator'''
  '''run as administrator'''
  1. Press '''⊞ + R'''
  1. Press '''⊞ + R'''
Line 16: Line 18:
  4. Choose '''Yes''' and Press '''Enter'''
  4. Choose '''Yes''' and Press '''Enter'''


<source lang="bat">
<syntaxhighlight lang="bat">
D:
D:
python -m pip install virtualenv
python -m pip install virtualenv
python -m venv D:\var\lib\venv\pgadmin4
python -m venv D:\var\lib\venv\pgadmin4
D:\var\lib\venv\pgadmin4\Scripts\activate
D:\var\lib\venv\pgadmin4\Scripts\activate
</source>
</syntaxhighlight>


==Wheel==
==Wheel==
<source lang="bash">
<syntaxhighlight lang="bash">
python -m pip install -U pip
python -m pip install -U pip
python -m pip install  wheel
python -m pip install  wheel
python -m pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v5.4/pip/pgadmin4-5.4-py3-none-any.whl
python -m pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v5.4/pip/pgadmin4-5.4-py3-none-any.whl
python -m pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.29/pip/pgadmin4-4.29-py3-none-any.whl
</syntaxhighlight>
</source>


==Config==
==Config==
<source lang="bash">
'''Linux'''
<syntaxhighlight lang="bash">
mkdir /var/log/pgadmin4
mkdir /var/log/pgadmin4
mkdir -p /var/lib/pgadmin4/{sessions,storage}
mkdir -p /var/lib/pgadmin4/{sessions,storage}
Line 38: Line 40:
chown -R pi:pi /var/lib/pgadmin4
chown -R pi:pi /var/lib/pgadmin4
chown -R pi:pi /var/log/pgadmin4
chown -R pi:pi /var/log/pgadmin4
</source>
</syntaxhighlight>


<source lang="bash">
<syntaxhighlight lang="bash">
cat <<EOF >> ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
cat <<EOF >> ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
Line 49: Line 51:
SERVER_MODE = True
SERVER_MODE = True
EOF
EOF
</source>
</syntaxhighlight>


<source lang="bash">
'''Windows'''
<syntaxhighlight lang="bash">
mkdir /d/var/log/pgadmin4
mkdir -p /d/var/lib/pgadmin4/{sessions,storage}
</syntaxhighlight>
 
<syntaxhighlight lang="bash">
cat <<EOF >> /d/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/config_local.py
cat <<EOF >> /d/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/config_local.py
DATA_DIR = 'D:/var/lib/pgadmin4/datadir'
LOG_FILE = 'D:/var/log/pgadmin4/pgadmin4.log'
LOG_FILE = 'D:/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = 'D:/var/lib/pgadmin4/pgadmin4.db'
SQLITE_PATH = 'D:/var/lib/pgadmin4/pgadmin4.db'
Line 60: Line 69:
SERVER_MODE = True
SERVER_MODE = True
EOF
EOF
</source>
</syntaxhighlight>


==Setup==
==Setup==
<source lang="bash">
'''Linux'''
<syntaxhighlight lang="bash">
python ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/setup.py
python ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/setup.py
: <<'END_COMMENT'
: <<'END_COMMENT'
Line 77: Line 87:
END_COMMENT
END_COMMENT
deactivate
deactivate
</source>
</syntaxhighlight>


<source lang="bat">
'''Windows'''
<syntaxhighlight lang="bat">
(pgadmin4) D:\>python D:\var\lib\venv\pgadmin4\Lib\site-packages\pgadmin4\setup.py
(pgadmin4) D:\>python D:\var\lib\venv\pgadmin4\Lib\site-packages\pgadmin4\setup.py
(pgadmin4) D:\>set MOD_WSGI_APACHE_ROOTDIR=C:/xampp/apache
(pgadmin4) D:\>set MOD_WSGI_APACHE_ROOTDIR=C:/xampp/apache
Line 87: Line 98:
(pgadmin4) D:\>mod_wsgi-express module-location
(pgadmin4) D:\>mod_wsgi-express module-location
deactivate
deactivate
</source>
</syntaxhighlight>


==Apache2==
==Apache2==
<source lang="bash">
'''Linux'''
<syntaxhighlight lang="bash">
chown -R www-data:www-data /var/lib/pgadmin4
chown -R www-data:www-data /var/lib/pgadmin4
chown -R www-data:www-data /var/log/pgadmin4
chown -R www-data:www-data /var/log/pgadmin4
nano /etc/apache2/sites-enabled/000-default.conf
nano /etc/apache2/sites-enabled/000-default.conf
</source>
</syntaxhighlight>


<source lang="apache" highlight="14-20" line>
<syntaxhighlight lang="apache" highlight="14-20" line>
<VirtualHost *:80>
<VirtualHost *:80>
     # The ServerName directive sets the request scheme, hostname and port that
     # The ServerName directive sets the request scheme, hostname and port that
Line 134: Line 146:
     #Include conf-available/serve-cgi-bin.conf
     #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
</VirtualHost>
</source>
</syntaxhighlight>


<source lang="bash">
<syntaxhighlight lang="bash">
apache2ctl -t
apache2ctl -t
systemctl status apache2
systemctl status apache2
systemctl restart apache2
systemctl restart apache2
</source>
</syntaxhighlight>
 
'''Windows'''
<syntaxhighlight lang="apache">
LoadFile "C:/Python39/python39.dll"
LoadModule wsgi_module "D:/var/lib/venv/pgadmin4/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "D:/var/lib/venv/pgadmin4"


<source lang="apache">
WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=D:/var/lib/venv/pgadmin4
WSGIScriptAlias /pgadmin4 "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/pgAdmin4.wsgi"
WSGIScriptAlias /pgadmin4 "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/pgAdmin4.wsgi"
<Directory "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/">
<Directory "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/">
    WSGIProcessGroup pgadmin
    WSGIApplicationGroup %{GLOBAL}
     Require all granted
     Require all granted
</Directory>
</Directory>
</source>
</syntaxhighlight>


==Knowledge==
==Knowledge==
Line 158: Line 172:
  python -m pip install --upgrade pip
  python -m pip install --upgrade pip
  python -m pip install -U pip
  python -m pip install -U pip
pip install pip-check
pip install pip-upgrader
pip install --upgrade pgadmin4


==References==
==References==
{|
| valign="top" |
* [https://stackoverflow.com/questions/42546569/ XAMPP Apache not working after installing <code>mod_wsgi</code>]
* [https://stackoverflow.com/questions/42546569/ XAMPP Apache not working after installing <code>mod_wsgi</code>]
* [https://stackoverflow.com/questions/6093727/ <code>mod_wsgi</code> module into apache on Windows 64-bit]
* [https://stackoverflow.com/questions/6093727/ <code>mod_wsgi</code> module into apache on Windows 64-bit]
* [https://stackoverflow.com/questions/46363836/ Install <code>mod_wsgi</code> on Windows + XAMPP in 2017]
* [https://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi Unofficial Windows Binaries for Python Extension]
* [https://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi Unofficial Windows Binaries for Python Extension]
* [https://stackoverflow.com/questions/46363836/ Install <code>mod_wsgi</code> on Windows + XAMPP in 2017]
* [https://www.digitalocean.com/community/tutorials/how-to-install-configure-pgadmin4-server-mode Install and Configure pgAdmin 4 in Server Mode]
* [https://www.digitalocean.com/community/tutorials/how-to-install-configure-pgadmin4-server-mode Install & Configure pgAdmin 4 in Server Mode]
* [https://stackoverflow.com/questions/59801387/ Install mod_wsgi into Apache on Windows]
* [https://stackoverflow.com/questions/59801387/ Install mod_wsgi into Apache on Windows]
* [https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-18-04-server Install Python 3 and Setup a Virtual Env]
* [https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-18-04-server Install Python 3 and Setup a Virtual Env]
* [https://www.pgadmin.org/docs/pgadmin4/development/server_deployment.html Windows 10 pgAdmin 4 in Server Mode]
* [https://www.pgadmin.org/docs/pgadmin4/development/server_deployment.html Windows 10 pgAdmin 4 in Server Mode]
* [https://www.pgadmin.org/docs/pgadmin4/development/import_export_servers.html Export Import PgAdmin 4 Servers]
* [https://github.com/GrahamDumpleton/mod_wsgi Build your own <code>mod_wsgi</code>]
* [https://github.com/GrahamDumpleton/mod_wsgi Build your own <code>mod_wsgi</code>]
| valign="top" |
* [[PostgreSQL/PgBouncer]]
* [[Helm/PostgreSQL]]
* [[Helm/PgAdmin4]]
* [[PostgreSQL]]
| valign="top" |
|}

Latest revision as of 09:24, 17 November 2024

Linux

apt install libgmp3-dev libpq-dev libapache2-mod-wsgi-py3
mkdir ~/environments
apt install python3-venv
python3 -m venv ~/environments/pgadmin4
source ~/environments/pgadmin4/bin/activate

Windows

run as administrator
1. Press ⊞ + R
2. Type in cmd
3. Press Ctrl + Shift + Enter
4. Choose Yes and Press Enter
D:
python -m pip install virtualenv
python -m venv D:\var\lib\venv\pgadmin4
D:\var\lib\venv\pgadmin4\Scripts\activate

Wheel

python -m pip install -U pip
python -m pip install  wheel
python -m pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v5.4/pip/pgadmin4-5.4-py3-none-any.whl

Config

Linux

mkdir /var/log/pgadmin4
mkdir -p /var/lib/pgadmin4/{sessions,storage}

chown -R pi:pi /var/lib/pgadmin4
chown -R pi:pi /var/log/pgadmin4
cat <<EOF >> ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/config_local.py
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'
UPGRADE_CHECK_ENABLED = False
SERVER_MODE = True
EOF

Windows

mkdir /d/var/log/pgadmin4
mkdir -p /d/var/lib/pgadmin4/{sessions,storage}
cat <<EOF >> /d/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/config_local.py
DATA_DIR = 'D:/var/lib/pgadmin4/datadir'
LOG_FILE = 'D:/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = 'D:/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = 'D:/var/lib/pgadmin4/sessions'
STORAGE_DIR = 'D:/var/lib/pgadmin4/storage'
UPGRADE_CHECK_ENABLED = False
SERVER_MODE = True
EOF

Setup

Linux

python ~/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/setup.py
: <<'END_COMMENT'
NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: [email protected]
Password: 
Retype password:
pgAdmin 4 - Application Initialisation
======================================
END_COMMENT
deactivate

Windows

(pgadmin4) D:\>python D:\var\lib\venv\pgadmin4\Lib\site-packages\pgadmin4\setup.py
(pgadmin4) D:\>set MOD_WSGI_APACHE_ROOTDIR=C:/xampp/apache

(pgadmin4) D:\>pip install mod-wsgi
(pgadmin4) D:\>mod_wsgi-express module-config
(pgadmin4) D:\>mod_wsgi-express module-location
deactivate

Apache2

Linux

chown -R www-data:www-data /var/lib/pgadmin4
chown -R www-data:www-data /var/log/pgadmin4
nano /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName pi4.dev.shahed.biz

    ServerAdmin [email protected]
    DocumentRoot /var/www/html

    WSGIDaemonProcess pgadmin processes=1 threads=25 python-home=/home/pi/environments/pgadmin4
    WSGIScriptAlias /pgadmin4 "/home/pi/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/pgAdmin4.wsgi"
    <Directory "/home/pi/environments/pgadmin4/lib/python3.7/site-packages/pgadmin4/">
        WSGIProcessGroup pgadmin
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
apache2ctl -t
systemctl status apache2
systemctl restart apache2

Windows

LoadFile "C:/Python39/python39.dll"
LoadModule wsgi_module "D:/var/lib/venv/pgadmin4/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "D:/var/lib/venv/pgadmin4"

WSGIScriptAlias /pgadmin4 "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/pgAdmin4.wsgi"
<Directory "D:/var/lib/venv/pgadmin4/Lib/site-packages/pgadmin4/">
    Require all granted
</Directory>

Knowledge

cd /usr/share/apache2/icons/
unzip /home/pi/icons.zip
python -m pip install --upgrade pip
python -m pip install -U pip

pip install pip-check
pip install pip-upgrader
pip install --upgrade pgadmin4

References