PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 21, 2022

[FIXED] How to set LD_LIBRARY_PATH for apache+wsgi website

 August 21, 2022     apache, environment-variables, mod-wsgi, python     No comments   

Issue

I'm trying to use a python library in my wsgi( apache + flask) based website.

While using the library in a standalone command script, I have to add the library path to LD_LIBRARY_PATH

So this works for standalone script:

# export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
# python script.py

Now when I try to use this python library through Apache+wsgi, I need to pass the same path to apache workers. How can I accomplish that?


Solution

Is the library required by a Python module extension you have compiled and installed? If it was, set LD_RUN_PATH environment variable to the directory the library is in when compiling and installing that Python module. That way the location is embedded in the Python module extension itself and you don't need LD_LIBRARY_PATH at run time.

The only other way to do it using environment variables is to set LD_LIBRARY_PATH in the startup scripts for Apache so that when Apache is started it is set as you require. This means fiddling with system startup scripts so is not ideal or always practical.

One final way which may work but isn't really that great of an idea and may not even work, is to use:

LoadFile "/usr/local/lib/libmylib.so"

in the Apache configuration. This will force linking of the specific library into Apache at startup, but depending on how the library is being used, this may not work.



Answered By - Graham Dumpleton
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing