Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python MySQLdb with SELinux

I'm using the mySQLdb module within my django application which is linked to Apache via WSGI. However I'm getting permission issues (shown below). This is down to SElinux and if I set it to passive everything is ok.

ImproperlyConfigured: Error loading MySQLdb module: /opt/django/virtenv/django15/lib/python2.7/site-packages/_mysql.so: failed to map segment from shared object: Permission denied

What is the best way to update SELinux to include this without having to turn off the whole the thing. The error is shown below:

ImproperlyConfigured: Error loading MySQLdb module: /opt/django/virtenv/django1/lib/python2.7/site-packages/_mysql.so: cfailed to map segment from shared object: Permission denied

like image 225
felix001 Avatar asked Dec 20 '14 21:12

felix001


1 Answers

As @Gohn67 suggests, change the SELinux security context of the file in question, allowing the HTTPD process to execute it:

sudo chcon -R -h -t httpd_sys_script_exec_t /opt/django/virtenv/django15/lib/python2.7/site-packages/_mysql.so
like image 67
Velimir Mlaker Avatar answered Oct 31 '22 03:10

Velimir Mlaker