1. Startseite
  2. Python
  3. Verwendung mehrerer Versionen mit Passenger

Verwendung mehrerer Versionen mit Passenger

Übersicht

Passagier provides an intelligent polyglot launcher interface for managing Node.js, Rubin, and Python processes. This can be teamed up with pyenv to effortlessly launch multiple Python applications with a single shell command and .htaccess directive.

These steps are only necessary to use supplementary Python versions available on the server. If the default version works satisfactorily, then no further changes are necessary.

Verwendung

Applying what has been learned from KB article: “Changing python versions“, create a directory structure compatible with Passenger:

cd /var/www
mkdir -p mypyapp/{public,tmp}
cd mypyapp

Now assign it a Python interpreter. We’ll use 3.3.5:

pyenv local 3.3.5

Lastly, inform Passenger to use the pyenv-compatible python shim by adding PassengerPython /.socket/python/shims/python zu einer .htaccess file in öffentlich/

echo "PassengerPython /.socket/python/shims/python" > /var/www/mypyapp/public/.htaccess

Wichtig: using pyenv’s shim system is considerably slower than accessing python directly, because a series of shell subprocesses are launched to resolve the python process necessary to satisfy a request. If using pyenv with Passenger, consider adapting it to the FastCGI specification for background persistence.

Siehe auch

Aktualisiert am März 7, 2021

Verwandte Artikel