Blog

How to install Elasticsearch 7.x

With the latest version of Magento, Magento 2.4 removing the MySQL search capability and forcing the use of Elasticsearch 7.x, many users may be frantically searching for the latest guide to install Elasticsearch in your server.

As most of the guides around the net are either outdated or may not work well in a CentOS 7 environment with cPanel/WHM installed, I hope this installation guide will be helpful to those of you running CentOS 7.

Firstly, create a yum repository in your server for Elasticsearch 7.x:-

nano /etc/yum.repos.d/elasticsearch.repo

Add the following content to the file:-

[elasticsearch]
name=Elasticsearch repository for 7.x packages 
baseurl=https://artifacts.elastic.co/packages/7.x/yum 
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch 
enabled=0
autorefresh=1
type=rpm-md

Then, run the Elasticsearch installation:-

yum -y install --enablerepo=elasticsearch elasticsearch

Once the installation is complete, modify the file below:-

nano /etc/sysconfig/elasticsearch

Add this to any new line in the file above to reference a temporary directory:-

ES_TMPDIR=/usr/share/elasticsearch/tmp

Create the temporary directory referenced above and set the appropriate file permissions:-

mkdir /usr/share/elasticsearch/tmp
chmod 777 /usr/share/elasticsearch/tmp

Make sure Elasticsearch will be started automatically whenever the server reboots:-

/bin/systemctl daemon-reload
/bin/systemctl enable elasticsearch.service

Start Elasticsearch:-

/bin/systemctl start elasticsearch.service

How to get MailChannels Inbound Spam Filtering for Free!

How to get MailChannels Inbound Spam Filtering for Free!

I recently came across a blog post by MailChannels which announced that they are now available as a CloudFlare App, which allows their service to be added to CloudFlare in a few clicks.

The biggest highlight in the blog post is the following:-

MailChannels created a special free plan for Cloudflare customers looking to add better spam filtering for a single domain.

For $0/month, you get commercial-grade spam, virus, and phishing protection for up to 5 users.

This is great news for CloudFlare users if you have less than 5 email accounts for your domain and want to use MailChannels professional inbound Spam filtering service.

MailChannels Inbound will remove Spam, phishing and virus from your emails before sending them to your mail or web hosting server.

Besides that, it will also hide or mask your actual mail server IP address which means that attacker will not know the actual mail server IP and thus not able to attack it directly.

To enable this service:-

  1. Login to your CloudFlare account and navigate to the MailChannels app.
  2. Click Preview MailChannels
  3. Click Finish installing onto your site

Once installed, the app will automatically configure the MX records on your domain and redirect your email traffic through MailChannels for scanning.

Accounts are automatically created for the administrator and end-users as you send email traffic.

How to forward emails to Gmail the right way

How to forward emails to Gmail the right way

You may want to forward emails from your custom @yourdomain.com email address to Gmail or another email service like Outlook for easier email management or so that multiple users will receive the emails.

If your email address is created with your web hosting provider, it may be tempting to use their Email Forwarder feature available in their hosting control panel (like cPanel or DirectAdmin) to forward some or all of your emails to another email service like Gmail.

Let me stop you right there with a warning that this is an extremely bad idea!

By forwarding your emails to Gmail, you are also forwarding Spam emails sent to @yourdomain.com to Gmail as well.

From Gmail’s point of view, they are receiving Spam emails from your domain and your email server!

If this continues over time, Gmail will categorize both your domain name and your email server IP as a source of spam, which means that any future emails that you sent will either end up in Gmail’s Spam box or get rejected outright!

Is there a better way to achieve this?

The best way to go about this is to use Gmail’s Check emails from other accounts feature.

This feature allows you to use Gmail to connect to your email server using POP and download the email message to Gmail, sort of like how an email client like Microsoft Outlook, Apple Mail or Mozilla Thunderbird works.

Gmail Check Emails from Other Accounts

Alternatively, you can also use a service called ImprovMX which allows you to setup email forwarding in seconds and start receiving and sending emails with your domain name, absolutely free.

ImprovMX Free Email Forwarding

You can setup email addresses with your own domain and have it forward to your personal or specially created email address at Gmail, Outlook or anywhere else.

What is using up all of my inodes?

What is using up all of my inodes?

Did you receive a notification from your web hosting provider about something called “inode”? What’s an inode anyway? Are you not within your Disk Space limit?

An “inode” is the data structure in a file system that describes a file-system object such as a file or a directory. To put it simply, each and every file and directory in your account is considered to be an “inode”. If you have 100 files and 20 directories, you have 120 inodes.

Most web hosting providers will have set a limit to the number of inodes each hosting account can have, which is generally between 200,000 to 300,000. The limit is set to ensure optimal server operation as every storage drive has a fixed number of inodes limit which should not be exceeded. Besides that, having a high number of inodes in a server will significantly slow down the time taken to complete a backup.

What files and/or directories are using up your inodes?

To check what files and/or directories are using up your inodes, run this SSH command:-

find . -printf "%h\n" | cut -d/ -f-2 | sort | uniq -c | sort -rn

You will see a list of directories along with their inode usages.

Most inodes are used by temporary files like caches so you can remove those files to free up your inodes.

How to test or preview website in a different server

How to test or preview website in a different server

So you’ve migrated your website to a new server or web hosting provider and you want to view your website in the new server before pointing your DNS over?

There are generally three ways for you to achieve this:-

  1. Modify your computer’s host file to add a host entry for your domain to point to the new server IP.
  2. Create a test subdomain in the new server and point the A record for this subdomain to the new server IP.
  3. Ask for a temporary URL from your hosting provider.

What if there’s a better way to achieve this?

I’ve been using a service called HOSTS.CX which allows you to preview your website from a different server.

HOSTS.CX Website Previewer

Assuming that the website has been copied or migrated over to the new server, all you need to do is to provide your website address and the new server IP in HOSTS.CX.

It will generate a custom link for you where you can preview your website from the new server instantly without any DNS or host file modifications.

What’s more, you can also share the custom link with your colleagues and clients and it’ll just work!

One thing you will want to keep in mind is the custom link generated by HOSTS.CX is public so it can be accessed by anyone who possessed the link. If you have a top secret website that you don’t want to show to the public, this may not be a suitable tool for you.