Django ImportError: No module named settings - Ubuntu 18.04

Hi all,

I’ve recently expiriencing some issue after apt upgrade on my ubuntu machine. Cyberpanel itself and all websites work fine. I’m able to add/remove websites, add/remove dns entries, issue ssl etc.
But when I try to change htaccess file or look at the logs site comes back with django error.

Provider: OneProvider
Virtualization Type: N/A it’s dedicated server
System: Ubuntu 18.04
Installation option:
OLS
Installing from official server or mirror server?
official
Replace JS/CSS files to JS Delivr?
no
Install Memcached extension for PHP?
yes
Install LiteSpeed Memcached?
yes
Install Memcached?
yes
Install Redis extension for PHP?
yes
Install Redis?
yes

When trying to save htaccess
Could not save rewrite rules. Error message: Traceback (most recent call last): File “/usr/local/CyberCP/plogical/virtualHostUtilities.py”, line 26, in from vhost import vhost File “/usr/local/CyberCP/plogical/vhost.py”, line 23, in from managePHP.phpManager import PHPManager File “/usr/local/CyberCP/managePHP/phpManager.py”, line 6, in from .models import * File “/usr/local/CyberCP/managePHP/models.py”, line 9, in class PHP(models.Model): File “/usr/local/CyberCP/managePHP/models.py”, line 10, in PHP phpVers = models.CharField(max_length=5,unique=True) File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/db/models/fields/init.py”, line 1057, in init super(CharField, self).init(*args, **kwargs) File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/db/models/fields/init.py”, line 172, in init self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 56, in getattr self._setup(name) File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 41, in _setup self._wrapped = Settings(settings_module) File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 110, in init mod = importlib.import_module(self.SETTINGS_MODULE) File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module import(name) ImportError: No module named settings

When trying to access site logs
Traceback (most recent call last):
File “/usr/local/CyberCP/plogical/virtualHostUtilities.py”, line 26, in
from vhost import vhost
File “/usr/local/CyberCP/plogical/vhost.py”, line 23, in
from managePHP.phpManager import PHPManager
File “/usr/local/CyberCP/managePHP/phpManager.py”, line 6, in
from .models import *
File “/usr/local/CyberCP/managePHP/models.py”, line 9, in
class PHP(models.Model):
File “/usr/local/CyberCP/managePHP/models.py”, line 10, in PHP
phpVers = models.CharField(max_length=5,unique=True)
File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/db/models/fields/init.py”, line 1057, in init
super(CharField, self).init(*args, **kwargs)
File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/db/models/fields/init.py”, line 172, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 56, in getattr
self._setup(name)
File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 41, in _setup
self._wrapped = Settings(settings_module)
File “/usr/local/CyberCP/local/lib/python2.7/site-packages/django/conf/init.py”, line 110, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
ImportError: No module named settings

Alto I do have full rsync backup from when it was still working, I would like to know if that’s something that’s someone already seen and is fixible
Thank you.

It might be related to csf again.
Cause I have another ubuntu dedicated server which also have csf but doesn’t have extra module on django or csf ui integrated in CP which is working perfectly fine.
Once I find out how can I fix it, I’ll post it here.

Now I can confirm that CyberPanel itself work fine without CSF.
On using cyberpanel to install it back, issue come back with exactly same errors.
I’ll compare both systems CSF configs later on to see if issue is in it’s config.

#edit I must have been wrong in first assumption. It’s not apt-get.
I must have done apt-get upgrade after which I’ve noticed functionality not working

@usmannasir is there any chance that I could get some guideline/assistance in removing/disabling ConfigServer module?

CSF configs diff (/etc/csf/csf.conf) have not brought anything that would fix it.

Tried removing csf, restarting serv, running upgrade, restart, reinstall csf, same issue persists.

Then tried removing csf, restarted, upgraded, done diffsettings, and module persists.

I’ve tried overwrite settings from working over to non-properly working CP to propely panel config and it’s still not working doing it all over again.

I’m not familiar enough with Python/Django by the looks of it as I’ve only managed to find out that there is extra django module through making diffsettings and comparing it over two ubuntu 18.04 servers (working and not working) while also being not knowledgeable enough to remove/disable it.

I’m able to get site to work as it used to by removing CSF, while it doesn’t seem to be best choice over simple FirewallD.

I still do use CSF while manually checking logs and editing .htaccess files manually through ssh and as it’s not essential web functionality to my server, it do give me peace of mind

I do think it’s worth to find and fix this bug within possibly already in previous commits which caused.
Interestingly it’s non-working server that is older over working one (both upgraded from ubuntu 14.04 using same official ubuntu source). I’ve reinstalled whole ubuntu after reporting csf upgrade issue to you @CyberPanel .
Have I possibly tried this too quickly?

/usr/local/CyberCP/CyberCP/settings.py

In the installed_apps variable if you see anything related to csf, you can remove and then do systemctl restart lscpd this will remove any csf apps from CyberPanel codebase.

i did the upgrade again when i saw this on one of my Ubuntu 18 servers and it fixed that.

sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)

Fixed https://github.com/usmannasir/cyberpanel/commit/a2ad6ca415b7069f1557ae4aa152c3365d32b78e

Try upgrading.

It doesn’t work in my case. Every time I try to upgrade CP when CSF already installed, script installs CSF plugin as well.
I’ve managed to install CSF through panel after changing 2 lines on
/usr/local/CyberCP/plogical/csf.py
Which is changing from

        command = "chmod +x install.sh"
        ProcessUtilities.normalExecutioner(command)

        command = 'bash install.sh'
        ProcessUtilities.normalExecutioner(command)

To

        command = "chmod +x install.generic.sh"
        ProcessUtilities.normalExecutioner(command)

        command = 'bash install.generic.sh'
        ProcessUtilities.normalExecutioner(command)

Otherwise it recognize cyberpanel and runs install.cyberpanel.sh which installs CSF plugin and issue persists.

Alternativly we can try to comment out lines installing plugin onto cyberpanel out of install.cyberpanel.sh which are at the buttom from line 486 to 500, then script works and doesn’t cause same issue

Those lines are
mkdir /home/cyberpanel/plugins
touch /home/cyberpanel/plugins/configservercsf

if ! cat /usr/local/CyberCP/CyberCP/settings.py | grep -q configservercsf; then
sed -i “/pluginHolder/ i \ \ \ \ ‘configservercsf’,” /usr/local/CyberCP/CyberCP/settings.py
fi
if ! cat /usr/local/CyberCP/CyberCP/urls.py | grep -q configservercsf; then
sed -i “/pluginHolder/ i \ \ \ \ url(r’^configservercsf/',include(‘configservercsf.urls’)),” /usr/local/CyberCP/CyberCP/urls.py
fi
#if ! cat /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html | grep -q configservercsf; then

sed -i “/url ‘csf’/ i

  • ConfigServer Security \& Firewall
  • ” /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html

    #fi
    if ! cat /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html | grep -q configserver; then
    sed -i “/trans ‘Plugins’/ i \{\% include "/usr/local/CyberCP/configservercsf/templates/configservercsf/menu.html" \%\}” /usr/local/CyberCP/baseTemplate/templates/baseTemplate/index.html
    fi

    Does anyone else have this issue when using CSF?
    I suspect it’s only Ubuntu.

    Rewrite rules work now tho. Log access doesn’t

    @netbos fixed fetching logs → bug fix: fetch logs · usmannasir/cyberpanel@7f03672 · GitHub

    All working perfectly now. Thank you @CyberPanel