How to install theme in Magento 2

Download the theme and copy the app folder and paste it in your magento root directory

  1. Open Shell, in the root directory, enter php bin/magento  setup:upgrade . This will upgrade all the magento files.

2. Also, Clear cache ,type  php bin/magento  cache:clean . 

3. Now force deploy the static files by typing  php bin/magento  setup:static-content:deploy -f . It will take a while.

4. Now, Go in the dashboard and select content->configuration.

5. Select the option with default store view and edit.

6. Select your theme from the options and click save and edit. If some problem arises, go to the vendor/magento/module-email/Model/AbstractTemplate.php and comment the “if”  condition of “setForcedArea” function, aprox. at line 535.

7. After changing theme successfully, clear the cache as done before.

Voila, the theme is changed!!



[SOLVED] PHP must be run as a CLI application error : Content-type: text/html; charset=UTF-8

php bin/magento cache:clean
Content-type: text/html; charset=UTF-8
bin/magento must be run as a CLI application

as root user, run the following commands (For php v7.0)

# yum install ea-php70
# source /opt/cpanel/ea-php70/enable

The solution involves fixing php variable’s path. We need to find which php is being used right now, you can find out by

$ which php
$ php -v

To fix this PHP cli error, see how to edit php in bash profile (.bashrc)

MySQL error 1449: The user specified as a definer does not exist

Why this error happens?

Most of the times, reason is that your database dump through command line or PhpMyAdmin or even other libraries can have SQL’s Definer statements. Now, as per MySQL’s Official Documentation:

The DEFINER clause specifies the MySQL account to be used when checking access privileges at routine execution time for routines that have the SQL SECURITY DEFINER characteristic.

MySQL Reference Manual v8.0

Solution: MySQL mysqldump create a safe backup to ensure no corruption

Use the following command to create backup of your mysql database. Put the command in terminal

mysqldump -hHOST -uUSERNAME -p DATABASE_NAME | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > BACKUP_NAME.sql

With gzip compression > backup

mysqldump -hHOST -uUSERNAME -p DATABASE_NAME | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | gzip > BACKUP_NAME.sql


Magento 2 all cli commands

[~/www]# php bin/magento list
Magento CLI version 2.2.4
command [options] [arguments]
-h, --help            Display this help message
-q, --quiet           Do not output any message
-V, --version         Display this application version
--ansi            Force ANSI output
--no-ansi         Disable ANSI output
-n, --no-interaction  Do not ask any interactive question
-v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help                                     Displays help for a command
list                                     Lists commands
admin:user:create                        Creates an administrator
admin:user:unlock                        Unlock Admin Account
app:config:dump                          Create dump of application
app:config:import                        Import data from shared configuration files to appropriate data storage
cache:clean                              Cleans cache type(s)
cache:disable                            Disables cache type(s)
cache:enable                             Enables cache type(s)
cache:flush                              Flushes cache storage used by cache type(s)
cache:status                             Checks cache status
catalog:images:resize                    Creates resized product images
catalog:product:attributes:cleanup       Removes unused product attributes.
config:sensitive:set                     Set sensitive configuration values
config:set                               Change system configuration
config:show                              Shows configuration value for given path. If path is not specified, all saved values will be shown
cron:install                             Generates and installs crontab for current user
cron:remove                              Removes tasks from crontab
cron:run                                 Runs jobs by schedule
customer:hash:upgrade                    Upgrade customer's hash according to the latest algorithm
deploy:mode:set                          Set application mode.
deploy:mode:show                         Displays current application mode.
dev:di:info                              Provides information on Dependency Injection configuration for the Command.
dev:profiler:disable                     Disable the profiler.
dev:profiler:enable                      Enable the profiler.
dev:query-log:disable                    Disable DB query logging
dev:query-log:enable                     Enable DB query logging
dev:source-theme:deploy                  Collects and publishes source files for theme.
dev:template-hints:disable               Disable frontend template hints. A cache flush might be required.
dev:template-hints:enable                Enable frontend template hints. A cache flush might be required.
dev:tests:run                            Runs tests
dev:urn-catalog:generate                 Generates the catalog of URNs to *.xsd mappings for the IDE to highlight xml.
dev:xml:convert                          Converts XML file using XSL style sheets
i18n:collect-phrases                     Discovers phrases in the codebase
i18n:pack                                Saves language package
i18n:uninstall                           Uninstalls language packages
import:categories                        Run category importer script
indexer:info                             Shows allowed Indexers
indexer:reindex                          Reindexes Data
indexer:reset                            Resets indexer status to invalid
indexer:set-mode                         Sets index mode type
indexer:show-mode                        Shows Index Mode
indexer:status                           Shows status of Indexer
info:adminuri                            Displays the Magento Admin URI
info:backups:list                        Prints list of available backup files
info:currency:list                       Displays the list of available currencies
info:dependencies:show-framework         Shows number of dependencies on Magento framework
info:dependencies:show-modules           Shows number of dependencies between modules
info:dependencies:show-modules-circular  Shows number of circular dependencies between modules
info:language:list                       Displays the list of available language locales
info:timezone:list                       Displays the list of available timezones
maintenance:allow-ips                    Sets maintenance mode exempt IPs
maintenance:disable                      Disables maintenance mode
maintenance:enable                       Enables maintenance mode
maintenance:status                       Displays maintenance mode status
module:disable                           Disables specified modules
module:enable                            Enables specified modules
module:status                            Displays status of modules
module:uninstall                         Uninstalls modules installed by composer
sampledata:deploy                        Deploy sample data modules
sampledata:remove                        Remove all sample data packages from composer.json
setup:backup                             Takes backup of Magento Application code base, media and database
setup:config:set                         Creates or modifies the deployment configuration
setup:cron:run                           Runs cron job scheduled for setup application
setup:db-data:upgrade                    Installs and upgrades data in the DB
setup:db-schema:upgrade                  Installs and upgrades the DB schema
setup:db:status                          Checks if DB schema or data requires upgrade
setup:di:compile                         Generates DI configuration and all missing classes that can be auto-generated
setup:install                            Installs the Magento application
setup:performance:generate-fixtures      Generates fixtures
setup:rollback                           Rolls back Magento Application codebase, media and database
setup:static-content:deploy              Deploys static view files
setup:store-config:set                   Installs the store configuration. Deprecated since 2.2.0. Use config:set instead
setup:uninstall                          Uninstalls the Magento application
setup:upgrade                            Upgrades the Magento application, DB data, and schema
store:list                               Displays the list of stores
store:website:list                       Displays the list of websites
theme:uninstall                          Uninstalls theme
varnish:vcl:generate                     Generates Varnish VCL and echos it to the command line

How to connect cpanel through SSH

Following are the steps to connect to cpanel through SSH:-

  1. Go to your cpanel and create a public private key-pair,

under SSH access->manage keys.

2. Under manage keys section, go on create a new key.

3. Create a key and give key name, key password, key type and key size.

4.  Click on generate keys and it will look something like this.

5. Go back and under public key  section ,

select your public key->manage->authorize key.

6.After that go to private key section and click on download private key and enter the same paraphrase (password) that you’ve entered before (key password).

7. After the keys are downloaded, open PuTTY.  Go to sessions and enter username and hostname .eg [email protected]

8. Go to SSH , select SSH Protocol version 2:

9. Under SSH, go to Auth, and select the private key downloaded and click open

10. A terminal will pop up. Enter your key paraphrase.

11. Done , you are now connected to your root folder via SSH.


Magento File Directory

The etc folder contains the di.xml configuration file
The di.xml file contains class mapping and interface preferences
Contains the design folder for themes.

The directory contains the magento file or a Command Line Interface script

Magento 2 testing and development tools are placed in this folder.

The internal and web subfolders are located here
The internal directory contains server-side libraries and several font files;
The web subfolder contains client-side libraries, jquery, modernizr, requirejs, prototype, scriptaculous

It should be set as your web root on the server
It contains all the publicly accessible files
index.php controller is also contained in the folder
pub also contains the error pages that will be displayed if your site is showing a 404 or 503 or another report page
Image uploads and imports will appear somewhere within pub/media.

caches and generated classes are all located in the folder
the var folder includes cache, composer_home, generation, log, di, view_preprocessed, page_cache files

the folder includes various packages that have been defined under composer.json
Marketplace modules and the core modules are all under vendor.
If you download something from the new Magento Marketplace.

Linux commands for SSH

  1. tar– to create archive files(.zip, .tar)

tar [options] [archive-file] [file or directory to be archived]

-c : Creates Archive
-x : Extract the archive
-f : creates archive with given filename
-t : displays or lists files in archived file
-u : archives and adds to an existing archive file
-v : Displays Verbose Information
-A : Concatenates the archive files
-z : zip, tells tar command that create tar file using gzip
-j : filter archive tar file using tbzip
-W : Verify a archive file
-r : update or add file or directory in already existed .tar file

2. curl – Transfers data from or to a server, using one of the protocols: HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE.

curl [options] [URL…]

3. service– The service command is used to run a System V init script. Usually all system V init scripts are stored in /etc/init.d directory and service command can be used to start, stop, and restart the daemons and other services under Linux.

The COMMAND can be at least start, stop, status, and restart.

4. netstat– The netstat command is used to display very detailed information about how your computer is communicating with other computers or network devices.

5. wget– Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on the system and it can work in background without hindering the current process.

wget [option] [URL]

6. grep– The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern.

grep [options] pattern [files]

Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.

7. ls – list directory contents
ls [OPTION]… [FILE]…

ls -l list with long format, show permissions
ls -la list long format including hidden files

8. cat – Concatenate and print the content of files.

cat [Options] [File]…

9. nano– GNU nano is a text editor for Unix-like computing systems or operating environments using a command line interface.

10. vi – vi is a screen-oriented text editor originally created for the Unix operating system.

11. cp – cp stands for copy. This command is used to copy files or group of files or directory.

cp [OPTION] Source Destination
cp [OPTION] Source Directory
cp [OPTION] Source-1 Source-2 Source-3 Source-n Directory

First and second syntax is used to copy Source file to Destination file or Directory.
Third syntax is used to copy multiple Sources(files) to Directory.

12. mv– mv stands for move. mv is used to move one or more files or directories from one place to another in file system

mv [Option] source destination

13. sudo– sudo (“superuser do”, or “switch user do”) allows a user with proper permissions to execute a command as another user, such as the superuser.

14. rm -rm stands for remove here. rm command is used to remove objects such as files, directories, symbolic links and so on from the file system

15. mkdir– make directories

16. ln -The ln command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file. The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk.

.htaccess redirect from http to https and from non-www to www redirect – Make site permanently SSL secured

put this in your htaccess file:

RewriteCond %{HTTP_HOST} !^www\.(.*)
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RPM repo not found connection errors on Centos Redhat duplicate problems

yum -y update command failing

Command line will show messages like

xxx is outdated and v abc will be installed
but at the end it shows duplicate binary, please remove duplicate first.


Backup first
Integrity Check
Find Problems
Identify duplicates
Clean duplicates
re build conf cache
update command
remove backup file .prev if successfully solved

\cp -r /var/lib/rpm /var/lib/rpm.prev
package-cleanup --problems
package-cleanup --dupes
package-cleanup --cleandupes
yum clean all
rpm --rebuilddb
yum update
# if all went OK run 'rm -rf /var/lib/rpm.prev'

Other possible solution

1. Update DNS to google dns and or freenom dns and


2. Restart internet while maintaining SSH session (you wont be logged out)

/etc/init.d/network restart

Linux – Rescue disk how to reset root password and unblock yourself if locked out

Centos as test server

Current situation – you are locked out, cant use WHM or SSH or anything else to login.
You may or may not remember the password. In any case you can reproduce the following steps to unblock yourself.

1. Use any other linux OS cd which can run live. I prefer FINNIX iso for such cases
2. Mount your main disk.

mount /dev/vda1 /mnt

3. Reset password if needed to

chroot /mnt passwd

4. Enter new password for root and confirm
5. Reboot and done.

In case you have been locked out due to WHM cpanel:
1. Use any other linux OS cd which can run live. I prefer FINNIX iso for such cases
2. Mount your main disk.

mount /dev/vda1 /mnt

3. Stop cphulk service for brute force protection

chroot /mnt /usr/local/cpanel/etc/init/stopcphulkd
chroot /mnt /usr/local/cpanel/bin/cphulk_pam_ctl --disable

4. Disable the lock for cphulk so that it does not start automatically after restart

chroot /mnt rm /var/cpanel/hulkd/enabled

5. Reboot and done

METHOD 2 – in case you are blocked at firewall level

In case you have been locked out due to WHM cpanel and just want to whitelist yourself:
1. Use any other linux OS cd which can run live. I prefer FINNIX iso for such cases
2. Mount your main disk.

mount /dev/vda1 /mnt

3. Stop cphulk service for brute force protection

chroot /mnt /usr/local/cpanel/etc/init/stopcphulkd
chroot /mnt /usr/local/cpanel/bin/cphulk_pam_ctl --disable

4. Disable the lock for cphulk so that it does not start automatically after restart

chroot /mnt /scripts/cphulkdwhitelist XXX.82.6.156

5. Remove yourself from firwall

chroot /mnt whmapi1 flush_cphulk_login_history_for_ips ip=XXX.82.6.156

6. Reboot and done

Remove lockouts
If the cPHulk service locks you out of your cPanel account, the /scripts2/doautofixer?autofix=disable_cphulkd script in WHM can disable cPHulk and allow you to log in.

For example, log in to WHM and navigate to, where represents your server’s hostname.

If you enabled the Block IP addresses at the firewall level if they trigger brute force protection or the Block IP addresses at the firewall level if they trigger a one-day block options in WHM’s cPHulk Brute Force Protection interface (WHM >> Home >> Security Center >> cPHulk Brute Force Protection), remove the iptables rule that the system created. To do this, run the following command:

iptables -F cphulk && mysql -e "Delete from cphulkd.login_track;"