Category Archives: Hosting

Database creation error: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.

Odoo issue creating new database:

Database creation error: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template.

Fix:
su – postgres
psql postgres

UPDATE pg_database SET datistemplate = FALSE WHERE datname = ‘template1’;
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = ‘UNICODE’;
UPDATE pg_database SET datistemplate = TRUE WHERE datname = ‘template1’;
\c template1
VACUUM FREEZE;

centos 7 odoo 9

yum install -y epel-release
For other RHEL-based distribution, see the EPEL documentation.

yum install -y postgresql-server
postgresql-setup initdb
systemctl enable postgresql
systemctl start postgresql
yum-config-manager –add-repo=https://nightly.odoo.com/9.0/nightly/rpm/odoo.repo
yum install -y odoo
systemctl enable odoo
systemctl start odoo

directadmin block brute force

systemctl mask firewalld
systemctl stop firewalld
yum -y install iptables-services
systemctl enable iptables

cd /usr/libexec/iptables
mv iptables.init iptables.init.backup
wget -O iptables.init http://files.directadmin.com/services/all/block_ips/2.1/iptables
chmod 755 iptables.init

systemctl reload iptables

cd /usr/local/directadmin/scripts/custom
wget -O block_ip.sh http://files.directadmin.com/services/all/block_ips/2.1/block_ip.sh
wget -O show_blocked_ips.sh http://files.directadmin.com/services/all/block_ips/2.1/show_blocked_ips.sh
wget -O unblock_ip.sh http://files.directadmin.com/services/all/block_ips/2.1/unblock_ip.sh
chmod 700 block_ip.sh show_blocked_ips.sh unblock_ip.sh

touch /root/blocked_ips.txt
touch /root/exempt_ips.txt

cd /usr/local/directadmin/scripts/custom
wget -O brute_force_notice_ip.sh http://files.directadmin.com/services/all/block_ips/2.1/brute_force_notice_ip.sh
chmod 700 brute_force_notice_ip.sh

centos postfix spf check

yum install perl-Mail-SPF
yum install perl-Sys-Hostname-Long

wget https://launchpad.net/postfix-policyd-spf-perl/trunk/release2.010/+download/postfix-policyd-spf-perl-2.010.tar.gz
tar -xf postfix-policyd-spf-perl-2.010.tar.gz

mkdir /usr/lib/postfix
cp postfix-policyd-spf-perl-2.010/postfix-policyd-spf-perl /usr/lib/postfix/

perl /usr/lib/postfix/postfix-policyd-spf-perl

vim /etc/postfix/main.cf
smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination,check_policy_service unix:private/policy
policy_time_limit = 3600s

vim /etc/postfix/master.cf
policy unix – n n – 0 spawn user=nobody argv=/usr/bin/perl /usr/lib/postfix/postfix-policyd-spf-perl

service postfix restart

Install it or recompile php without –disable-phar

It means you are missing phar extension, you will face this error until php will show:

php -i | grep phar –color=always

Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On

df shows wrong tmp size


du -sh /tmp/
976K /tmp/

but: df -h /tmp
tmpfs 4.0G 2.9G 1.2G 71% /tmp

lsof -a +L1 /tmp
mysqld 814658 mysql 5u REG 0,18 6909 0 129877498 (deleted)/tmp/ibDs7ppL
mysqld 814658 mysql 6u REG 0,18 550 0 129877499 (deleted)/tmp/ibdkEKwG
mysqld 814658 mysql 7u REG 0,18 0 0 129877500 (deleted)/tmp/ibJv84DB
mysqld 814658 mysql 8u REG 0,18 0 0 129877581 (deleted)/tmp/ibVsY6gs
mysqld 814658 mysql 22u REG 0,18 0 0 129953780 (deleted)/tmp/ibFXQ0vR
mysqld 814658 mysql 7109u REG 0,18 1511325696 0 130050097 (deleted)/tmp/MYVbKwmg
mysqld 814658 mysql 7138u REG 0,18 1511325696 0 130043510 (deleted)/tmp/MYdDNZUq

mysqladmin processlist

| 13962 | cphulkd | localhost | cphulkd | Query | 27931 | Sorting result | SELECT USER,SERVICE,TYPE,TIMESTAMPDIFF(SECOND, '1970-01-01', LOGINTIME) as LOGINTIME,TIMESTAMPDIFF(S |
| 24119 | cphulkd | localhost | cphulkd | Query | 25842 | Sorting result | SELECT USER,SERVICE,TYPE,TIMESTAMPDIFF(SECOND, '1970-01-01', LOGINTIME) as LOGINTIME,TIMESTAMPDIFF(S |
| 31029 | cphulkd | localhost | cphulkd | Query | 24435 | Sorting result | SELECT USER,SERVICE,TYPE,TIMESTAMPDIFF(SECOND, '1970-01-01', LOGINTIME) as LOGINTIME,TIMESTAMPDIFF(S |
| 120593 | root | localhost | cphulkd | Query | 8229 | Waiting for table flush | LOCK TABLES `auths` READ /*!32311 LOCAL */,`ip_lists` READ /*!32311 LOCAL */,`known_netblocks` READ |
| 152512 | cphulkd | localhost | cphulkd | Query | 2154 | Waiting for table flush | SELECT USER,SERVICE,TYPE,TIMESTAMPDIFF(SECOND, '1970-01-01', LOGINTIME) as LOGINTIME,TIMESTAMPDIFF(S |

mysql -e "SELECT CONCAT('KILL ',ID,';') FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'cphulkd' AND COMMAND = 'Query' AND TIME > 100 INTO OUTFILE '/tmp/kill_list.txt';" && mysql -e "source /tmp/kill_list.txt" && rm -rf /tmp/kill_list.txt