Error: Cannot find module 'less'
[WARNING] 找不到编译器:wepy-compiler-sass。
解决办法
npm install less --save-dev
npm install wepy-compiler-less --save-dev
npm install
npm rebuild node-sass
作者归档:杨龙
laravel实现跨域的中间件
# 创建中间件
php artisan make:middleware EnableCrossRequestMiddleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class EnableCrossRequestMiddleware
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$origin = $request->header('Origin');
if ($origin) {
$exps = [
'/.*\.xxx\.com$/', # 匹配下自己的域名
'/.*localhost.*/',
'/.*127.0.0.1.*/',
'/.*10.*/',
];
foreach ($exps as $exp) {
$matchCount = preg_match($exp, $origin, $matches);
if ($matchCount && isset($matches[0])) {
if ($request->isMethod('OPTIONS')) {
$response = response('');
$response->withHeaders([
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => $origin,
'Access-Control-Allow-Methods' => 'GET, POST',
'Access-Control-Allow-Headers' => 'Content-Type, Token',
'Access-Control-Max-Age' => 3600 * 24,
]);
return $response;
}
$response = $next($request);
$response->withHeaders([
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => $origin,
]);
return $response;
}
}
}
return $next($request);
}
}
另外需要关闭csrf保护否则会413
composer设置代理、CMD、powershell设置代理
cmd: set http_proxy=127.0.0.1:1080 powershell: $env:http_proxy="127.0.0.1:1080" $env:https_proxy="127.0.0.1:1080"
http_proxy 用于http链接
https_proxy 用于https链接
docker初探小记
# 启动个nginx
docker run --detach --publish 80:80 --name webserver nginx
# 停止nginx
docker container stop webserver
# 删除容器
docker container rm webserver
–detach等于-d 后后台运行的意思
可参考链接:
http://www.runoob.com/docker/docker-command-manual.html
CentOS 7安装docker:
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
docker vmware 冲突和 切换
切换到VMware workstation
bcdedit /set hypervisorlaunchtype off
# 需要重启
切换到docker
bcdedit /set hypervisorlaunchtype auto
# 需要重启
Broken pipe or closed connection
MySQL 8.0快速配置远程连接
— 创建用户并设置密码(默认密码有复杂度要求,这里使用新的验证方式 caching_sha2_password )
CREATE USER 'root'@'%' IDENTIFIED WITH caching_sha2_password BY 'Aa#111111111';
— 授予root权限
GRANT ALL ON *.* TO 'root'@'%';
UPDATE `mysql`.`user` SET `Grant_priv` = 'y' WHERE (`Host` = '%') and (`User` = 'root');
然后重启下MySQL就好了
如果root@%已经存在了则需要修改密码:
alter user 'root'@'%' identified by '123456';
其他配置:
不强制要求特殊字符:set global validate_password.special_char_count=0;
Redis主从配置
Redis主从配置非常简单
# 第一步配置访问主库的密码
masterauth <master-password>
# 第二步redis-cli里直接开启同步
slaveof 192.168.78.129 8000 # 参数是主库IP和端口
slaveof no one # 关闭同步办法
两步开启redis缓存淘汰算法
https://blog.csdn.net/wy757510722/article/details/77684083
- maxmemory 256mb # 配置内存限额
- maxmemory-policy volatile-lru # 配置淘汰策略
.php.bin文件
opcache.file_cache string
配置二级缓存目录并启用二级缓存。 启用二级缓存可以在 SHM 内存满了、服务器重启或者重置 SHM 的时候提高性能。 默认值为空字符串 “”,表示禁用基于文件的缓存。