Thursday, November 24, 2022

Auto deployment from github to server using FTP

 Step-1: Login the github the go to the project and click on setteings and add FTP Password under Security->Secrets. Then click New repository secret and name

Step - 2:Click Actions menu of repository and create the yml file as follows:

Click on Create a new worklow> set up a workflow yourself

.github/workflows/main.yml

Step - 3: Then add the following code to yml file and save.

on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v2

- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@4.3.2
with:
server: ourdomain.com/IP
username: username@yourdomain.com //or IP
password: ${{ secrets.FTP_PASSWORD }}
# server-dir: /home/dfaserghx/public_html/

How to delete all commit history in GitHub & repush to main?

Create a new Branch:

git checkout --orphan latest_branch

Add your all the files:

git add .

Save the changes with commit:

git commit -m "commit message"

Delete Main Branch:

git branch -D main

Rename latest_branch to main:

git branch -m main

Force update the repo:

git push -f origin main

Saturday, November 19, 2022

Find duplicates in value using SQL command

 SELECT

    username,

    email,

    COUNT(*)

FROM

    users

GROUP BY

    username,

    email

HAVING

    COUNT(*) > 1


or,

SELECT name, COUNT(*) c FROM table GROUP BY name HAVING c > 1;

Wednesday, November 2, 2022

Find All Rows Containing Duplicates using SQL CMD

SELECT

    a.*

FROM

    users a

JOIN(

    SELECT

        username,

        email,

        COUNT(*)

    FROM

        users

    GROUP BY

        username,

        email

    HAVING

        COUNT(*) > 1

) b

ON

    a.username = b.username AND a.email = b.email

ORDER BY

    a.email

Wednesday, October 26, 2022

How to Upgrade and Downgrade the PHP Versions on CentOS 7.9

 php -v

rpm -qa | grep php

yum remove "php-*" -y

yum --disablerepo=remi-php72 --enablerepo=remi-php73 install php php-gd php-mbstring php-mysql php-curl php-mcrypt

rpm -qa | grep php

yum remove "php-*" -y

yum --disablerepo=remi-php73 --enablerepo=remi-php56 install php php-gd php-mbstring php-mysql php-curl php-mcrypt

php -v

Tuesday, October 25, 2022

Set Force HTTPS Using .htaccess file

 RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Nginx server block configuration for MailWizz

 server {

  #    if ($host = www.yourdomain.com) {

  #     return 301 https://$host$request_uri;

  #  } # managed by Certbot


    root /var/www/yourdomain.com/public/;

    server_name yourdomain.com www.yourdomain.com;

  # Add index.php to setup Nginx, PHP & PHP-FPM config

  # index index.php index.html index.htm index.nginx-debian.html;


    listen [::]:443 ssl ipv6only=on; # managed by Certbot

    listen 443 ssl; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; # managed by Certbot

    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; # managed by Certbot


#   ssl_certificate /etc/letsencrypt/live/www.yourdomain.com/fullchain.pem; # managed by Certbot

#    ssl_certificate_key /etc/letsencrypt/live/www.yourdomain.com/privkey.pem; # managed by Certbot

    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


  location / {

    #try_files $uri $uri/ =404;

         if (!-e $request_filename){

             rewrite ^(/)?api/.*$ /api/index.php;

         }

         if (!-e $request_filename){

             rewrite ^(/)?customer/.*$ /customer/index.php;

         }

         if (!-e $request_filename){

             rewrite ^(/)?backend/.*$ /backend/index.php;

         }

         if (!-e $request_filename){

             rewrite ^(.*)$ /index.php;

         }

         index  index.html index.htm index.php;

   }


  # pass PHP scripts on Nginx to FastCGI (PHP-FPM) server

  location ~ \.php$ {

    include snippets/fastcgi-php.conf;

    include /etc/nginx/fastcgi_params;

    # fastcgi_pass  127.0.0.1:9000;

    # fastcgi_index index.php;

    #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    #fastcgi_read_timeout 600s;

    #fastcgi_send_timeout 600s;

    # Nginx php-fpm sock config:

    fastcgi_pass unix:/run/php/php8.1-fpm.sock; #For PHP-FPM

    # Nginx php-cgi config :

    # Nginx PHP fastcgi_pass 127.0.0.1:9000;

  }


  # deny access to Apache .htaccess on Nginx with PHP, 

  # if Apache and Nginx document roots concur

  location ~ /\.ht {

    deny all;

  }

}

Office 2021 Activation using command

  @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================...