Mysql create Database and give permission to user to access and write privilege.

Login in mysql command

mysql -u root -p

Create database command

CREATE DATABASE m2;

Grant privilege

GRANT ALL PRIVILEGES ON m2.* TO 'root'@'localhost';

Puneet Kumar Magento Developer

Create a Linux Swap File

Swap is a space on a disk that is used when the amount of physical RAM memory is full. When a Linux system runs out of RAM, inactive pages are moved from the RAM to the swap space.
Swap space can take the form of either a dedicated swap partition or a swap file. In most cases, when running Linux on a virtual machine, a swap partition is not present, so the only option is to create a swap file.
This tutorial was tested on Linux systems with Ubuntu 18.04 and CentOS 7, but it should work with any other Linux distribution.

How to add Swap File

Follow these steps to add 1GB of swap to your server. If you want to add 2GB instead of 1 GB, replace 1G with 2G.

1. Create a file that will be used for swap:
sudo fallocate -l 1G /swapfile
If faillocate is not installed or if you get an error message saying fallocate failed: Operation not supported then you can use the following command to create the swap

file:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576

2. Only the root user should be able to write and read the swap file. To set the correct permissions type:
sudo chmod 600 /swapfile


3. Use the mkswap utility to set up the file as Linux swap area:

sudo mkswap /swapfile



4. Enable the swap with the following command:

sudo swapon /swapfile
To make the change permanent open the /etc/fstab file and append the following line:
/etc/fstab
/swapfile swap swap defaults 0 0



5. To verify that the swap is active, use either the swapon or the free command as shown below:
sudo swapon –show


Output

NAME      TYPE  SIZE   USED PRIO
/swapfile file 1024M 507.4M   -1


sudo free -h




Puneet Kumar Magento Developer

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

Open below URL and follow up step by step then you will not face any problem.
if you have any problem you can comment in this blog i will reply you within 24 hours.

Tutorial: Install a LAMP Web Server with the Amazon Linux AMI

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html

Puneet Kumar Magento Developer

Install composer on Amazon AMI running on EC2

Install composer on Amazon AMI running on EC2


$ cd ~
$ sudo curl -sS https://getcomposer.org/installer | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer

 then you can run
 $ sudo composer install

Puneet Kumar Magento Developer

What is interceptor or plugins in Magento 2?

Question : What is interceptor or plugins in Magento 2?

Plugins (Interceptors)

Basically plugin, or interceptor both are same. it is a class only which are modifies the behavior of public class functions by intercepting a functionality and running code before, after, or around that function call. This allows you to substitute or extend the behavior of original, public methods for any class or interface.

Extensions that wish to intercept and change the behavior of a public method can create a Plugin class.

This interception approach reduces conflicts among extensions that change the behavior of the same class or method. Your Plugin class implementation changes the behavior of a class function, but it does not change the class itself. Magento calls these interceptors sequentially according to a configured sort order, so they do not conflict with one another.

Plugins can not be used on following:

Final methods
Final classes
Non-public methods
Class methods (such as static methods)
__construct
Virtual types
Objects that are instantiated before MagentoFrameworkInterception is bootstrapped

Puneet Kumar Magento Developer

What is object manager in Magento 2?

ObjectManager

Object manager is Maento 2 core class a “Magento/Framework/ObjectManagerInterface”.

Object manager to avoid boilerplate code when composing objects during instantiation.

In the Magento framework, the implementation of the ObjectManagerInterface performs the duties of an object manager.

Responsibilities :

The object manager has the following responsibilities:

1. Object creation in factories and proxies.
2. Implementing the singleton pattern by returning the same shared instance of a class when requested
3. Dependency management by instantiating the preferred class when a constructor requests its interface
4. Automatically instantiating parameters in class constructors

Puneet Kumar Magento Developer

Deploy your static content on development mode for easy to develop your theme.

If your website is in developer mode, and you run bin/ magento dev:sourcetheme:
deploy, most files in this directory will be symlinked to their
sources throughout the Magento codebase. In production mode, you run
bin/ magento setup:static-content:deploy to process and copy files to
this directory.
Puneet Kumar Magento Developer

Magento 2 – How can i enable path hint or block hint by CLI command?

You can enable Block Hints with the  bin/magento dev:template-hints:enable. This only works in
Developer mode.
Puneet Kumar Magento Developer

How to switch Php version between two version on aws

First go to path of CD /use/bin directory and search here. Should be installed your Php version which one you want to switch after that you have to run below command.

sudo update-alternatives --set php /use/bin/php5.5
sudo update-alternatives --set php /use/bin/php7.3
sudo update-alternatives --set php /use/bin/php7.4
How to switch PHP version?

First go to path of CD /use/bin directory and search here. Should be installed your Php version which one you want to switch after that you have to run below command.
sudo update-alternatives –set php /use/bin/php5.5
change your php version according to you.

5. What step during the layout loading is the node processed?

5. What step during the layout loading is the node processed?

A. After the generation of layout blocks.

B. Vefore the generation of layout update XML, but after the generation of layout blocks.

C. Before the generation of layout blocks, but after the generation of layout XML.

D. After the generation of layout blocks, but before rendering the page.

Puneet Kumar Magento Developer