Pcre Issue When Setting Up Wsgi Application

UWSGI error with PCRE Ubuntu 20.04 error while loading shared libraries: libpcre.so.1:

What solved it for me was apparently just reinstalling UWSGI, like in this thread, in my virtual env while forcing it to ignore the cache so it could know to use the pcre library I installed.

In order, doing this

uwsgi --version

Was giving me this

uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

So I made sure I had the latest libpcre installed

sudo apt-get install libpcre3-dev

And then what linked it all together was this

pip install uwsgi -I --no-cache-dir

Deploying C app that uses the PCRE library

It's better to either install it or link it in statically. The former, of course, is lighter on resources. The best way to ensure compatibility would be to build the package for target system, specifying all dependencies (depends on the distribution, of coursE).

Enabling internal routing in uWSGI

I had to install uWSGI with pcre support. It solved problem with routing.

To do it I had to install pcre lib(for Ubuntu the package called libpcre3) and reinstall uWSGI then. Since PCRE is already in your system uWSGI will be automatically compiled with pcre support.

There are also points from @tobias.mcnulty comment that also might be useful:

  • libpcre3-dev package on Ubuntu also needs to be installed
  • afterwards you may want to run pip install -I --no-cache-dir uwsgi to reinstall it, otherwise you might just get the same cached wheel.
  • the error in the logs is !!! no internal routing support, rebuild with pcre support !!!

Error while loading shared libraries: 'libpcre.so.0: cannot open shared object file: No such file or directory'

The message means what it says. The nginx executable was compiled to expect the PCRE (Perl-compatible Regular Expression) shared library to be available somewhere on LD_LIBRARY_PATH or specified in /etc/ld.so.conf or whatever equivalent library-locating mechanisms apply to your operating system, and it cannot find the library.

You will need to install PCRE - or configure your environment so that nginx will look for the PCRE library where it is installed.

uwsgi failed to open python file /root/ ... /wsgi.py (DJANGO)

Check your file permissions for the Django project.You have your WSGI worker configured to use the account 'www-data'. Either change this to an account that has access to the directories and file, or change the files permissions.

You can validate the file permissions by running ls -la in the directory. The third column shows the owner and the fourth column shows the group.

-rwxrwxrwx 1 lbird lbird      548 Nov  3 11:52  default-soapui-workspace.xml
-rwxrwxrwx 1 lbird lbird 2785280 Jun 5 2021 ntuser.dat.LOG1
-rwxrwxrwx 1 lbird lbird 3256320 Jun 5 2021 ntuser.dat.LOG2
-rwxrwxrwx 1 lbird lbird 20 Jun 5 2021 ntuser.ini
-rwxrwxrwx 1 lbird lbird 8677 Nov 3 11:52 soapui-settings.xml

You can change file and folder permissions by running chown www-data:www-data ./* in the project directory.

I do not recommend keeping the files in your root directory, that should be protected. Instead consider moving them to /var/www or /var/app.

To validate if its a permissions issue, you could change your uWSGI configuration to make the uid and gid root, but do not use this in a production setting.



Related Topics



Leave a reply



Submit