liujia 发布的文章

magento - inventory_stock_1 doest exist - 导入数据库时需注意用户权限

现象:在原网站,以mysql的root用户,通过mysqldump导出magento2的数据库文件。将导出的数据库文件导入到cPanel空间的数据库。访问cPanel空间的站点,提示出错:

2 exception(s):
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S02]: Base table or view not found: 1146 Table 'aqtest.inventory_stock_1' doesn't exist, query was: SELECT COUNT(DISTINCT e.entity_id) FROM `catalog_product_entity` AS

尝试:编辑导出的magento2数据库文件,将原

DEFINER=`root`@`localhost`

替换为现数据库用户,如

DEFINER=`aqtest`@`localhost`

,最后重新导入。

参考:https://magento.stackexchange.com/questions/259534/inventory-stock-1-doest-exist-on-magento-2-3

cpanel - 用不同的版本的php命令 - /opt/cpanel/ea-php72/root/usr/bin/php - An exception was raised while creating "Request"

现象:在cPanel环境中执行magento2的命令,如 php bin/magento cache:flush提示出错:

An exception was raised while creating "Request"; no instance returned

尝试:用正确的php版本路径再次执行,如 /opt/cpanel/ea-php72/root/usr/bin/php bin/magento cache:flush

参考:

Shell交互输入日期和时间,查询web日志统计条数

##!/bin/sh

dates=$1
month=$(date | awk '{print $2}')
years=$(date | awk '{print $6}')
hours=$2
minutes=$3
seconds=$4


if [ "$seconds" = "" ] && [ "$minutes" = "" ] && [ "$hours" = "" ]; then
        grep "$dates/$month/$years" access.log | grep 'MOBILENO_QUERY'| wc -l;
elif [ "$seconds" = "" ] && [ "$minutes" = "" ]; then
        grep "$dates/$month/$years:$hours" access.log | grep 'MOBILENO_QUERY'| wc -l;
elif [ "$seconds" = "" ]; then
        grep "$dates/$month/$years:$hours:$minutes" access.log | grep 'MOBILENO_QUERY'| wc -l;
else
        grep "$dates/$month/$years:$hours:$minutes:$seconds" access.log | grep 'MOBILENO_QUERY'| wc -l;
fi 

shell-date-weblog.png

参考:

自动延活ssh会话 - ssh -o "ServerAliveInterval 60" - Connection reset by port 22

问题:有些服务器,设置了一段时间后(如3分钟后)ssh会话无活动时会自动断开,出现 Connection reset by anqun.org port 22 的提示信息,不方便长时间使用。

尝试:如在Windows的MobaXterm客户端中,可运行如 ssh -o "ServerAliveInterval 60" root@anqun.org 的命令,自动每60秒发送数据,延续ssh会话。

参考:https://superuser.com/questions/699676/how-to-prevent-ssh-from-disconnecting-if-its-been-idle-for-a-while

magento - Invalid Form Key. Please refresh the page 错误 - 增大 max_input_vars 值

问题:新安装的magento2.3,在网站后台添加多个产品属性的新商品时,出错,提示 Invalid Form Key. Please refresh the page。环境是apache2.4和php。

尝试:

1.查看web错误日志,有如:

PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0

2.更改php.ini中的 max_input_vars 的值到两万(默认是1000),如 max_input_vars = 20000

3.重启web服务

参考:https://www.simicart.com/blog/magento-2-invalid-form-key/