Tuesday 28 May 2019

How to connect ssh using PPK file into Cpanel from terminal Ubuntu

Connection command without PPK file
ssh username@146.66.87.208 -p18765
 Connection command with PPK file
ssh -i privatekey.ppk username@146.66.87.208 -p18765 (if not connect with PPK or give an error like "Load key "privatekey.ppk": invalid format" so please use the direct file without PPK format (See the following screenshot) ) (Supported port : 22, 18765, 18675)

Thursday 9 May 2019

Access denied for user 'root'@'localhost' even password is correct

Error : SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket
Step 1 : For backup = cp -rfv /var/lib/mysql /var/lib/mysql$(date +%s)
Step 2 : sudo /etc/init.d/mysql stop
Step 3 : sudo mysqld_safe --skip-grant-tables & (If process will not complete after 5 minuts keep this window open and open another terminal window)
Step 4 :  mysql -u root -p 
Step 5 : FLUSH PRIVILEGES;
Step 6 : UPDATE user SET Grant_priv = 1, Super_priv = 1 WHERE user = 'root'
Step 7 : update user set password=PASSWORD("Franki3r0s3") where User='root';
Step 8 : GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'anki8f0s3';

Additional commands : 
1. mysql# show users;
2. mysql# SELECT User FROM mysql.user;
3. ps -e | grep mysqld
4. kill -kill 16300
5. ps -x



Friday 22 March 2019

How to make backgroud process in php using shell_exec

Create background.php file
<?php
$post_id = ['post_id'=>10];
$post_id = json_encode($post_id);
$pid = shell_exec("php /var/www/html/magento/dump/exportfile.php $post_id alert >> /var/www/html/magento/dump/test.log & echo $!");
echo $pid;
Create checkprocess.php file
$pid = 1254; // Copy pid from background.php
if (file_exists("/proc/$pid" )){
    echo "process with a pid = $pid is running";
}
 Create exportfile.php file
//Create this file with high time taking script

Friday 8 March 2019

How to create CloudFront Distributions / CDN in AWS with Origin EC2 / Loadbalancer

Origin Settings

Step 1 : Login AWS console ( https://console.aws.amazon.com )
Step 2 : Open CloudFront console ( https://console.aws.amazon.com/cloudfront/ )
Step 3 : Click on "Create Distribution" 
Step 4 : Click on "Get started" on Web
Step 5 : "Origin Domain Name" = Select your load balancer for EC2 
Step 6 : Origin Path = Blank (add cdn file directory path if specific dir add for CDN )
Step 7 : Origin SSL Protocols = default selection
Step 8 : Origin Protocol Policy = HTTP Only
Step 9 : Origin Response Timeout = 30 (default) 
Step 10 : Origin Keep-alive Timeout = 5 (default)
Step 11 : HTTP Port = 80  (default)
Step 12 : HTTPS Port = 443 (default)
Step 13 : Origin Custom Headers = Blank (like default) 

Default Cache Behavior Settings 

Step 14 : Viewer Protocol Policy = HTTP and HTTPS
Step 15 : Allowed HTTP Methods = GET, HEAD
Step 16 : Field-level Encryption Config = blank (default)
Step 17 : Cache Based on Selected Request Headers = None (default)
Step 18 : Object Caching = Use Origin Cache Headers (default)
Step 19 : Forward Cookies = None (default)
Step 20 : Query String Forwarding and Caching = None (default)
Step 21 : Smooth Streaming = No (default)
Step 22 : Restrict Viewer Access (Use Signed URLs or Signed Cookies) = No (default)
Step 23 : Compress Objects Automatically = No (default)
Step 24 : Lambda Function Associations = (default)

Distribution Settings

Step 25 : Price Class = Use U.S., Canada, Europe, Asia and africa (You can select ALL for best performance world wide)
Step 26 : AWS WAF Web ACL = None (default)
Step 27 : Alternate Domain Names (CNAMEs) = Subdomain like cdn.jaydipkansagra.com (you can add multiple domain here)
Step 28 : SSL Certificate = Select custom if you want SSL on cdn url ( If option disable you need to create Certificates into N.Virginia ) 
Step 29 : Supported HTTP Versions = HTTP/2, HTTP/1.1, HTTP/1.0
Step 30 : Default Root Object = Blank (default)
Step 31 : Logging = Off (default)
Step 32 : Enable IPv6 = Checked (default)
Step 33 : Comment = Blank (default)
Step 34 : Distribution State = Enabled (default)
Step 35 : Click on Create Distribution button (default)

Pointout domain 

Step 36 : Point subdomain cdn.jaydipkansagra.com to d111111abcdef8.cloudfront.net
Step 37 : open the Route 53 console at https://console.aws.amazon.com/route53/
Step 38 : Click Hosted Zones
Step 39 : Click Create Record Set
Step 40 : Name = cdn, Type = CNAME, Alias = NO, TTL (Seconds) = 300, Value = d2m9sh2v6fo5gb.cloudfront.net
Step 41 : Click on save button
Step 42 : Finish : Open http://cdn.jaydipkansagra.com thats done

Tuesday 29 January 2019

How To Migrate Magento 1 To Magento 2

Step 1 : Get full backup of your Magento 1 store including all files, folders, and the database

Step 2 : Create a clone of your Magento 1 store. Do not use your live store for Magento migration process

Step 3 : Check your store. Keep what you think is necessary and delete the rest

Step 4 : Check whether your current theme(s), extensions and custom code are compatible with the Magento 2 or not.

Step 5 : Create clone of Magento 1 database and connect with new(clone) magento 1.

Step 6 : Remove useless data from the database including logs, recently viewed products, compared products, etc.

Step 7 : To make Magento migration process as hassle-free as possible, install a fresh and latest copy of Magento 2 on the same hosting server where your Magento 1(cloned) store is located.

Step 8 : To find the version of your store, navigate to the root directory of your Magento 2 via SSH and enter the following command:
php bin/magento --version
Step 9 :
composer config repositories.magento composer https://repo.magento.com
composer require magento/data-migration-tool:2.3.0
You will be asked to enter your developer authentication keys. Go to the Magento Marketplace. Sign in using your login credentials, go to your profile and then click Access Keys under My Products section.

If you already have keys then, your public key will be your username and the private key will be your password. Otherwise, create a new key pair by clicking the Create a New Access Key button.

In a few seconds, the Data Migration Tool will be successfully installed on your Magento 2 store.

Configure Magento 2 Data Migration Tool


Step 10 : Goto <Magento 2 root dir>/vendor/magento/data-migration-tool/etc/opensource-to-opensource/<Magento 1.x version> and rename config.xml.dist to config.xml

Step 11 :

Next, open config.xml in your favorite code editor and specify the following:

<source>

<database host="localhost" name="Magento1-DB-name" user="DB-username" password="DB-password"/>

</source>

<destination>

<database host="localhost" name="Magento2-DB-name" user="DB-username" password="DB-password"/>

</destination>

<options>

<crypt_key>Magento1-Encrypted-Key</crypt_key>

</options>

In the above code, <source> has the database information of Magento 1 and <destination> has the relevant database information of Magento 2. <crypt_key> is mandatory and needs to be filled prior run. It is the encryption key of Magento 1 store and can be found in the <Magento 1 root dir>/app/etc/local.xml file, within the <key> tag.

When finished, save the config.xml and you are done.

Migrate Settings Using Magento 2 Data Migration Tool


Here is how you can use the Data Migration Tool to migrate settings from Magento 1 to Magento 2. These settings include stores, websites, system configurations such as shipping, payment, tax settings, etc.

According to the Magento Data Migration Order, you should migrate settings first. To start migrating the settings, navigate to your Magento 2 root directory via SSH terminal and run the following command:
php bin/magento migrate:settings --reset <path to your config.xml>
where <path to your config.xml> this would be vendor/magento/data-migration-tool/etc/opensource-to-opensource/<Magento 1.x version>/config.xml. I have used --reset argument in the above command which forces the Data Migration Tool to start from the beginning.

Once the settings migration is over, a successful message will be displayed.


Migrate Data Using Magento 2 Data Migration Tool


Data migration from Magento 1 platform to Magento 2 platform includes products, categories, orders, customers, wish lists, ratings, etc. To migrate data, run the following CLI command:
php bin/magento migrate:data --reset <path to your config.xml>
As this command runs, the Magento 2 Data Migration Tool saves its current progress, and in the case of an error, stop the process and resume from the last known good state. Also, the Magento 2 Data Migration Tool may report some errors during the migration. In such a case, refer to the Troubleshooting page of the Magento 2 Data Migration Tool for further assistance.

Step 12 : Finish and check Your Magento 2 store


How to install Extension in PHP 7.2 | PHP 7.1 | PHP 7.0 in Ubuntu 16.04 | Ubuntu 18.04

Open terminal or cmd and put following command
apt install php7.2-soap
apt install php7.2-bcmath

Thursday 24 January 2019

How to dump Magento 2 Enterprise Edition Database

  1. curl -sS https://accounts.magento.cloud/cli/installer | php
  2. magento-cloud list
  3. login without root
  4. magento-cloud db:dump
  5. Open login URL in browser like : http://127.0.0.1:5000
  6. Update to version 1.23.0? [Y/n] y
  7. Continue? [Y/n] y
  8. Enter a number to choose a project:
    1.  [0] ProjectName (Project) (tx2ia23dv5uk)
    2.   Environment ID [staging]: (Press enter key)
  9. Enter a number to choose a relationship:
    1.   [0] database
    2.   [1] database-slave
  10. (Press 0 and Enter key)