Tag Archives: wordpress

Fixing wp_termmeta doesn’t exist error

One day, I open my mailbox and see bunch of error mail written something like this:

Upon diving in Google ocean, I found this solution that may solve the problem:

Use this SQL query to add manually the wp_termmeta table in your WordPress database if there is the wp_termmeta table doesn’t exist in your DB.

Credit: http://zanca.it/tutorials/wp_termmeta-doesnt-exist-error-solved/

WordPress permalinks with Nginx

If you are on Apache(mod_rewrite), WordPress will automatically add the required rewrite rules to your .htaccess file for permalinks to work. Just add code generated by WordPress in .htaccess, and its done. But for nginx, you have to add the rules manually in the nginx conf file.

But the problem is when WordPress detects that mod_rewrite is not loaded (which is this case, nginx), it falls back to using PATHINFO permalinks, which inserts an extra ‘index.php’ in front. This will cause the problem for me as I want to remove the index.php from the permalinks.

Permalink Setting

So you need to edit your nginx configuration file to make the permalinks work. We will use the try_files directive to pass URLs to WordPress’s index.php for them to be internally handled.

If your blog is at the root of the domain (something like www.blog.com), find the location / block inside the configuration file, and add the following line to it.
[shell]try_files $uri $uri/ /index.php?q=$uri&$args;[/shell]

Here, Nginx checks for the existence of a file at the URL ($uri), then for a directory ($uri/). If it doesn’t find a directory or a file, it performs an internal redirect to /index.php passing the URL as PATHINFO.

It should look like this after the edits :
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;

If your blog is in a subfolder (lets say /blog), you’ll have to add an extra location /blog/ block to your configuration file :
location /blog/ {
try_files $uri $uri/ /blog/index.php?q=$uri&$args;

After you have finished making the changes in the configuration file, reload the nginx configuration:
[shell]nginx -s reload[/shell]

The permalinks should be working fine now.

Install DenyHosts on Ubuntu 12.04

DenyHosts is a security tool written in python that monitors server access logs to prevent brute force attacks on a virtual private server. The program works by banning IP addresses that exceed a certain number of failed login attempts.

1. Install DenyHosts via apt
[shell]sudo apt-get install denyhosts[/shell]

2. Whitelist you IP Addresses
After you install DenyHosts, make sure to whitelist your own IP address. Skipping this step will put you at risk of locking yourself out of your own machine.

To insert you IP, open this file:
[shell]sudo nano /etc/hosts.allow[/shell]

under the description, add in any IP addresses e.g. your IP so that you will not kicked out from the server. You can write each one on a separate line, using this format:

After making any changes, be sure to restart DenyHosts so that the new settings take effect on your virtual private server:
[shell]sudo /etc/init.d/denyhosts restart[/shell]

3. Configure DenyHosts (Optional)
If you want to customize the behavior of DenyHosts on your VPS, you can make the changes within the DenyHost configuration file:
[shell]sudo nano /etc/denyhosts.conf[/shell]

Nginx – 413 Request Entity Too Large

Haa.. Seperti tajuk diatas, bagi sape2 yang pernah configure & run server Nginx ni, korang pernah kena macam ni tak?
Benda ni jadi masa aku nak uploadkan theme kat wordpress.. Nak install theme la..
Saiz theme tu dalam 1.2MB.. Sekali keluar error macam tu..
So, dicari2 solutionnya.. Jumpa jugak..

Mari kita tengok macam mana solution dia..
First, kita kena edit file configuration nginx ni.. Kita taip ni:

Masukkan password korang, dan nanti keluarlah configuration dia kat terminal tu..
Lepas tu kita kena masukkan line ni..

Function dia untuk menetapkan jumlah memori untuk server tu..
Letakkan line tadi tu kat sini..

http {
include /etc/nginx/mime.types;

access_log /var/log/nginx/access.log;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 2;
tcp_nodelay on;

gzip on;
gzip_disable “MSIE [1-6].(?!.*SV1)”;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

client_max_body_size 4M;
client_body_buffer_size 128k;

Haa.. Nampak tak? Lepas tu korang tekan CTRL-O untuk write-out dan save..
Nak exit tekan CTRL-Z.. Lepas tu korang try restart nginx korang.. taip kan:

Kalau tak ada masalah apa2, dia akan restart dengan elok.. Lepas tu try korang upload theme tu balik..
Insyallah mesti boleh.. Sebab aku da buat & da jadi pun! 😀
Apa2 pertanyaan bolehlah tanya aku.. Insyallah aku cuba tolong korang..