Jiliuke

激流客

Nginx https 证书自己生成(debian系系统为例)

1.切换到/etc/nginx 目录下执行

1
sudo openssl req -new -x509 -nodes -out server.crt -keyout server.key

2.配置站点nginx(/etc/nginx/sites-enabled/test)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
upstream php5.6-fpm {
server unix:/var/run/php/php5.6-fpm.sock;
}
server {
listen 443 ssl;
listen [::]:443 ssl;

server_name www.test.local;

ssl on;

ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.key;

ssl_session_cache shared:SSL:1m;


root /home/dyl/website/test;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}
index index.php index.html;

location ~ \.php$ {
# 设置php-fpm
fastcgi_pass php5.6-fpm;
# 设置nginx的默认首页文件(上面已经设置过了,可以删除)
fastcgi_index index.php;
# 设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}


# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}

3.重启nginx服务

1
sudo systemctl restart nginx

如果 docker ps -a 中太多,一次性删除方法

1
docker rm `docker ps -a -q --filter 'status=exited'`

debian apparmor linux内核安全模块影响docker运行,本地操作系统可以直接移除此包

1
sudo apt-get purge apparmor

百万级文件删除使用rm删除会十分缓慢,大量删除操作需要用到rsync同步命令。
例如需要删除文件夹/home/dyl/test/

  1. 首先新建一个空文件夹 /tmp/test/
  2. 然后使用以下命令删除
    1
    rsync --delete-before -a -H -v /tmp/test/ /home/dyl/test/
    如果不想看到日志,参数换成-d.
    1
    rsync --delete-before -d /tmp/test/ /home/dyl/test/

需求

我们有很多仓库账号,每个仓库的登录用户又不同,这个时候就需要使用多个ssh keys配置不同的仓库,否则将会出现权限问题

步骤

1.首先生成ssh key,参见生成ssk key.
2.配置config(~/.ssh/config)

1
2
3
4
5
6
7
8
9
Host            git.us.magento.cloud
Hostname git.us.magento.cloud
IdentityFile ~/.ssh/id_rsa_mage_cloud
IdentitiesOnly yes
Host michaeldyl520.github.com
Hostname ssh.github.com
IdentityFile ~/.ssh/id_rsa_michaeldyl520
IdentitiesOnly yes
User git

如果都是使用github,建议别名项目仓库Host避免冲突,例如git@michaeldyl520.github.com:xxxx/xxxx.git

需求

有时候我们需要在同一台服务器配置多个php版本利于开发测试,我们可以直接使用他人做好的包直接安装配置,以deepin示例。

步骤

  1. 首先加入多版本php源

    1
    2
    3
    4
    sudo apt-get -y install apt-transport-https lsb-release ca-certificates
    sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
    sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
    sudo apt-get update

    https://packages.sury.org/php/README.txt

  2. 安装apache和多版本php-fpm

    1
    sudo apt-get install apache2 php5.6-fpm php7.0-fpm php7.1-fpm
  3. 打开apache headersproxy_fcgi模块

    1
    sudo a2enmod headers proxy_fcgi

    apachephp-fpm建议运行用户配置成当前登录账号,避免出现权限问题

  4. 配置虚拟域名

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <VirtualHost *:80>
    ServerName m1.mycoolcell.local
    ServerAlias m1.mycoolcell.local
    ServerAdmin webmaster@localhost
    DocumentRoot /home/dyl/website/mycoolcell_m1
    SetEnv MAGE_RUN_CODE wholesale
    SetEnv MAGE_RUN_TYPE website
    <FilesMatch "\.php$">
    <If "-f %{REQUEST_FILENAME}">
    SetHandler "proxy:unix:/run/php/php5.6-fpm.sock|fcgi://localhost/"
    </If>
    </FilesMatch>
    ErrorLog ${APACHE_LOG_DIR}/m1.mycoolcell.local.error.log
    CustomLog ${APACHE_LOG_DIR}/m1.mycoolcell.local.access.log combined
    </VirtualHost>

    如果需要其他版本,将上面的php5.6-fpm.sock配置成php7.1-fpm.sock即可。

Tips

1
2
3
4
5
6
7
8
#show elasticsearch database
curl localhost:9200/_cat/indices?v
#delete elasticsearch database
curl -XDELETE localhost:9200/xxxxxxx?pretty
#set limit variable
curl -XPUT localhost:9200/_template/template_name -d '{"template": "*", "order": 0, "settings": {"index": {"mapping": {"total_fields": {"limit": 10000}}}}, "version": 1}'
#show use percent of elasticsearch
curl http://localhost:9200/_nodes/stats?pretty&human -s |grep heap_used

本地开发减少docker elasticsearch的内存占用

1
2
3
4
5
6
docker cp elasticsearch7177:/usr/share/elasticsearch/config/jvm.options ~/
cd ~
sed -i 's/-Xms6g/-Xms2g/g' ~/jvm.options
sed -i 's/-Xmx6g/-Xmx2g/g' ~/jvm.options
docker cp ~/jvm.options elasticsearch7177:/usr/share/elasticsearch/config
rm ~/jvm.options

问题

当我们本地有很多私钥的时候,直接使用ssh xxx@xx.xx.xx.xx方式登录的时候会出现 Too many authentication failures for xxx Authentication failed.的错误,所以当我们存在大量的私钥时,为了方便,可以使用免密登录(不在此文讨论范围),还可以必须使用账号密码登录。

解决办法

配置ssh配置文件,如debian配置文件在/etc/ssh/ssh_config中,加入PubkeyAuthentication no到文件中即可。

  1. 访问开发文档搜索并点击Create a test-only Payflow Gateway account,继续点击Payflow Services开始创建账号,根据需要的类型选择支付处理公司,除了邮件其他随意填继续下一步到结束。完成后会有成功注册信息发送到邮箱。

  2. 根据邮件登录信息登录登录paypal payflow后台,

  • 点击
    Service Setting->Set Up->Payment Confirmation中,修改Show confirmation pagew为On my website,修改Return URL MethodPost。转到Security Options,修改Enable Secure TokenYes,保存;
  • 导航到Service Setting->Customize->Choose a layout and color,选择Layout C,然后保存发布(Save and Publish);
  • 导航到Account Administration->Manage Security->Transaction Settings,修改Allow reference transactionsYes,保存(Confirm);
  1. magento2后台配置paypal payflow后即可使用测试信用卡测试。

问题

magento-cloud新项目添加magento-cloud ssh-key:add后仍然无法pull代码,

处理

解决方法如下:

1.需要配置~/.ssh/config文件,例如:

gedit ~/.ssh/config,

拷贝以下到~/.ssh/config

1
2
3
4
Host git.us-3.magento.cloud
Hostname git.us-3.magento.cloud
User tajmoznp6wqkq
IdentityFile /home/dyl/.ssh/id_rsa.2

2.获取公钥写入到~/.ssh/known_hosts中,终端执行以下命令:

1
ssh-keyscan -H git.us-3.magento.cloud >> ~/.ssh/known_hosts

简介

很多情况下我们需要修改后台eav属性对应的模板文件。以下是通过修改模板文件让客户无法在后台修改multiple select,也就是disable multiple select。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!--
Silk/AdvancedEstimatedShippingDate/etc/adminhtml/di.xml
-->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="esd" xsi:type="array">
<item name="class" xsi:type="string">Silk\AdvancedEstimatedShippingDate\Ui\DataProvider\Product\Form\Modifier\esd</item>
<item name="sortOrder" xsi:type="number">10</item>
</item>
</argument>
</arguments>
</virtualType>
</config>

接下来修改modifyMeta

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//Silk\AdvancedEstimatedShippingDate\Ui\DataProvider\Product\Form\Modifier\esd
<?php
/**
* Created by PhpStorm.
* User: dyl
* Date: 18-4-17
* Time: 下午4:31
*/

namespace Silk\AdvancedEstimatedShippingDate\Ui\DataProvider\Product\Form\Modifier;
use Magento\Framework\Stdlib\ArrayManager;

class esd implements \Magento\Ui\DataProvider\Modifier\ModifierInterface
{
/**
* Container fieldset prefix
*/
const CONTAINER_PREFIX = 'container_';
/**
* @var ArrayManager
*/
protected $arrayManager;

/**
* esd constructor.
* @param ArrayManager $arrayManager
*/
public function __construct(ArrayManager $arrayManager)
{
$this->arrayManager = $arrayManager;
}

/**
* @param array $data
* @return array
*/
public function modifyData(array $data)
{
return $data;
}

/**
* @param array $meta
* @return array
*/
public function modifyMeta(array $meta)
{
$fieldCode = 'esd';
$elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children');
$containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children');
if (!$elementPath) {
return $meta;
}

$meta = $this->arrayManager->merge(
$containerPath,
$meta,
[
'arguments' => [
'data' => [
'config' => [
'formElement' => 'container',
'componentType' => 'container',
'breakLine' => false,
'label' => __('ESD'),
'required' => 0,
'sortOrder' => 320,
'scopeLabel' => __('[STORE VIEW]'),
],
],
],
'children' => [
$fieldCode => [
'arguments' => [
'data' => [
'config' => [
'dataType' => 'multiselect',
'formElement' => 'multiselect',
'elementTmpl' => 'Silk_AdvancedEstimatedShippingDate/ui/form/element/multiselect'
],
],
],
],
]
]
);
return $meta;
}
}

最后加上template文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!--
Silk/AdvancedEstimatedShippingDate/view/base/web/template/ui/form/element/multiselect.html
-->
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<select multiple class="admin__control-multiselect" data-bind="
attr: {
name: inputName,
id: uid,
size: size ? size : '6',
disabled: true,
'aria-describedby': noticeId,
placeholder: placeholder
},
hasFocus: focused,
optgroup: options,
selectedOptions: value,
optionsValue: 'value',
optionsText: 'label'"
/>

0%