分类 电脑 下的文章

安装 magento 2.4.6-p1

当前,magento 官方商城使用的程序版本是 magento 2.4.6-p1 。尝试安装一下,记录遇到的问题。

问题一:debian 12系统里,默认安装的mariadb版本是10.11.3,但 magento 要求是10.6。数据库的版本过高,magento安装程序不认。

出错信息:Current version of RDBMS is not supported. Used Version: 10.11.3-MariaDB-1. Supported versions: MySQL-8, MySQL-5.7, MariaDB-(10.2-10.6)

或:

Warning: preg_match(): Compilation failed: range out of order in character class at offset 25 in magento/vendor/magento/framework/DB/Adapter/SqlVersionProvider.php on line 101

尝试:

对于第一个报错,按照网上的例子,修改 magento/app/etc/di.xml 文件内容,如:
<item name="MariaDB-(10.2-10.11)" xsi:type="string">^10\.[2-11]\.</item> 直接修改版本号。

第二个报错,修改 magento/vendor/magento/framework/DB/Adapter/SqlVersionProvider.php 文件内容,如:

        $pattern = sprintf('/(%s)/', implode('|', $this->supportedVersionPatterns));
        $pattern = '/10.11/';
        $sqlVersionOutput = '10.11.3-MariaDB-1';
        preg_match($pattern, $sqlVersionOutput, $match);

问题二:magento 安装程序,连接不上刚刚安装的 opensearch ,提示:Could not validate a connection to the opensearch, no alive nodes found in your cluster

尝试:在 /etc/opensearch/opensearch.yml 文件中,添加一行 plugins.security.disabled: true ,即将opensearch的https和用户访问的安全设置禁用。

问题三:使用 nginx 的反向代理 apache 上的 magento 站点后,https 访问异常,如不断地循环跳转。

magento 的站点网址设置等,和平时的差不多,如下例:

catalog/search/engine - opensearch
catalog/search/opensearch_server_hostname - localhost
catalog/search/opensearch_server_port - 9200
catalog/search/opensearch_index_prefix - magento2
catalog/search/opensearch_server_timeout - 15
catalog/category/root_id - 2
web/seo/use_rewrites - 1
web/unsecure/base_url - http://magento.anqun.org/
web/unsecure/base_static_url -
web/unsecure/base_media_url -
web/secure/base_url - https://magento.anqun.org/
web/secure/base_static_url -
web/secure/base_media_url -
web/secure/enable_hsts - 0
web/secure/enable_upgrade_insecure - 0
web/secure/use_in_frontend - 1
web/secure/use_in_adminhtml - 1
web/secure/offloader_header -
web/default_layouts/default_product_layout - product-full-width
web/default_layouts/default_category_layout - category-full-width
web/default_layouts/default_cms_layout - cms-full-width
web/cookie/cookie_path -
web/cookie/cookie_domain -
web/cookie/cookie_httponly - 1
general/locale/code - zh_Hans_CN
general/locale/timezone - Asia/Shanghai
general/region/display_all - 1
general/region/state_required - AL,AR,AU,BG,BO,BR,BY,CA,CH,CL,CN,CO,CZ,DK,EC,EE,ES,GR,GY,HR,IN,IS,IT,LT,LV,MX,PE,PL,PT,PY,RO,SE,SR,US,UY,VE
currency/options/base - CNY
currency/options/default - CNY
currency/options/allow - CNY
analytics/subscription/enabled - 1
crontab/default/jobs/analytics_subscribe/schedule/cron_expr - 0 * * * *
crontab/default/jobs/analytics_collect_data/schedule/cron_expr - 00 02 * * *

关键应该是设置 https 的环境参数,如通过 .htaccess 添加以下内容:

setenv HTTPS on
SetEnv HTTP_X_FORWARDED_PROTO "https"

如果nginx反代配置中使用了 X-Real-IP 头,那么 apache 中的访问日志,可以使用 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Real-IP}i\"" proxycombined 来记录访客IP。

nginx站点例子:

server {
        listen       443 ssl;  
        server_name  magento.anqun.org; 

        ssl_certificate          fullchain.cer;
        ssl_certificate_key      magento.anqun.org.key;

        proxy_buffer_size   128k;
        proxy_buffers   4 256k;
        proxy_busy_buffers_size   256k;

        location / {
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_pass         http://192.168.1.9:8001;
        }
}

参考:

甲骨文云 - ARM机 - 安装 Debian 12 bookworm ARM64

需求;甲骨文云中的ARM机,有提供免费的 Canonical-Ubuntu-22.04-Minimal-aarch64 系统镜像。如果想使用 Debian 12,能不能安装呢?

实践;能。用 Debian 提供的网络安装文件,能完成。如在已有的 Ubuntu 中,使用 kexec 来启动到带远程 ssh 的 Debian 安装界面。举例:
kexec --command-line="priority=critical mirror/http/hostname=ftp.us.debian.org interface=auto language=en country=US locale=en_US.UTF-8 keymap=us modules=network-console network-console/password=hellodebian network-console/password-again=hellodebian DEBIAN_FRONTEND=text" --initrd=initrd.gz linux

如果是静态IP的,或许是:

kexec --command-line="priority=critical mirror/http/hostname=ftp.cn.debian.org interface=auto netcfg/disable_autoconfig=true netcfg/get_ipaddress=192.168.1.61 netcfg/get_netmask=255.255.255.0 netcfg/get_gateway=192.168.1.1 netcfg/get_nameservers=8.8.8.8 language=en country=US locale=en_US.UTF-8 keymap=us modules=network-console network-console/password=hellodebian network-console/password-again=hellodebian8 DEBIAN_FRONTEND=text" --initrd=initrd.gz linux

另有 ISPSystem中Debian 11 和 Debian 11 netinstall 包中 metainfo.xml 的内核参数实例,可对比:

<kernelcommand>url=($OSINSTALLINFO_HTTPv4) language=en debian-installer/country=RU locale=en_US keyboard-configuration/xkb-keymap=us console-keymaps-at/keymap=us interface=auto netcfg/disable_dhcp=true netcfg/disable_autoconfig=true netcfg/use_autoconfig=false ipv6.autoconf=0 netcfg/get_ipaddress=($IPv4) netcfg/get_netmask=($NETMASKv4) netcfg/get_gateway=($GATEWAYv4) netcfg/get_nameservers=($NAMESERVERv4) hostname=($HOSTNAME) domain=($HOSTNAME) netcfg/hostname=($HOSTNAME) net.ifnames=0 netcfg/link_wait_timeout=30</kernelcommand>

<kernelcommand>url=($OSINSTALLINFO_HTTPv4) language=en debian-installer/country=RU locale=en_US keyboard-configuration/xkb-keymap=us console-keymaps-at/keymap=us interface=auto netcfg/disable_dhcp=true netcfg/get_ipaddress=($IPv4) netcfg/get_netmask=($NETMASKv4) netcfg/get_gateway=($GATEWAYv4) netcfg/get_nameservers=($NAMESERVERv4) hostname=($HOSTNAME) domain=($HOSTNAME) netcfg/hostname=($HOSTNAME) netcfg/link_wait_timeout=30</kernelcommand>

参考:

DCImanager 5 - Debian 12 - bookworm

需求:ISPSystem 当前没有为 DCImanager 5 提供 Debian 12 的系统镜像。但 Debian 的网络安装方式没有改变,使用新版本的 initrd.gz 和 linux 文件来安装 Debian 12,或许也是可以的。

首先,从 ISPSystem 下载现有的 Debian 11 系统安装包。然后,修改 metainfo.mxl 中关于系统名称的描述。再从 Debian 官方下载 Debian 12 的网络安装镜像文件 initrd.gz 和 linux,替换即可。

参考:

DCImanager 5 - Ubuntu 22.04 - user-data

问题:DCImanager 的官方系统镜像源中有 Ubuntu 22.04 ,但仅限于 DCImanager 6。如果想在 DCImanager 5 中使用,需要修改。

修改一:metainfo.xml 文件中,除了 <support> 项要修改, <kernelcommand> 也要改一下,因为可能有些参数不适合 DCImgr5。如将原有的:
<kernelcommand>ip=dhcp cloud-config-url=/dev/null url=($SHAREDIR_FILE)ubuntu.iso autoinstall ds=nocloud-net;s=($OSINSTALLINFO_HTTP)&amp;file=user-data&amp;qwe=files/cloud/</kernelcommand>
修改为:
<kernelcommand>ip=dhcp cloud-config-url=($OSINSTALLINFO_HTTP)&amp;file=user-data url=($SHAREDIR_FILE)ubuntu.iso autoinstall</kernelcommand>

关键是要让 Ubuntu cloud-init 自动安装时,能找到配置文件 user-data。记得还要在文件中加载自定义的 user-data 文件,<file>user-data</file>

修改二:前一步中是用自己修改后的 user-data 文件,因为官方中的内容中可能包含 DCImgr5 中没有的参数 $DISK_LAYOUT_FILE。即将原有的:
bash /tmp/part.sh "($HDD_RAID)" "($DISK_LAYOUT_FILE)"
修改为:
bash /tmp/part.sh "($HDD_RAID)"

参考:

iRedMail - 对指定用户设置限制 - 仅允许收信 不能发信 - iredapd

需求:因为主机商对滥发邮件管得严格,所以想对指定用户设置限制,设置为可以收到邮件,但不能发出邮件。

环境:iRedMail 1.6.2,ubuntu 20.02

尝试:

作用:将 liujia@example.com 用户加到不允许发信但可收信的列表
python3 /opt/iredapd/tools/wblist_admin.py --outbound --account liujia@example.com --add --blacklist @.

作用:列出当前的黑名单
python3 /opt/iredapd/tools/wblist_admin.py --outbound --account liujia@example.com --list --blacklist

作用:将 liujia@example.com 用户从不允许发信但可收信的列表移除
python3 /opt/iredapd/tools/wblist_admin.py --outbound --account liujia@example.com --delete --blacklist @.

参考: