Friday, April 20, 2018

mod_qos(004): failed to create mutex (ACT)(/var/tmp/K564968484.mod_qos): No space left on device

Solution :
Apache cannot be started because of this error, it means you have installed and enabled qos module in apache to avoid ddos attack. Now apache is crashed automatically and you are not able to start it.

Disable qos module

sudo a2dismod qos
Restart apache2

Error : django.db.utils.ProgrammingError: permission denied for relation django_migrations

While running django migrations for postgresql if you get above error, there may be chances that postgresql user which is used in connection file does not have sufficient permissions to run the migrations command. You need to provide privileges to postgresql user using super user.
1. Log into the database which is going to be migrated using super user
\c database name

2. Run following queries
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public to username;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public to username;

Change text username with postgresql user which is used in server side postgresql connection file.

Note :
Generally you get this error while running python manage.py migrate 
and above solution works well for this error.

Apache - Block IP or an IP Range to prevent opening your site


If you want to block IPs from accessing your site, you can simply achieve it using an htaccess file. Add following line in .htaccess and IP owner will not be able to open your site anymore.


Suppose you want that your site should not be opened from IP 46.161.9.67, you need to add a line your .htaccess file.
Deny from 46.161.9.67
If there are multiple IPs and you want to block them all. Add following line in .htaccess.
Deny from 46.161.9.67 46.161.10.187 46.161.58.89
Block a whole IP Range
Here is the tricky part, If you want to block a whole IP Range like 69.0.0.0 to 69.0.0.255. Use following code in your .htaccess 

Deny from 69.208.0.0/24
If it is from 69.0.0.0 to 69.0.255.255
Deny from 69.208.0.0/16
And If it is from 69.0.0.0 to 69.255.255.255
Deny from 69.208.0.0/8

Refer Link for more wide Range :
https://www.mediawiki.org/wiki/Help:Range_blocks