I'm trying to deploy a Flask application on a BlueHost shared hosting server. I have been following this guide. I have made one change, and that is in the .fcgi
file. I'm not using flup
. This is my .fcgi
file (flask.fcgi
):
#!/path/to/venv/bin/python
from wsgiref.handlers import CGIHandler
from server import app
CGIHandler().run(app)
I've made the file executable, and when I run ./flask.fcgi
from the command line (via SSH) it returns the HTML page for the index route, which is what I expect. But if I navigate to mydomain.com/flask.fcgi
I receive a 500 Internal Server error. Checking the server logs I can see this message:
/path/to/venv/bin/python: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
I encountered this error before while installing openssl
and rectified it by setting the LD_LIBRARY_PATH
environment variable to include the path to the location where the libraries were installed. This is my .htaccess
file:
# For Flask
PassEnv LD_LIBRARY_PATH
PassEnv REQUEST_METHOD
Options ExecCGI
AddHandler fcgid-script .fcgi
RewriteEngine On
# For Flask
RewriteCond %{REQUEST_FILENAME} !=/path/to/public_html/flask.fcgi
RewriteRule ^(.*)$ flask.fcgi/$1 [QSA,L]
RewriteOptions inherit
You can see that I try to pass in the LD_LIBRARY_PATH
variable, but to no avail, I continue to receive the 500 Internal Server errors, regardless of whether I navigate to mydomain.com/page
or to mydomain.com/flask.fcgi
directly.
I'm entirely at a loss of where to go from here, any help would be greatly appreciated.
CodePudding user response:
So I figured out what the problem was. I needed to set LD_LIBRARY_PATH
and LD_RUN_PATH
before compiling openssl
and python
. I set the paths and then ran ./Configure
and make && make install
for openssl
, and the same for python
.