DEV Community

Discussion on: Flask Deploy with Apache on CentOS - Minimal Setup

Collapse
 
sm0ke profile image
Sm0ke • Edited

Oh .. , sounds like super fun. I see two options here:

  • Recompile the mod_wsgi module using Python3
  • Update the deployment schema to use Apache as a reverse proxy and start the app using Gunicorn

Let me know if this helps.

Collapse
 
williamium3000 profile image
william • Edited

I have gone with the first approach and encounters problems and would like to communicate with you on this a bit more.
so i uninstall mod_wsgi on python2, and tried install using zip pack from mod_wsgi website
./configure --with-python=/usr/local/bin/python3 this is the configure that i used to specify python interpreter
then make && make install
problem occurs(part of the error reports looks like the following)

/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(Python-ast.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast_opt.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast_unparse.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getcompiler.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getcopyright.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getplatform.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(structmember.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getopt.o): relocation R_X86_64_32S against `.rodata.str4.4' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(parser.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(node.o): relocation R_X86_64_PC32 against symbol `PyObject_Free' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1

my server is a centos 7 with gcc and python2 installed already. i install python3 using zip pack from its home webside and set --enable-shared to make sure that its library can be shared.
another way i tried is through pip3 install mod_wsgi
problems:

/usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(Python-ast.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast_opt.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(ast_unparse.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getcompiler.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getcopyright.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getplatform.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(structmember.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(getopt.o): relocation R_X86_64_32S against `.rodata.str4.4' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(parser.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: /usr/local/python3/lib/libpython3.7m.a(node.o): relocation R_X86_64_PC32 against symbol `PyObject_Free' can not be used when making a shared object; recompile with -fPIC
    /usr/bin/ld: final link failed: Bad value
    collect2: error: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/python3/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-313gyz5m/mod-wsgi/setup.py'"'"'; __file__='"'"'/tmp/pip-install-313gyz5m/mod-wsgi/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-a4z7qsiz/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/python3/include/python3.7m/mod-wsgi Check the logs for full command output.

i have stuck with this for a few days and would really appreciated if you can help
thx sincerely.

Thread Thread
 
sm0ke profile image
Sm0ke • Edited

Hello,
That's a super heavy error. I've googled a little, nothing relevant found. Apache mod_wsgi is super buggy on CentOS. I had many issues in the past and skip over that setup.

I'm using on CentOS a simple setup that uses uWSGI to start the Flask/Django app and Apache as a reverse proxy.
uWSGI is fast but is not handle the SSL layer (that's why you need Apache in front). Feel free to use Gunicorn instead of uWSGI, in case you are familiar with it.

I'm not super free with my time, but we can chat LIVE on Discord. I'm Sm0ke on that server (the moderator).