.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.

Process

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
yum-complete-transaction
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 8.8.8.8 and 8.8.4.4 or freenom dns 80.80.80.80 and 80.80.81.81

system-config-network

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 https://www.example.com:2087/scripts2/doautofixer?autofix=disable_cphulkd, where www.example.com 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;"

Installing Magento Common Issues

Following are the steps to complete install Magento error-free:-

  • Uncomment the files which are required by Magento in php.ini and restart the server
  • If installation error occurs, set memory_limit = 786M
  • if still error occurs, uninstall the db and make it again
  • after successfull install, go to (root_directory)app/etc/di.xml and change “Symlink” to “Copy” in developerMaterialization section.
  • go to cmd , root directory and type :- “/bin/magento setup:static-content:deploy
  • refresh the page. done.

PHP Malware – Important regex to bust infected website

grep -rnwl './' -e 'eval'
grep -rnwl './' -e ']};}'
grep -rnwl './' -e '}["'
grep --include=*\.php -rnwl './' -e '${${'
grep -rnwl './' -e '57h'
grep -rnwl './' -e '3o'
grep -rnwl './' -e '__O'
grep -rnwl './' -e '__0'
grep -rnw './' -e '057home'
grep -rlnw './' -e '057home'
find -name "*.ico"
grep --exclude=\*.scss -rnwl './' -e '@include'
grep --exclude=\*.{scss,css,map,js} -rnwl './' -e '@include'
grep -rlnw './' -e '057ho'
grep --exclude=\*.{svg,jpg,png,jpeg} -rlnw './' -e '057'
grep -rlnw './' -e '057h'
grep --include=\*.php -rnwl './' -e '@include'
grep -rlnw './' -e '057hom'
grep -rlnw './' -e '7hom'
grep -rnwl './' -e 'bgeteam'
nano grep -rnwl './' -e 'abcd'
grep -rnwl './' -e 'abcd'
grep -rnwl './' -e '{eval'

Light flick effect on image hover – CSS

.collection-grid-item__link:before{
    -ms-transition:all 0.5s ease-in-out;
    -webkit-transition:all 0.5s ease-in-out;
    transition:all 0.5s ease-in-out;
    content:"";
    position:absolute;
    top:-110%;
    left:-210%;
    width:200%;
    height:200%;
    opacity:0;
    filter:alpha(opacity=0);
    -webkit-transform:rotate(30deg);
    -ms-transform:rotate(30deg);
    -moz-transform:rotate(30deg);
    -o-transform:rotate(30deg);
    transform: rotate(44deg);
    background:rgba(255,255,255,0.1);
    background:linear-gradient(to right, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.1) 77%, rgba(255,255,255,0.5) 92%, rgba(255,255,255,0) 100%);
}

How to install wordpress on cPanel

WordPress is a free and open-source content management system (CMS) based on PHP and MySQL.Features include a plugin architecture and a template system.

Follow these steps to install WordPress:

Download WordPress

Download WordPress from this link:  https://wordpress.org/download/

Create Database

Create an empty database for WordPress and specify it’s username and password.

Set up Wizard

  • Step 1: Upload the downloaded compressed file on your website root directory and extract it.

  • Step 2: Open the url of your website and install WordPress.

 

  • Step 3: Specify the  Database Name, Username, Password and Database Host.

  • Step 4:  A confirmation message will appear after the database settings are validated. Click on ‘Run the Installation’ button.

  • Step 5:  Provide the administrative information needed for your WordPress website and Install WordPress.

  • Step 6: You have successfully installed WordPress and the final step is to log in, for which you will use the username and password entered at step 5.

 

Commands not to be used on terminal as a root user

First one on list is the infamous 8 characters in that particular order

rm -rf /

Sometimes we just want to remove the current directory for which the command is rm -rf ./ but you keyboard skips the dot and you end up in a deadzone.

Second one would be:

ifdown eth0

wow!!, you just disconnected your server from internet.

Basics about advertisements and Google Adsense

On 15th Year Anniversary of GOogle Adsense and their partnerships with Publishers, google published a youtube video briefly explaining all the basic keywords related to Adsense.

Transcript:
15 words to sum up 15 years?
That's easy! Okay, let's go.
Content
Content is at the heart of the web.
And publishers?
You power that web. Without you that place would be quite empty.
Ads? Ads bring the revenue that helps to fund it all while helping you reach your…
Goals! Goals like growing your business, doing something you love and sharing it with the world creating…
Memories? So many good memories!
You've told us that Adsense has funded your weddings,
helped you buy your homes or hire new teams. We feel part of your…
Community. A community that grows with you recommending us. Thank you!
Beginnings. It's been 15 years since we ran our first ads, they were text only back then.
Today? Today Adsense is truly global!
Urdu, Japanese or French – We speak 45 languages. And counting.
Change…is constant, especially on the web.
We've been evolving with you and your audience needs for the past 15 years,
to help you provide the best possible…
…Experiences. As the look and feel of websites have improved over the years
we built native ads to complement them,
while always giving you the…
Control. To decide what type of ads will show on your site.
Platforms? All of them. Mobile, Video and whatever will come next – we have you covered.
Time. Saved. With smart automated ad placements,
keeping things simple for you so that you can focus on creating great content.
Simplicity. Always. Our team's goal: making it easier to grow your business.
Okay and last but not least.
Happy Birthday! Absolutely. 15 years is a milestone we should all celebrate.
But the web doesn't wait so time to get back to work.
Can I finish my cake first?

Watch the video here