Monday, 10 January 2022

git log to file

git log --author="gunabalan" --no-merges --since='12-01-2021' --date=short --pretty=format:'"%an" :: "%ad" >>> "%s"' > file.csv

Friday, 8 October 2021

aws light sail pont to a domain in godaddy

Step 1: go to light sail dashboards and
 

Step 2: Assign static ip to the instance
 

Step 3: create dns zone with that static ip

This will  provide Name server;

Step 4: Now u can also add A record for subdomain ex: www for your domain and use @ to pint the main domain

ex: @ to point your domain.com

      www to pint your www.domain.com


Step 5: now go to domain where u baught   (example godaddy dashboards)
    you can see the DNS >
 

Step 6 : Now change Name server > and add the name provided by aws

That is it; dns propagation take min 24 hrs
so it will take 24 hrs min to see the changes the url points to new aws hosting

Note: 

The A record maps a name to one or more IP addresses when the IP are known and stable.
The CNAME record maps a name to another name. It should only be used when there are no other records on that name.
The ALIAS record maps a name to another name, but can coexist with other records on that name.


Thursday, 7 October 2021

Error in query (1267): Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_0900_ai_ci,IMPLICIT) for operation '='

SET SESSION default_collation_for_utf8mb4 = 'utf8mb4_unicode_ci'


The Unicode organization has been evolving the specification over the years. Here are the mappings from its "versions" to MySQL Collations:

4.0   _unicode_
5.20  _unicode_520_
9.0   _0900_

The suffix (MySQL doc):

_bin      -- just compare the bits; don't consider case folding, accents, etc
_ci       -- explicitly case insensitive (A=a) and implicitly accent insensitive (a=á)
_ai_ci    -- explicitly case insensitive and accent insensitive
_as (etc) -- accent-sensitive (etc)


Performance:

_bin         -- simple, fast
_general_ci  -- fails to compare multiple letters; eg ss=ß, so somewhat fast
...          -- slower
_900_        -- (8.0) much faster because of a rewrite

From mysql:8 default collation
collation_connection    utf8mb4_0900_ai_ci
collation_database    utf8mb4_0900_ai_ci
collation_server    utf8mb4_0900_ai_ci

So we can go with utf8mb4_0900_ai_ci
    because 1. Unicode 9.0 specification
            2. introduced in mydql 8
            3. reported faster Performance    


Step 1 - data base alter collate

ALTER DATABASE `dbname` COLLATE utf8mb4_unicode_ci

Step 2 - alter collate of table 

 ALTER TABLE tablename  COLLATE 'utf8mb4_0900_ai_ci';

 

Error in query (1292): Incorrect datetime value

Run this query - this work for a session
 

SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';


best way is to set in mysql .cnf files


$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

Below [mysqld] section add sql_mode command Example:

[mysqld]
sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

Then validate config

sudo mysqld --validate-config
OR
sudo mysqld --defaults-file=/etc/mysql/my.cnf --validate-config

No output, then everything good.

Then
sudo service mysql restart

Tuesday, 30 March 2021

installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1

 sudo apt-get purge mysql-server
sudo dpkg --remove --force-remove-reinstreq mysql-server
sudo dpkg --remove --force-remove-reinstreq mysql-server
sudo dpkg --remove --force-remove-reinstreq
Errors were encountered while processing:
 mysql-server-8.0


installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1


sudo apt-get purge mysql-common
sudo rm -rf /var/log/mysql
sudo rm -rf /var/log/mysql.*
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
 

sudo dpkg --remove --force-remove-reinstreq mysql.*
 

# and then:
sudo apt-get install mysql-server --fix-missing --fix-broken


Configure nginx web server with tls and firewall in ubuntu

Install nginx


sudo apt update
sudo apt install nginx
 

after installation these are the command to operate nginx

sudo systemctl status nginx
sudo systemctl stop nginx
sudo systemctl reload nginx
sudo systemctl restart nginx
sudo systemctl start nginx
sudo systemctl disable nginx
sudo systemctl enable nginx
 

log files is here

 error_log /var/log/nginx/error.log;

change document root

sudo chown -R www-data:www-data /var/www/html/

permission may be 755 or 644
 

sudo chmod -R 755 ./

 

Configure firewall

    sudo ufw status 

    sudo ufw app list

    sudo ufw allow 'Nginx Full'
    sudo ufw allow 'OpenSSH'
 

    or
    sudo ufw allow ssh   

    This will add tcp 22 port (22/tcp (v6)    ALLOW       Anywhere (v6))

    sudo ufw logging on

    sudo ufw logging low|medium|high
    /var/log/ufw.log


Install mysql server


    
sudo apt-get install mysql-server

        Any issue you can find log here

        /var/log/mysql/error.log


    
sudo mysql_secure_installation

         follow steps of the above command

        use localhost for host; that is allow database access only from localhost

             Manage mysql service

             sudo service mysql start
            sudo service mysql stop


        Create new user and set privilages

        sudo mysql

            USE databasename;
            CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'your pw';
            GRANT ALL ON
databasename.* TO 'newuser'@'localhost';
            FLUSH PRIVILEGES;

Install PHP

    sudo apt-get install php7.4-fpm php-mysql

    
sudo systemctl restart php7.4-fpm
    sudo service mysql restart

additionally you may need zip; gd;

    sudo apt-get install php7.4-zip

 
    sudo apt-get install php7.4-curl

    sudo apt-get install php7.4-gd


    sudo curl -V

 

Lets-encrypt for nginx

     Install snapd

Snap (also known as Snappy) is a software deployment and package management system.Snapd is a REST API daemon for managing snap packages. 

    Ensure that your version of snapd is up to date

    sudo snap install core
    sudo snap refresh core

Remove any pre existing Certbot packages 

        sudo apt-get remove certbot
         sudo dnf remove certbot
         sudo yum remove certbot

        Install Certbot 

        sudo snap install --classic certbot

        sudo certbot --nginx

            Follow step by step process; example the certificate issued for the host :                         

             www.ishtabox.com,ishtabox.com

 

nginx  server block to run php

https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04

 

sudo vi /etc/nginx/sites-available/default

 

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}


 ==========

Test your configuration file for syntax errors:

 sudo nginx -t

 Then reload server

sudo systemctl reload nginx

now put a php file in document root  and test the site
 

Ref:

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04

https://www.linode.com/docs/guides/configure-firewall-with-ufw/
https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx
   
       
 

Monday, 15 March 2021

woocommerce force ssl checkout

force to use Checkout page  with https or remove for local host dev purpose

 https://localhost/wordpress/with checkout/


 

 

or more advanced setting from admin..

http://localhost/wordpress/wp-admin/options.php

add in the option

woocommerce_force_ssl_checkout

yes or no