fail2ban

Configure my own jail sudo nano /etc/fail2ban/jail.localenabled = truelogpath = /var/log/mysql/query.logfilter = mysqld-authport = 3306backend = %(mysql_backend)s Enable logging for mysql sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf# Be aware that this log type is a performance killer.general_log_file = /var/log/mysql/query.loggeneral_log = 1sudo systemctl restart mysql Troubleshoot sudo fail2ban-client status sshdsudo service fail2ban restartsudo service fail2ban statussudo fail2ban-client status...

Node.js

Install the following for dev. https://nodejs.org/en (Node itself) https://github.com/nvm-sh/nvm (Node Version manager)NVM is not supported on Windows so download below:https://github.com/coreybutler/nvm-windows Test installation node -vnpm -vnvm -v Start your project mkdir first_projectcd first_projectnpm init#To re-download dependencies if requirednpm install npm update#install packages npm install --save expressnpm install chalknpm install debugnpm install morgannpm install mysql#install template...

Django app deployment on Ubuntu

Global install sudo apt-get install apache2 python3-django libapache2-mod-wsgi-py3 virtualenv### MySQLsudo apt-get install mysql-server libmysqlclient-devmysql_secure_installation Virtual env setup Not testedsudo apt-get install python3-venv (doesn't need. )sudo apt-get install python3-devsudo a2enmod wsgisudo systemctl restart apache2 Make Python Virtual Environment ### Install and create venv sudo apt-get install python3-pippip3 install virtualenv### Go to desired location to create...

Django HelloWorld with PyCharm

### Install django(venv) C:\Users\kim\PycharmProjects\DjangoHelloWorld>pip install django### Create django project(venv) C:\Users\kim\PycharmProjects\DjangoHelloWorld>django-admin startproject mysite### Test run(venv) C:\Users\kim\PycharmProjects\DjangoHelloWorld\mysite>python manage.py runserver 127.0.0.1:8080 Add the following (optional) to mysite\ settings.py ALLOWED_HOSTS = ### Create app(venv) C:\Users\kim\PycharmProjects\DjangoHelloWorld\mysite>python manage.py startapp polls...

phpMyAdmin on Ubuntu 18.04

Install When prompted, select apache2 Select "apache2"<Yes> for dbconfig-common ### Explicitly enable the mbstring PHP extension sudo phpenmod mbstring ### Load changes sudo systemctl restart apache2 Secure phpMyAdmin instance ### AllowOverride All<Directory /usr/share/phpmyadmin> Options FollowSymLinks DirectoryIndex index.php AllowOverride All ... Create .htaccess at the installed directory sudo nano /usr/share/phpmyadmin/.htaccess Create .htpasswd within /etc/phpmyadmin directory...

LAMP on Ubuntu 18.04

Linux, Apache, MySQL, PHP Adjust firewall Install MySQL Use a password when connecting to MySQL ### Loginsudo mysql sudo mysql -u root -p### view current mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;### Set password for root mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';### Reload with new change mysql> FLUSH PRIVILEGES;### Verify new change mysql>...

Django app development

timezone setup on web server ### List timezonestimedatectl list-timezones### Set timezone e.g. Singaporesudo timedatectl set-timezone Asia/Singapore### Verify changestimedatectldate Install django on venv $ source venv/bin/active (venv) $ pip install django(venv) $ pip install django-crispy-forms(venv) $ pip install Pillow(venv) $ python -m pip install Pillow (venv) $ django-admin startproject domain.sg (venv) # python manage.py startapp...

Python basics

types Lists Tuple () Sets {} dict {} ++ increment is not allowed in Python Deploy python to executable Get full path location for *.csv Extract only filename from full path Good to know methods ### Get directory of the objectprint(dir(num))...

Python sorted()

Sort by data value in the list of dict Sort by using itemgetter Sort by attribute value in class Sort by using attrgetter list tuple sort dict by key sort by absolute value...

Scroll to top