IT Daily Documentation

String id cannot be empty in WordPress

How to know it: Open the wp-config.php file and change for this line:

define('WP_DEBUG', false);

to true

define('WP_DEBUG', true);

Problem: Same situation like this using WPML Plugin.

Solution: check database, there are some rows which id is zero. Try to delete all of them.

Then, the table must not have primary key, so set a primary key and set auto increment.

SET timeout value to prevent long-running SELECT queries for Mysql/MariaDB

Problem: Some WordPress plugin cause a lot of long-running queries and seems to want to run forever:( (You can check it out by entering SQL command “show processlist;”)

Solution: Set up session-wide or global timeout:

For MySQL, enter below command

SET SESSION MAX_EXECUTION_TIME=2000;
SET GLOBAL MAX_EXECUTION_TIME=2000;

For MariaDB, enter below command:

SET SESSION max_statement_time=2000;
SET GLOBAL max_statement_time=2000;

2000 is 2000 second.

Nextcloud in CentOS 7 guide

Suggested steps:

I suggest using Apache, because Nginx need more time to debug in some parts.

I suggest using BT panel (or AApanel for Eng ver -- https://www.aapanel.com/index.html)

Once you installed NextCloud, go to http://domain/index.php/settings/admin/overview to check any error that occurred.

  1. for error like “/.well-known/caldav” and “/.well-known/carddav” -> turn on apache rewrite function, restart apache and make sure you add AllowOverride All on Nextcloud directory on conf file.
  2. Suggest PHP 7.4. Install below php plugin: fileinfo, opcache, opcache, imagemagick, gmp. memory_limit set above 2GB. Then restart PHP
  3. for backup procedure, first you can take a reference in https://docs.nextcloud.com/server/15/admin_manual/maintenance/restore.html. Simply using command
rsync -Aax nextcloud-dirbkp/ nextcloud/

to backup folders. using command

sqlite3 data/owncloud.db .dump > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

to backup SQlite.

Run puppeter in Cent OS 7 CLI mode

Required steps:

  1. make sure you have installed below packages:
pango.x86_64
libXcomposite.x86_64
libXcursor.x86_64
libXdamage.x86_64
libXext.x86_64
libXi.x86_64
libXtst.x86_64
cups-libs.x86_64
libXScrnSaver.x86_64
libXrandr.x86_64
GConf2.x86_64
alsa-lib.x86_64
atk.x86_64
gtk3.x86_64
ipa-gothic-fonts
xorg-x11-fonts-100dpi
xorg-x11-fonts-75dpi
xorg-x11-utils
xorg-x11-fonts-cyrillic
xorg-x11-fonts-Type1
xorg-x11-fonts-misc

use yum install to install above dependencies should be fine. And be careful your are 64 bit or 32 bit.

2. Install VNC server:

yum install tigervnc-server

and make sure you set your password through

vncpasswd

and know what to start/stop/kill vnc

systemctl start [email protected]:1.service
systemctl stop [email protected]:1.service

vncserver -kill :1

and your port should be 5901 (if you use 1.service)

3. use gnome-terminal:

export DISPLAY=:0
gnome-terminal --display=:0

4. in your js file, make sure your browser has below arguments:

const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});

Then your js file:

node index.js

6. If you need to use cronjob, you can try like this:

export DISPLAY=:0; node index.js

Solve “rediect too many times” in WordPress during migration

Problem: I’m using CentOS + Nginx + MySQL + phpMyAdmin. and all config is correct, which includes all the DB tables (domain updated), wp-config.php. but still encounter too many redirect problem.

Solution: If you sure you set up correctly, you can first delete all your tables, but not your database.

Then open https://yourdomain/wp-admin/install.php. Try to install the tables through WordPress wizard.

After you can enter the newly created default website, then go back to phpMyAdmin. Import the MySQL file again, it is ok to overwrite the original. Finally the problem solved.

Can not login due to “Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.” in WordPress multisite

Problem: try to log in a subdomain WordPress multisite website and receive below error message:

ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.

Solution: install Setup WordPress Multisite Domain Mapping

and in case you are using Cloudflare, try to add a page rule in Page Rules page:

*.domain.com/wp-*

Disable Security : Security is disabled
Browser Integrity Check : Off

ref: https://wordpress.stackexchange.com/a/331995, https://enterpr1se.info/2014/07/how-to-speed-up-wordpress/7/

Unable to push repo using bitbucket in CentOS 7

Problem: try to use git to push my repo in CentOS 7. But pop up below error message:

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Solution: Go to Bitbucket panel, go to the SSH keys page in Personal Setting (not repo setting) and add the public key content.

Then upload the private key to your CentOS 7 server and enter below command:

eval `ssh-agent`
ssh-add <private_key_file>

remember the key file permission (600), and if you don’t want to run above command every time you log in. you can run ssh-agent on the background.

eval $(ssh-agent -s)

then enter below command --

ssh -T [email protected]

above command is to verify your configuration and Bitbucket username. If you see below message then you can start to push your repo.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

You can push your code using

git push