WordPress update all post with WP-CLI
In wordpress folder, run commands: Above commands mean “do nothing”. But you can edit to do something.
Run WP CRON with crontab and WP CLI
Download wp-cli: Add crontab in /var/spool/cron/root: Make sure your crontab file is good linux format: Disable WP_CRON in wp-config.php: By Proxy, block or return empty page for requests to your http://domain.com/wp-cron.php
Tuning performance Mariadb/ MySQL
Add more config (maybe at /etc/my.cnf.d/server.conf): With a powerful server, can adjust I/O: How to find the good innodb_buffer_pool_size number? Here is Recommended InnoDB Buffer Pool Size: Or adjust more 10%: After your DB run with new config in a period time (daily, weekly,…), check how many memory in used. This Data_MB number can be…
Run PHP-FPM (FastCGI) with NGINX
Install PHP-FPM (FastCGI) and NGINX Selinux Create new website: New user and project Create new php-fpm pool New file: /etc/php-fpm.d/domain.com.conf: Restart Create Nginx config: Restart Install SSL Install certbot: Create cert Then update cert to nginx config with new server block for port 443 ssl with fastcgi_param HTTPS on; and declare cert & key. Some…
Install ClamAV antivirus or Linux Malware Detect
Install ClamAV Install Linux Malware Detect ClamAV should be install first, helpful for Linux Malware Detect. Install Linux Malware Detect: Scan: Show quarantine files:
Count the usage size of Mariadb/MySQL
Query: Result:
Config HAProxy community edition Active/Active cluster (Solution)
The first, install keepalived to manage Virtual IP. My concept is use 2 Virtual IPs bind on 2 Nodes. Node 1 is MASTER on Virtual IP 1 and BACKUP on Virtual IP 2, Node 2 is MASTER on Virtual IP 2 and BACKUP on Virtual IP 1. DNS Round-robin to 2 Public IPs, every Public…
Makes NextJS easy to understand
UI/UX Design thinking
Tips to improve Kafka performance
Use Child_Process to pull code?
Yes, that is a simple opinion. Do it with one simple file: Now, you can write an API to call http://localhost:3000 to pull 3 project. You can `composer update` or something more.
Convert Interface in Typescript
I have one Interface: Convert fields in the interface to required The desired result is as follows: Solution: Convert fields in the interface to optional The desired result is as follows: Solution: Convert some fields by name instead of all The desired result is as follows: Solution: Convert fields in the interface to other value…
Create MongoDB cluster with 3 nodes
Edit /etc/hosts file in 3 nodes, add with 3 node ips: In terminal, set root password: Create ssl key then COPY folder to all members for same key. Disable THP: Edit file /etc/mongod.conf, add: Restart mongod for all nodes: Connect to primary node (node 1) with your yourRootPassword Setup replication: Check it: Create new user…
Create Kafka Cluster with 3 nodes
Edit file “server.properties” with different broker.id and advertised.listeners: Delete folder “logs” which defined in config (“/home/kafka/logs”) in secondary nodes and folder “zookeeper”. Stop all nodes then restart all node: Important! In node 01: Open meta.properties file in /home/kafka/logs. Copy cluster.id value. Paste cluster.id value to /home/kafka/logs/meta.properties in other node, for the same cluster. For multi…
Create Redis Cluster with few steps
With 3 computers (10.5.10.1, 10.5.10.2, 10.5.10.3). My example is Rocky Linux/ Centos Step 1: Install Redis on computer Step 2: Edit /etc/redis.conf: Step 3: Open Firewall on 7001 & 17001 (7001+10000): Step 4: Run Redis Server with command: Repeat all steps above on other computer with other port (7002, 7003) Step 5: Create cluster Open…
Build NestJS Library
To build a NestJS library, you can follow these steps: Create a new NestJS project using the NestJS CLI: Change the working directory to your library folder: Create a new library module using the NestJS CLI: This will generate a new folder my-library inside the src folder. This folder contains the library module and its…
MongoDB error: child process failed, exited with error number
Check all path in /etc/mongod.conf. If files or folders not exist, create them then:
Compare strings and calculate scores, find the closest string
Compare strings and calculate scores, find the closest string by JS:
Store compressed data in MongoDB and decompress it
Storing compressed data in MongoDB and decompressing it is a necessary task when you store large data files like Logs. Database schema Interface Upload Controller Method: POST – ‘multipart/form-data‘ Field name: file Type: Use .zip file for lightweight Allows to use multiple text files in a zip file Upload Service Input: file Extract the zip…
NGINX – Installation and configuration
It’s easy to install NGINX from the repo. For example on RHEL/ Centos/ Rocky Linux: So, this tutorial I want to show you how to install from source. You can read something here for NGINX and streaming: [Full install] Streaming HLS with Nginx & FFMPEG (quicktricks.net). Or below: Preparing for the installation Install some required…
MongoServerError: Plan executor error during findAndModify :: caused by :: E11000 duplicate key error collection [Solved]
Tips for “MongoServerError: Plan executor error during findAndModify :: caused by :: E11000 duplicate key error collection“. Mongo duplicate when findAndModify(), same for findOneAndUpdate() Don’t try to query the dynamic field with the upsert option! The same problem will occur when querying multiple conditions (include some not unique fields), while turn on option upsert=true. This…
[Full install] Streaming HLS with Nginx & FFMPEG
This guide for Centos/ RHEL/ Rocky Linux,… So, you can use for other Linux. Install some required packages Install NGINX from source Download some required packages: ZLIB: Find lastest version here: https://zlib.net/ My version is https://zlib.net/zlib-1.2.12.tar.gz PCRE Find lastest version here: https://www.pcre.org/ or https://sourceforge.net/projects/pcre/files/pcre2/ My version is pcre2-10.37.tar.gz OPEN SSL Find lastest version here: https://www.openssl.org/source/…