Tuesday, June 24, 2025

When refresh the react page getting 404 not found error

 My development team is working on React and Nodejs combination, after deployment the links are working but when we do a refresh on the working page getting "404 not found error"

Solution.

Make sure you have AllowOverride All

In your document root, vi .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>

Now try refresh, it will work.

Monday, March 3, 2025

How to configure Mysql root password on Oracle Linux 8

How to configure Mysql root password on Oracle Linux 8




  • Login to your server as root.
  • By default, there is no password for mysql root.
  • mysql -u root -p
  • Alter user 'root'@'localhost' identified WITH mysql_native_password by 'StrongPassword';
  • flush privileges;
  • exit;

Now, try to connect to Mysql as root user. It works!

Thursday, January 16, 2025

git@github.com: Permission denied (publickey)

 Error when cloning git after adding SSH key. Below is the error

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.


Fix :


First make sure you have added SSH key correctly. On right hand side of top corner under profile, you can see settings. In setting click on SSH and GPG keys and add your key as authentication keys.


Then login to the server or desktop from where you generated the key or have its private key, 

eval `ssh-agent -s`

ssh-add ~/.ssh/id_rsa


Wait for some time and try git clone, it will work.

Saturday, January 11, 2025

OCI Instance Principals Authentication


OCI Instance Principals Authentication

In OCI, one of the authentication mechanism is using "Instance Principals". Here we don't need to use a key to execute OCI CLI commands, instead of key we are allowing OCI Compute instance the permission to execute CLI commands.

In this video you can see the steps.

1. Get the OCID of the compute instance
2. Create a Dynamic group
3. Create a Policy
4. Validate the setup
5. Execute your CLI commands {oci os object put --bucket-name backup-bucket --file sc_laundry_db-202412181734507003.sql --auth instance_principal}

Few Links for further read

Saturday, October 26, 2024

how to install letsencrypt on oracle linux 8

 how to install letsencrypt on oracle linux 8

1. Login to the server as root

2. dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

3. dnf install certbot python3-certbot-apache

4. certbot --apache

Saturday, August 17, 2024

Errors during downloading metadata for repository 'appstream': - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

 Error while installing a package in CentOS 8

Errors during downloading metadata for repository 'appstream':   - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

How to fix?

1. Login to the server

2. cd /etc/yum.repos.d/

3. sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

4. sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

5. yum install <package>

It works!

Thursday, May 23, 2024

SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty

 Error on Oracle linux9

After installing Letsencrypt, i am getting this error "SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty" when trying to execute certbot --apache

How to fix :

systemctl restart httpd

After this, you can successfully execute the command certbot --apache and the issue if solved.

Wednesday, May 22, 2024

How to mount an OCI Object Storage Bucket as File System on Linux

I am trying to mount OCI Object Storage bucket as a file system in one of my application server. It will helps me a lot to take backups and in automation I can point this OCI bucket as the destination of scripts output. As OCI object storage is S3 compatible, I am here using S3fs-fuse utility to mount the bucket.

OS : Oracle Linux 9

As a pre-request, please make sure that the compartment you are trying to mount the object storage is S3 compatible.

Go to "Governance & Administration --> Tenancy Details --> Edit object storage settings"


Now follow the below steps.

Step 1 : SSH to your application server

Step 2 : dnf update -y

Step 3 : vi /etc/yum.repos.d/oracle-epel-ol9.repo

Step 4 : Update "enabled=0" to "enabled=1" and save the file

Step 5 : yum install s3fs-fuse -y

Step 6 : Login to OCI console and generate your "Access key" and "Secret key" (keep it safe with you)

Step 7 : SSH to application server

Step 8 : vi /home/opc/.passwd-s3fs

Step 9 : Input your Access key id : Secret key id (Both in one line with a colon separated)

Step 10 : chmod 600 /home/opc/.passwd-s3fs

Step 11 : Create bucket in your OCI account (My bucket name is skynet-upload-bucket)

Step 12 : Identify your OCI region identifier (https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm)

Step 13 : Identify your object storage namespace ("Governance & Administration --> Tenancy Details -->Object storage namespace")

Step 14 : Location of your local path folder in application server (mkdir -p /home/opc/mybucket)

Step 15 : sudo s3fs {oci bucket name} {local path folder} -o endpoint={oci region identifier} -o passwd_file=.passwd-s3fs -o url=https://{object storage namespace}.compat.objectstorage.{oci region idnetifier}.oraclecloud.com/ -onomultipart -o use_path_request_style -o allow_other

Step 16 : Check your mount point (mount | grep s3fs), seems all good.

Step 17 : Now we can test. touch /home/opc/mybucket/testfile.txt

Step 18 : Go to OCI buket (skynet-upload-bucket) and check whether you can see it

Step 19 : Remove the mount point # sudo fusermount -u /home/opc/mybucket

Youtube video about this post : https://youtu.be/QJ6GBPo8F2M



Monday, May 13, 2024

jupyterhub spawn failed server at http //127.0.0.1

 How to fix jupyterhub spawn failed server at http //127.0.0.1

In my VM, I am using docker to run Jupyter.

How to fix this issue?

1. Login to your Jupyter hub docker container - docker exec -it jupyterhub bash
2. Install notebook - pip install notebook

Try to reload again, it works.


Sunday, March 3, 2024

Mysql Slave_SQL_Running no

 Mysql Slave_SQL_Running no

Environment is Centos8 with MySQL 8.0 and its a MySQL master slave replication. When I checked the "SHOW SLAVE STATUS\G" I am seeing status no for "Slave_SQL_Running".

Fix the issue :

Login to Slave Server.

STOP SLAVE;

SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; 

START SLAVE;

This will fix my issue.


Tuesday, January 30, 2024

How to connect OpenVPN 3 client in Ubuntu 22

 How to connect OpenVPN client in Ubuntu 22

In linux, Open VPN client is connected using the configuration file.

First, Install the open vpn3 client.

#apt install apt-transport-https curl
#mkdir -p /etc/apt/keyrings
#curl -sSfL https://packages.openvpn.net/packages-repo.gpg >/etc/apt/keyrings/openvpn.asc
#echo "deb [signed-by=/etc/apt/keyrings/openvpn.asc] https://packages.openvpn.net/openvpn3/debian 
            DISTRIBUTION main" >>/etc/apt/sources.list.d/openvpn3.list
Replace the DISTRIBUTION in the above command with yours. For me mine is "jammy"
#apt update
#apt install openvpn3
Now you have installed openvpn3 in your ubuntu machine.
Type openvpn3 --help you will see bunch of commands.

Second, we need to generate the configuration file from the open vpn server

Login to your openvpn Admin UI
Under User Management, select User Profiles
Click on the "New Profile" for the user which you want to connect
Generate the profile
Download the profile file

Third, connect the VPN client

# openvpn3 session-start --config {path to the above configuration file}
Enter your username (only username no need for username@IP)
Enter password
It connects, please make sure don't close this terminal. If you need you can run as a background process.

Wednesday, December 27, 2023

How to Archiving Amazon S3 Data to Amazon Glacier

 How to Archiving Amazon S3 Data to Amazon Glacier

As you know in AWS S3 we have different tier of storage. Based on our requirement we need to use the correct one to save cost and to meet the purpose. One of such requirement is to move the old backup files from S3 to amazon Glacier.


In this video you will learn how to archiving amazon s3 data to amazon glacier.






Tuesday, September 26, 2023

How to install OCI CLI in CentOS 8 Stream

 How to install OCI CLI in CentOS 8 Stream

The steps mentioned in the internet is not working for me. So this is the working commands.

# yum install python38 -y

# ll /usr/bin/pip3.8

# ll /usr/bin/pip-3.8

# pip3.8 install oci-cli

# oci --version

Monday, September 18, 2023

How to redirect 404 error to the home page

 How to redirect 404 error to the home page

Following steps helps to redirect all 404 error pages to the home page. Assume you already installed httpd in this server.

  • Make sure you enabled "rewrite_modile" (httpd - M | grep rewrite)
  • vi /etc/httpd/conf/httpd.conf (enable AllowOverride from "None" to "All"). Based on your configuration path.
  • vi /var/www/html/.htaccess (ErrorDocument 404 https://example.com)
  • systemctl restart httpd
  • Test it

How to install letsencrypt on Amazon linux 2023

 How to install letsencrypt on Amazon linux 2023

In Amazon linux 2023, EPEL is not available. All the documentations avaialble in internet is about EPEL and then install certbot. But here we need to use a different approach.

  • Login to the server
  • dnf install python3 augeas-libs
  • dnf remove certbot
  • python3 -m venv /opt/certbot/
  • /opt/certbot/bin/pip install --upgrade pip
  • /opt/certbot/bin/pip install certbot certbot-apache
  • ln -s /opt/certbot/bin/certbot /usr/bin/certbot
  • certbot --apache
This works perfectly for me. 🙋🙋
Here is the video tutorial. Have a look and install.


Wednesday, September 6, 2023

Single command to checkout all branches in git

 Single command to checkout all branches in git


[yourserver #] for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do; git branch --track ${branch#remotes/origin/} $branch; done;


This is useful when we do git migrations.

Monday, July 24, 2023

The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository.

 OS : CentOS 7

Error while installing Mysql

The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package.

Check that the correct key URLs are configured for this repository.


Fix:


Import new key from rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022


Yum update

yum install mysql-server

Thursday, June 15, 2023

Access denied for user 'user'@'hostname' (using password: YES) in mysql8

 Error : Access denied for user 'user'@'hostname' (using password: YES) in mysql8

Mysql version is Mysql8

OS is Ubuntu 22

I am sure that i can connect from my both apps servers to the DB from the command shell.

The issue is the mysql user password. In my password, i had some special characters. When we input this password in command prompt, in bash shell it will work. But its not working from nodejs code (.env file)

Solution :

I change the password without a special character and the issue got fixed.

Thursday, January 26, 2023

unable to find /root/.my.cnf. Exception message: (1698, \"Access denied for user 'root'@'localhost

 While running Ansible 2.14.1, i am getting the error

"unable to find /root/.my.cnf. Exception message: (1698, \"Access denied for user 'root'@'localhost

Solution to fix is :

You need to login to the server and find the mysqld.sock file. In my Ubuntu22 machine its /var/run/mysqld/mysqld.sock

I need to update this in my playbook as

- name: Create Application database
mysql_db: name=employee_db state=present login_unix_socket=/var/run/mysqld/mysqld.sock

- name: Create Database User
mysql_user:
name : db_user
password: Passw0rd
priv: '*.*:ALL'
login_unix_socket: /var/run/mysqld/mysqld.sock
state: present

Monday, January 2, 2023

ansible ssh key path in different location - Part 2

 Normally we will add the private key of the server in our .ssh/authorized keys, right?

But i want to keep the ssh key in a different location.

I created a folder called "centos" and i am planning to keep all the ansible files related to this project under this folder.

/Users/shivinvijai/Desktop/Learnings/Ansible/centos

In this folder, I fist created an inventory file.

shivinvijai@Shivins-MacBook-Pro centos % cat inventory 

[myservers]

150.61.189.96 ansible_user=opc ansible_ssh_private_key_file=/Users/shivinvijai/Desktop/Learnings/Ansilbe/ssh-key-2023-01-01.key

shivinvijai@Shivins-MacBook-Pro centos %

I specify my username and path to the ssh key file.

Now, I going to do a test, here i am using my own inventory file so the command will be this

shivinvijai@Shivins-MacBook-Pro centos % ansible -i inventory  -m ping myservers

150.61.189.96 | SUCCESS => {

    "ansible_facts": {

        "discovered_interpreter_python": "/usr/libexec/platform-python"

    },

    "changed": false,

    "ping": "pong"

}