Tag Archives: wordpress

Fixing wp_termmeta doesn’t exist error

One day, I open my email via mail command and see bunch of error mail received by me, written something like this:

PHP message: WordPress database error Table 'blog.wp_termmeta' doesn't exist for query SELECT term_id, meta_key, meta_value FROM wp_termmeta WHERE term_id IN (108) ORDER BY meta_id ASC made by require('wp-blog-header.php'), wp, WP->main, do_action_ref_array, call_user_func_array, Jetpack_RelatedPosts->action_frontend_init, Jetpack_RelatedPosts->_action_frontend_init_ajax, Jetpack_RelatedPosts->get_for_post_id, Jetpack_RelatedPosts->_get_related_posts, Jetpack_RelatedPosts->_get_related_post_data_for_post, Jetpack_RelatedPosts->_generate_related_post_context, get_the_category, get_the_terms, wp_get_object_terms, update_termmeta_cache, update_meta_cache

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

CREATE TABLE `wp_termmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `term_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `term_id` (`term_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=InnoDB AUTO_INCREMENT=3255 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

Use this SQL query to manually add the wp_termmeta table into your WordPress database; if 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.

try_files $uri $uri/ /index.php?q=$uri&$args;

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:

nginx -s reload

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

sudo apt-get install denyhosts

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:

sudo nano /etc/hosts.allow

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:

sshd: 12.34.45.678
sshd: 89.76.54.321

After making any changes, be sure to restart DenyHosts so that the new settings take effect on your virtual private server:

sudo /etc/init.d/denyhosts restart

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:

sudo nano /etc/denyhosts.conf

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