Score:1

Apache CustomLog directive failing - pipe

in flag

I have the following directive in my apache2_site.conf file:

        CustomLog "|/home/me/myjlog.py %h \"%r\"" common

which should create a log in my MySQL server. myjlog.py starts with:

#!/usr/bin/python3
import pymysql
import sys

ip=sys.argv[1]
req=sys.argv[2]
...

However, for each request to my site, the logging in my database isn't done.

What appears in /var/log/apache2/error.log is:

AH00106: piped log program '/home/me/myjlog.py %h "%r"' failed unexpectedly
Traceback (most recent call last):
  File "/home/alibaba/myjlog.py", line 2, in <module>
    import pymysql
ModuleNotFoundError: No module named 'pymysql'

It seems that python doesn't recognize the module pymysql. However this module is installed for users me and root...

How may I guarantee access to pymysql to apache2?

EDIT: 1 - I don't use any virtual environment on this server. 2 - After setting chmod -R g+rx /home/me/.local and chmod -R a+rx /home/me/.local, I run sudo -u www-data python3 -m site and obtained:

sys.path = [
    '/home/me',
    '/usr/lib/python36.zip',
    '/usr/lib/python3.6',
    '/usr/lib/python3.6/lib-dynload',
    '/home/me/.local/lib/python3.6/site-packages',
    '/usr/local/lib/python3.6/dist-packages',
    '/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/me/.local' (exists)
USER_SITE: '/home/me/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True

But still the CustomLog directive can't access pymysql.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.