CentOS安装Samba和mac、win10连接

安装samba
yum -y install samba

关防火墙:
systemctl stop firewalld.service

关SELinux
setenforce 0
查看Selinux
getenforce
返回的结果分为三种:Enforcing,Permissive和Disabled。其中,Enforcing-代表记录警告且阻止可疑行为;Permissive-代表仅记录安全警告但不阻止可疑行为;Disabled表示被禁用。

如果不关的话,会导致能登录,但无法访问的情况。

修改smb.conf,增加下面的节点

[share]
        path = /data/share/office
        comment = xxxxx
        public = yes
        writable = yes
        browseable = yes
        guest ok = no
        valid users = office,ben
        available = yes

增加用户office
useradd office
useradd ben
这里不用为他们指定密码

设置samba的密码
smbpasswd -a office
smbpasswd -a ben
必须要先加用户,不然会出现:Failed to add entry for user xxxxx. 的错误

设置目录的权限:
chown office:office /data/share/office

同一时间,只能以一个用户连接上smb服务器,如果需要切换用户,需要先断开,在windows下,可以用net use断开:
net use \\1.1.1.1\xxx /del

 

Redisearch使用笔记

通过docker安装:
docker run -p 6380:6379 redislabs/redisearch:latest

127.0.0.1:6379> FT.CREATE myIdx ON HASH PREFIX 1 doc: SCHEMA title TEXT WEIGHT 5.0 body TEXT url TEXT

127.0.0.1:6379>hset doc:1 title “hello world” body “lorem ipsum” url “http://redis.io”
127.0.0.1:6379>hset doc:2 title “hello coupon codes” body “lorem ipsum” url “http://redis.io”
127.0.0.1:6379>hset doc:3 title “hello promotions” body “lorem ipsum” url “http://redis.io”

默认情况下他会处理单复数的问题

命令文档:https://oss.redislabs.com/redisearch/Commands/

搜索词的语法:https://oss.redislabs.com/redisearch/Query_Syntax/

默认情况下多个以空格分隔的词是and判断,如果要是or的关系用|生成

Mac下连接L2TP后无法访问外网和ROUTE操作记录

Mac下查看路由规则:
netstat -r

Mac下查看dns:
scutil –dns

Route管理:
route -n add -net 221.5.203.0 -netmask 255.255.255.0 10.1.0.1
route -n delete -net 221.5.203.0 -netmask 255.255.255.0 10.1.0.1

无法访问外网的问题找了一下,是因为telnet dns 服务器53端口的时候响应特别的慢。

所以把vpn的dns设置成了家里的网关地址就行了。

PHP替换Emoji表情

在检测文本语言的时候,emoji表情会影响检测的准确性,从stackoverflow上找了一个函数,作一下记录:

function removeEmoji($text) {
    return trim(preg_replace('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{1F000}-\x{1FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F9FF}][\x{1F000}-\x{1FEFF}]?/u', '', $text));
}

 

CentOS安装多PHP环境

yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xmll
systemctl enable php73-php-fpm
systemctl start php73-php-fpm

安装的配置文件路径:
/etc/opt/remi/php73/

安装路径:
/opt/remi/php83/root/usr/

启动fpm服务
systemctl restart php80-php-fpm

设置为自动运行
chkconfig php80-php-fpm on

CentOS升级curl
rpm -ivh http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/city-fan.org-release-2-1.rhel7.noarch.rpm

yum update curl –enablerepo=city-fan.org -y

 

PHP里用SoapClient出现”Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL”处理

在一台很老的服务器上,调用bing的接口时,出现如下错误,以前都是好好的:

PHP Fatal error:  Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl' : failed to load external entity "https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl"

后面发现Curl也不行,报:Peer certificate cannot be authenticated with known CA certificates 错误。

wget也不行,也报:ERROR: cannot verify certificate。

现在看来是由于系统的根证书无效了(系统太老应该是很多年前的机器了),所以无法判断microsoft的证书的有效性,按如下操作就可以了:

cd /etc/pki/tls/certs
wget https://curl.haxx.se/ca/cacert.pem
cat cacert.pem >> ca-bundle.crt

思路是去下载一个新的可信证书串(上面是curl的,也可以找一个其它的),把这个串放到系统的可信证书后面去。

如果是在php程序里用curl的话,不用设置操作系统的,可以试试把 https://curl.haxx.se/ca/cacert.pem 下载下来后,再设置php.ini的curl设置

[curl]
curl.cainfo=/path/to/downloaded/cacert.pem

 

通过smtp向google gmail发送邮件报错问题处理

在Laravel里用smtp方式通过gmail发送邮件出现下面的错误:

Failed to authenticate on SMTP server with username "[email protected]" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials a25sm9780898pfo.27 - gsmtp
". Authenticator PLAIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials a25sm9780898pfo.27 - gsmtp
". Authenticator XOAUTH2 returned Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/?p=BadCredentials a25sm9780898pfo.27 - gsmtp
".

需要按下面的步骤去解决:

1、开启2步验证方式,通过这里:https://www.google.com/landing/2step/

2、为GMAIL设置一个单独的密码,通过这里:https://security.google.com/settings/security/apppasswords

3、把第二步里的密码设置到Laravel的.env文件里。

对于.env邮件的设置也要注意加密方式,下面的我的配置:

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=独立密码
MAIL_ENCRYPTION=tls
[email protected]
MAIL_FROM_NAME="${APP_NAME}"

 

Laravel操作Redis笔记

Laravel操作Redis好麻烦的,也不封闭完。。。

操作Sortd Set

// 判断是否存在
if (Redis::command("exists", [self::REDIS_KEY_MERCHANT_TITLE])) {
    return;
}
// 增加
Redis::zadd(self::REDIS_KEY_MERCHANT_TITLE, 1, "sdfsdf");
// 加分
Redis::command('zIncrBy', [self::REDIS_KEY_MERCHANT_TITLE, 1, "sdfsdf"]);
// 弹出最小的
Redis::command('zPopMin', [self::REDIS_KEY_PROMOTION_DESC, 1]);
// 弹出最大的
Redis::command('zPopMax', [self::REDIS_KEY_PROMOTION_DESC, 1]);

 

Git记录

删除本地分支
git branch -D test –没合并也删除
git branch -d test — 没合并删除不了

删除远程分支
git push origin :feature/ttkh

查看本地分支:git branch
查看远程分支:git branch -r
查看所有分支:git branch -a

切换远程分支:git checkout -b myRelease origin/Release

git remote add origin https://github.com/wu347771769/learngit.git

把某历史版本打出分支
git checkout -b xxx/xxx 5f4648474fb38c75b69dce0db9c4d4ec1b1e6b74

合并到master分支:
git checkout master
git merge issue1234

把本地分支推送到远程分支
新建远程分支前端 CSS.md
git push origin hotfix/liyan-190905:hotfix/liyan-190905

远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
git push -u origin/remote_branch

远程已有remote_branch分支并且已经关联本地分支local_branch且本地已经切换到local_branch
git push

处理更新不下来,分支冲突的情况
[www@xxx]$ git pull
error: ‘refs/remotes/origin/hotfix’ exists; cannot create ‘refs/remotes/origin/hotfix/business-button’
From gitlab.xxxx.com:Project/backend/gocashback-api
! [new branch] hotfix/business-button -> origin/hotfix/business-button (unable to update local ref)
error: some local refs could not be updated; try running
‘git remote prune origin’ to remove any old, conflicting branches
[www@xxxt]$ git remote prune origin
Pruning origin

指定本地分支和远程某个分支的关系
git branch –set-upstream-to=origin/branch_remote branch_local
查看本地的分支是和哪个远程分支关联的
git branch -vv

提交错误后,回滚
https://blog.csdn.net/BigData_Mining/article/details/88179370

使用阿里云的Redis时,Laravel把Job发布到Queue失效的问题

又是一个坑人的大坑。

之前遇到的问题是在设置密码的时候,不是用户名和密码,需要把用户名和密码用冒号串起来写进去进行认证。

我们用的是阿里去的ecs和redis,用的是laravel框架,里面有用到Job,以队列的方式在执行:

ProductUpdateJob::dispatch($product);

结果任务死活发布不到Redis的List里,对应的Job也没有运行。

后面一步步的跟到Laravel的框架里: vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php

public function command($method, array $parameters = [])
{
    var_dump($method, $parameters);
    $start = microtime(true);

    $result = $this->client->{$method}(...$parameters);

    $time = round((microtime(true) - $start) * 1000, 2);

    if (isset($this->events)) {
        $this->event(new CommandExecuted($method, $parameters, $time, $this));
    }

    return $result;
}

输出:

string(4) "eval"
array(3) {
  [0]=>
  string(153) "-- Push the job onto the queue...
redis.call('rpush', KEYS[1], ARGV[1])
-- Push a notification onto the "notify" queue...
redis.call('rpush', KEYS[2], 1)"
  [1]=>
  array(3) {
    [0]=>
    string(14) "queues:default"
    [1]=>
    string(21) "queues:default:notify"
    [2]=>
    string(579) "{"uuid":"5b31adf4-4646-4435-a13e-9940450261da","displayName":"App\\Jobs\\TestJob","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":null,"maxExceptions":null,"backoff":null,"timeout":null,"retryUntil":null,"data":{"commandName":"App\\Jobs\\TestJob","command":"O:16:\"App\\Jobs\\TestJob\":10:{s:3:\"job\";N;s:10:\"connection\";N;s:5:\"queue\";N;s:15:\"chainConnection\";N;s:10:\"chainQueue\";N;s:19:\"chainCatchCallbacks\";N;s:5:\"delay\";N;s:11:\"afterCommit\";N;s:10:\"middleware\";a:0:{}s:7:\"chained\";a:0:{}}"},"id":"H97AvylnadgDi2Vp8eA0ieXiNxrgY8Ok","attempts":0}"
  }
  [2]=>
  int(2)
}

发现里面用的是eval命令执行的rpush。

最后在redis里用命令执行eval,结果发现没有这个权限运行:

eval "redis.call('rpush', KEYS[1], ARGV[1])\nredis.call('rpush', KEYS[2], 1)" "queues:default" "queues:default:notify" 
返回:
"ERR command eval not support for your account"

最后联系阿里的客服,建议我们升级Redis的版本后,问题就好了。