Complete Tutorial on Installing Meilisearch Search Engine and Integrating with WordPress using HestiaCP

Last week a beautiful woman talked about herWordpressThe website search is too slow, and the results for searching "tutorial" in Chinese are all messed up. I'd like to help you fix it.

I thought it was simple: just switch to a different search engine. Meilisearch is the hottest open-source search engine right now, its Chinese word segmentation is ridiculously strong, and its performance is great. Just install it and you're good to go, right?

result. . .

I was in hisHestiaCPI spent a whole day messing around with the control panel's server. Permission errors, services failing to start, 502 Bad Gateway—I encountered every single one of those classic pitfalls.

To be honest, I wasn't sure if it would work at first, but looking back after all the effort, it really only involved a few key points, and once you figured them out, it was quite simple. Today I'm sharing this solution; if you're also using HestiaCP + WordPress, just follow along.

WordPress search is too difficult to use, I've decided to switch to it.

Anyone who has used WordPress knows how difficult the built-in search function is.

It's the kind of search result you get when you search for "AIThe search term "tutorials" returns a bunch of articles containing "AI" or "tutorials," but they are completely irrelevant. Searching for "HestiaCP installation" brings up a ton of irrelevant results with the word "installation" in them. The user experience is atrocious; every search feels like a lottery.

Complete Tutorial on Installing Meilisearch Search Engine and Integrating with WordPress using HestiaCP

Meilisearch is completely different. It supports Chinese word segmentation, understands what you're searching for, and has incredibly high performance with millisecond-level response times. Crucially, it's open-source and free; you deploy it yourself, and your data is entirely in your control.

The problem is that while the official tutorials are general, the HestiaCP panel is somewhat unique. It has strict access control and its Nginx configuration follows specific rules; directly following the official documentation will likely lead to problems.

I messed up.

A Troubleshooting Guide to Installing Meilisearch on HestiaCP

The first time I installed it, I used the official one-click script, just a quick curl command and it was done. But the service wouldn't start, giving me a "Permission denied" error.

I realized something was wrong; I was using root access. Then I discovered that the downloaded binary file lacked execute permissions. HestiaCP's environment is slightly different from standard Debian, and path permissions are also restricted.

After all that work, the service was up and running, but when I tried to use curl on the local port, I got a 502 Bad Gateway error.

This is a huge pitfall. HestiaCP's Nginx configuration has its own management method; you can't just manually modify a configuration file. You have to use its control panel to manage it, or manually access the configuration files it generates. I didn't understand this at first and went through several rounds of trial and error.

After finally figuring it out completely, I put together a plan, started from scratch, and finished it in ten minutes.

Meilisearch Standard Installation Method (HestiaCP Only)

Please note that my solution is specifically designed for HestiaCP, and it differs from the official tutorial, but it is more stable.

First, update the system dependencies; there's not much to say about that.

apt update && apt install curl wget -y

Then, the crucial step is to delete any residual files that may have been left behind. If you've installed it before, whether successfully or not, there might be files with abnormal permissions remaining. Don't hesitate, delete them directly.

rm -f /usr/local/bin/meilisearch

Many people overlook this step, but let me tell you, it's one of the root causes of 502 errors. In HestiaCP environments, the permissions of the /usr/local/bin path are a bit unpredictable; deleting it and starting over is the cleanest solution.

Then install it with one click from the official website.

curl -L https://install.meilisearch.com | sh

After installation, don't rush to start it. First, move the binary file to a safe place.

mv meilisearch /usr/bin/
chmod +x /usr/bin/meilisearch

This step is crucial. /usr/bin is the standard system executable file directory, with more standardized permission management, avoiding those strange permission issues.

Then create the data directory.

mkdir -p /var/lib/meilisearch

Next, configure the systemd service to start automatically on boot. Create a service file.

nano /etc/systemd/system/meilisearch.service

Paste the following configuration file.

[Unit]
Description=Meilisearch Search Engine
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/meilisearch \
    --env production \
    --http-addr 127.0.0.1:7700 \
    --db-path /var/lib/meilisearch \
    --master-key 1234567890123456

Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Note a few points. The http-addr is bound to 127.0.0.1:7700, meaning it only listens locally and is inaccessible from the external network; this is the most secure approach. The master-key must be at least 16 characters; don't use my example, create your own complex one.

After saving and exiting, reload the configuration and start the service.

systemctl daemon-reload
systemctl enable meilisearch
systemctl restart meilisearch

Then test it.

curl http://127.0.0.1:7700/health

If returned{"status":"available"}Congratulations, you've got it done.

When I saw the return signal, I breathed a huge sigh of relief. After a whole day of struggling, I was finally running again.

WordPress configuration method for integrating with Meilisearch

This step is simple. Go to the WP backend and install a plugin called Scry Search. It's free, so just use it.

After installation, go to settings and fill in three things.

Meilisearch address:http://127.0.0.1:7700

API key: This is the master-key you just set.

Index name: Give your website a name, such as "blog".

Then click "Start Full Indexing," wait for it to finish, and the foreground search will automatically take over. No theme code or configuration changes are needed; it's ready to use right out of the box.

I tested it out; searching for "HestiaCP" returned an exact match, and searching for "Meilisearch installation" yielded the same result. The Chinese word segmentation is incredibly accurate, with millisecond-level response times.

This feels so good.

Multiple WordPress sites sharing Meilisearch on the same server

It's worth mentioning that many people may have more than one WordPress website on the same server.

There's absolutely no need to reinstall Meilisearch. The service you already have installed can be used by all websites on the same server.

The principle is simple: since the service is bound to 127.0.0.1, it communicates locally and is even faster.

All you need to do is fill in the same address and key in the plugin configuration for each website, but the index name will be different.

For example, the first website index is named "blog", and the second is named "UFOThe third one is called "shop". Each website has its own index, which does not interfere with each other, but they share the same search service.

It's that simple.

Meilisearch Production Environment Safety Optimization

There are a few points to note.

First, don't use a simple master key. It should be at least 16 characters long, with a mix of letters and numbers, and it shouldn't be the same as someone else's.

Secondly, the service only listens on 127.0.0.1, making it inaccessible from the external network. This is crucial, and many people overlook it. You might think you've hidden it well, but exposing the port is a risk.

Third, for production environments, it is recommended to provide a read-only search key.WP pluginUse it yourself, but keep the master key to avoid leakage.

If these points are all addressed, there should be no major security issues.

Solutions to common errors encountered when installing Meilisearch using HestiaCP

Let's summarize some of the most common questions.

Permission denied

The problem is that the binary file permissions are incorrect, or the path is wrong. The solution is as I mentioned above: delete it and reinstall it to the /usr/bin directory using chmod +x.

502 Bad Gateway

The Meilisearch service may not be running or may not be listening on the local port. You can check the local port using curl to find out. If the service is working but you're still getting a 502 error, it might be a problem with the HestiaCP Nginx configuration; try rebuilding the site configuration.

WordPress cannot connect to the service

Check three things: Is the address 127.0.0.1 being used? Is the key correct? Is the service status running?

Basically, there are only a few pitfalls; once you understand them, it's quite simple.

Finally, let me say something else.

To be honest, I've always felt that the search function is undervalued.

Many people spend a lot of money building websites and creating content, but the search experience is terrible. Users come in to search for something, can't find what they want, and leave immediately. No matter how good your content is, if the search function is bad, it's all for nothing.

Deploying a tool like Meilisearch isn't actually difficult, but many people are deterred by the permission and configuration issues. I spent a whole day working on this to completely lower that barrier, so that others can easily get started.

Just imagine: a high-performance search engine that's open-source, free, has excellent Chinese language support, and is secure. This was something we never even dared to dream of before.

The open-source ecosystem is getting stronger and stronger. Many services that used to require a lot of money to buy can now be built by ourselves. It feels really great.

If you're also using HestiaCP + WordPress and struggling with search issues, try this solution. It only takes ten minutes, really.

Since you've read this far, if you found it helpful, please like and share it. If you want to receive updates first, you can also follow me!

Thank you for reading my article. See you next time.

Comment

Your email address will not be published. Required fields * Callout

Scroll to Top