CREATE USER 'admin'@'localhost' IDENTIFIED BY 'the_secure_password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Posts made by aizu
-
RE: mysql - snippets
-
NodeJS - ERR_OSSL_EVP_UNSUPPORTED error
export NODE_OPTIONS=--openssl-legacy-provider
Ref: https://stackoverflow.com/questions/69394632/webpack-build-failing-with-err-ossl-evp-unsupported
-
RE: nginx conf - sample
redirect
server { server_name .mydomain.example; rewrite ^ http://www.adifferentdomain.example$request_uri? permanent; }
or on any version 0.9.1 or higher:
server { server_name .mydomain.example; return 301 http://www.adifferentdomain.example$request_uri; }
HTTP redirect:
- 301 (permanent)
- 302 (temporary)
-
Linode - disable ipv6
Check IP
ip a
File: /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
Reload sysctl
sysctl -p /etc/sysctl.conf
-
Softether - Linux
Install server
Download here: https://www.softether-download.com/en.aspx?product=softether
apt-get update apt-get upgrade apt-get install build-essential wget "https://www.softether-download.com/files/softether/v4.43-9799-beta-2023.08.31-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.43-9799-beta-2023.08.31-linux-x64-64bit.tar.gz" tar -zxvf softether-vpnserver-v4.43-9799-beta-2023.08.31-linux-x64-64bit.tar.gz cd vncserver make main
-
S3 - Bucket Policy - ACL - for public
{ "Version": "2008-10-17", "Statement": [ { "Sid": "AllowPublicRead", "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::BUCKET_NAME/*" } ] }
-
docker build for ECR
1. build
docker build -t nextjs-app .
aws ecr get-login-password --region ap-southeast-1
Then it will come out the password
2. login
docker login -u AWS -p somePassword 123456789012.dkr.ecr.us-east-1.amazonaws.com
3. tag
docker tag nextjs-app:latest 123456789012.dkr.ecr.us-east-1.amazonaws.com/nextjs-app:latest
4. push
docker push 123456789012.dkr.ecr.us-east-1.amazonaws.com/nextjs-app:latest
Below example for docker login stdin with aws get password
aws ecr get-login-password --region ap-southeast-1 | docker login -u AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com
-
EC2 - increase storage without turn off instance
To increase the space on your AWS instance, follow these steps:
1. Check the Available Storage:
Before expanding, verify the disk space:df -h
2. Identify the Volume:
Find the attached volumes for your EC2 instance:Go to the EC2 Console.
Under Elastic Block Store (EBS), select Volumes.
Identify the volume attached to your instance.3. Modify the EBS Volume:
Select the volume you want to expand.
Click on Actions → Modify Volume.
Increase the size of the volume (e.g., from 8 GB to 20 GB).
Click Modify.4. Extend the Partition on the EC2 Instance:
After the volume is resized, you'll need to extend the file system to use the new space.For ext4 file system:
Verify the volume size:lsblk
Make sure the resized volume reflects the correct size.
Extend the file system:sudo growpart /dev/nvme0n1 1 sudo resize2fs /dev/nvme0n1p1
For xfs file system:
Extend the file system:sudo xfs_growfs -d /
5. Verify the Increased Space:
Check the disk space again:df -h
This process will allow you to increase the disk space without stopping the instance.
To check partition type
lsblk -f
-
Multiple PHP 8.3 and 7.4 - Ubuntu 24
To run multiple PHP versions (8.3 and 7.4) on Ubuntu 24, you can install PHP 7.4 alongside PHP 8.3 and configure PHP-FPM to handle both versions. Here’s a step-by-step guide:
Step 1: Add PHP 7.4 Repository
First, you need to add the ondrej/php PPA, which allows you to install older PHP versions like 7.4.sudo apt update sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update
Step 2: Install PHP 7.4 and PHP 7.4-FPM
Now, install PHP 7.4 along with its FPM package and any required extensions.sudo apt install php7.4 php7.4-fpm php7.4-cli php7.4-common php7.4-mysql php7.4-xml php7.4-mbstring php7.4-curl
Step 3: Ensure PHP 8.3 FPM is Installed
Make sure you also have PHP 8.3 FPM installed (if not already):sudo apt install php8.3-fpm
Step 4: Configure Nginx to Use Different PHP-FPM Versions
Now, you need to modify your Nginx configuration to point to the correct PHP-FPM socket for each site or location.For PHP 8.3 (default):
In your Nginx config file (e.g., /etc/nginx/sites-available/default), set the fastcgi_pass directive to PHP 8.3:nginx
Copy code
location ~ .php$ {
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
include fastcgi_params;
}For PHP 7.4 (for specific locations or sites):
For specific sites or locations where you want to use PHP 7.4, you can point to the PHP 7.4 FPM socket:location ~ \.php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock; include fastcgi_params; }
Step 5: Enable and Restart PHP-FPM Services
Enable both PHP-FPM services to ensure they start on boot:sudo systemctl enable php8.3-fpm sudo systemctl enable php7.4-fpm
Then restart both services:
sudo systemctl restart php8.3-fpm sudo systemctl restart php7.4-fpm
Step 6: Set PHP 8.3 as the Default CLI Version (Optional)
If you want to keep PHP 8.3 as the default for the CLI, use the update-alternatives command:sudo update-alternatives --set php /usr/bin/php8.3
To switch to PHP 7.4 for the CLI:
sudo update-alternatives --set php /usr/bin/php7.4
Step 7: Verify Installation
To check the installed versions of PHP-FPM, run:php -v # To check the default CLI version sudo systemctl status php7.4-fpm sudo systemctl status php8.3-fpm
Conclusion
Now you have both PHP 8.3 and PHP 7.4 running on your Ubuntu 24 system, with PHP 8.3 as the default and the ability to use PHP 7.4 for specific locations or virtual hosts. -
PDF using gotenberg - docker
install gotenberg
docker run -d --rm -p 5000:5000 gotenberg/gotenberg:8 gotenberg --api-port=5000 --api-timeout=10s --libreoffice-disable-routes --log-level=debug
docker ps docker ls
request
curl --request POST http://localhost:5000/forms/chromium/convert/url --form url=https://sparksuite.github.io/simple-html-invoice-template/ -o my.pdf
-
PM2 for Strapi CMS
ecosystem.config.cjs
module.exports = { apps: [ { name: "sirehpark-cms", script: "npm", args: "start", cwd: "/var/www/sirehpark-cms", env: { NODE_ENV: "production", PORT: 1337, }, }, ], };
-
Tips to buy laptop - as on 2024
CPU - get the i5 14th-gen. If budget constrain, i5 12th-gen pun good CPU. Try not get into seller trap, which they might sell AMD Ryzon or something, as AMD is battery hunger, and AMD have bad history of over-heating. If you are gamer, yes, go for AMD.
RAM - if possible, get 16GB RAM. If budget issue, get 8GB minimum. Do not get below 8GB. Chrome nowdays a little mafia-eating-memory. If possible, get 16GB - comfortable for long run usage, example 5 to 10 Chrome tabs.
HDD - get with SSD drive (which range around 256GB to 512GB. Do not get normal spinning 1TB hard drive (seller might hard-sell you, saying 1TB is much more spacious, but, it is slow) - realistically, in normal work, 256GB or 512GB is good enough (unless you need for video editing or Photoshopping)
Screen size - if need big screen, get 15”. But, it is less portable compared to 14” - In my personal case, I prefer to be highly portable, so I opted for 13”, can do work anywhere.
Kalau boleh, if budget is good, boost up the RAM, 24GB ke.
-
PM2 for NextJS - (without ecosystem file)
pm2 start 'node_modules/next/dist/bin/next start -p 3000' --name 'index-3000' --watch
-
Change SSH Port - Ubuntu
vim /etc/ssh/sshd_config
Modify the Port to new port number (i.e: 23)
Port 23
Restart ssh service
/etc/init.d/ssh restart
If not working, modify file below;
vim /etc/systemd/system/sockets.target.wants/ssh.socket
Modify the "ListenStream" value to target (i.e: 23)
Restart systemctl daemon & ssh service
systemctl daemon-reload /etc/init.d/ssh restart
Ref: https://askubuntu.com/questions/1483893/unable-to-change-ssh-port-on-ubuntu
-
Windows 10 - setup without Microsoft email
Option 0
- release IP address
ipconfig /release
Option 1
- disable wifi
Shift + F10 OOBE\BYPASSNRO
Use the Command Prompt to Bypass the Internet Requirement When you encounter the "Let's connect you to a network" screen, you can execute the "**OOBE\BYPASSNRO**" command in Command Prompt to bypass the connectivity requirement during the Windows 11 installation process. To achieve this, press **Shift+F10** to launch Command Prompt while on the "Let's connect you to a network" screen. In the Command Prompt window, type **OOBE\BYPASSNRO** and press Enter. Ref: https://www.howtogeek.com/bypass-lets-connect-you-to-a-network-screen/
Option 2
- go to explorer, control panel
- disable wifi
Shift + F10
Type: explorer.exe to load the window
Option 3
During setup, when asked about email, press "Ctrl + Shift + F3"
Once desktop loaded, forget the WiFi.
Restart the Setup
Ref: https://www.reddit.com/r/techsupport/comments/ickdw9/disable_wifi_during_windows_10_install/
-
SSH Tunnel Port
Tunnel the port using SSH
ssh -v -N -L 3001:TARGET_INTERNAL_IP:3000 -i PEM_KEY_FILE [email protected] ssh -v -N -L 3001:TARGET_INTERNAL_IP:3000 [email protected] 3001 : local port (127.0.0.1:3001) 3000 : remote port (TARGET_INTERNAL_IP:3000) -v : verbose -N : non-interactive -L : tunnel -f : non-foreground
-
AWS ECS task definition file sample
{ "containerDefinitions": [ { "name": "REPLACE_WITH_SERVICE_NAME", "image": "REPLACE_WITH_ECR_IMAGE_NAME", "cpu": 0, "portMappings": [ { "containerPort": 3000, "hostPort": 3000, "protocol": "tcp", "name": "REPLACE_WITH_SERVICE_NAME-3000-tcp", "appProtocol": "http" } ], "essential": true, "environment": [], "environmentFiles": [], "mountPoints": [], "volumesFrom": [], "ulimits": [], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "/ecs/REPLACE_WITH_SERVICE_NAME", "mode": "non-blocking", "awslogs-create-group": "true", "max-buffer-size": "25m", "awslogs-region": "ap-southeast-1", "awslogs-stream-prefix": "ecs" }, "secretOptions": [] }, "systemControls": [] } ], "taskRoleArn": "arn:aws:iam::0000000000000:role/ecsTaskExecutionRole", "executionRoleArn": "arn:aws:iam::0000000000000:role/ecsTaskExecutionRole", "networkMode": "awsvpc", "requiresCompatibilities": [ "FARGATE" ], "family": "REPLACE_WITH_SERVICE_NAME", "cpu": "1024", "memory": "3072", "runtimePlatform": { "cpuArchitecture": "X86_64", "operatingSystemFamily": "LINUX" }, "tags": [ { "key": "hello", "value": "world" } ] }
-
bitbucket pipeline - sample aws-cli, ecr
image: node:20 pipelines: branches: development: - step: name: Build image, push to ECR and deploy to ECS caches: - docker services: - docker script: # install packages - apt-get update && apt-get install -y awscli # create aws-cli credential file - mkdir -p ~/.aws - echo "[default]" > ~/.aws/credentials - echo "aws_access_key_id=$AWS_DEV_ACCESS_KEY" >> ~/.aws/credentials - echo "aws_secret_access_key=$AWS_DEV_SECRET_ACCESS_KEY" >> ~/.aws/credentials - echo "[default]" > ~/.aws/config - echo "region=$AWS_DEFAULT_REGION" >> ~/.aws/config - echo "output=json" >> ~/.aws/config # login to ECR - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_DEVELOPMENT_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com # prepare the variables, get version number from package.json - IMAGE_NAME="image_name_goes_here" - VERSION=$(sed -n 's/.*"version":\ "\(.*\)".*/\1/p' package.json) - VERSION_TAG="v${VERSION}" # build docker image - docker build -t $IMAGE_NAME:$VERSION_TAG . - docker tag $IMAGE_NAME:$VERSION_TAG $AWS_DEVELOPMENT_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_NAME:$VERSION_TAG - docker images # send image to ECR - docker push $AWS_DEVELOPMENT_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_NAME:$VERSION_TAG # modify task definition template file - aws s3 cp $TASK_DEF_FILE_S3_URL_LOCATION task-definition.json - sed -i 's|"image":\ ".*"|"image":\ "'$AWS_DEVELOPMENT_ACCOUNT_ID'.dkr.ecr.'$AWS_DEFAULT_REGION'.amazonaws.com/'$IMAGE_NAME':'$VERSION_TAG'"|' task-definition.json - sed -i 's|"environmentFiles":\ \[\]|"environmentFiles":\ \[{"value":\ "'$ENV_FILE_S3_ARN'","type":\ "s3"}\]|' task-definition.json # add task into ECS & update services - aws ecs register-task-definition --cli-input-json file://task-definition.json > task-definition-registration-out - export UPDATED_TASK_DEFINITION=$(sed -n 's/.*"taskDefinitionArn":\ "\(.*\)".*/\1/p' task-definition-registration-out) - aws ecs update-service --service image_name_goes_here --cluster dev-fargate-cluster --task-definition ${UPDATED_TASK_DEFINITION} > /dev/null staging: - step: name: Staging command goes here caches: - docker services: - docker script: - echo "Hello!" definitions: services: docker: memory: 2048