最近macos 使用brew upgrade 更新了nginx ,然后postman调试接口的时候报错。发现是/usr/local/var/run/nginx/client_body_temp 目录没有权限,网上的做法是sudo chown -R nobody:nobody /usr/local/var/run/nginx/proxy_temp/,我试着做了。但是没起作用,然后改了下权限。可以了。sudo chmod -R 775 /usr/local/var/run/nginx/proxy_temp/
mysql 忘记root密码解决办法
当前版本:mysql5.7
找到my.cnf 一般在/etc/my.cnf 或 macos /usr/local/etc/my.cnf
在[mysqld] 下加入以下语句:skip-grant-tables
执行mysql -uroot -p ,如果提示输入密码,按回车。然后登入mysql
修改密码
use mysql; update user set password=PASSWORD('你的密码') where user='root'; ### 5.7执行以下语句 ### update user set authentication_string=PASSWORD('你的密码') where user='root'; flush priveleges;
再修改my.cnf 将刚添加的语句去掉。成功!!
PHP如何读取大文件
这里使用的yield 方法
function readTheFile($path) {
$handle = fopen($path, 'r');
while(!feof($handle)) {
yield trim(fgets($handle));
}
fclose($handle);
}
$iterator = readTheFile('shakespeare.txt');
foreach ($iterator as $item) {
echo $item;
}
Debian9 安装稳定版本的nginx
- 先安装依赖组件
sudo apt install curl gnupg2 ca-certificates lsb-release
2. 再仓库里生成list文件
echo "deb http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
3. 增加key
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
4. 校验key
sudo apt-key fingerprint ABF5BD827BD9BF62
如果看到以下命令,表明成功
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62
uid [ unknown] nginx signing key <signing-key@nginx.com>
5. 安装nginx
sudo apt update
sudo apt install nginx
关于Mariadb启动报错Job for mariadb.service failed because the control process exited
MariaDB重启后,执行 systemctl start mariadb
启动报错
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
根据官方提示执行 systemctl status mariadb.service
或者 journalctl -xe
并不能看出真正原因,此时可以查看mariadb的日志文件,查看错误原因。
cd /var/log/mariadb/
tail -n 100 mariadb.log
发现 Fatal error: cannot allocate memory for the buffer pool。
内存不够了
vim /etc/my.cnf将 innodb_buffer_pool_size = 专用的DB服务器,改为内存的50%,非专用改为内存的15-20%。
重启即可
‘comp-lzo’ is deprecated in OpenVPN 2.4

修改你的*.ovpn文件,将comp-lzo 替换为 compress lzo 即可。
php数组排序
目前遇到二位数组的排序,会用到array_multisort函数。
比如:
$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);
// 对volume降序,edition升序
$volumeList = [];
$editionList = [];
foreach ($data as $item) {
$volumeList[] = $item['volume'];
$editionList[] = $item['edition'];
}
array_multisort($volumeList, SORT_DESC, $editionList, SORT_ASC, $data);
print_r($data);
// out
Array
(
[0] => Array
(
[volume] => 98
[edition] => 2
)
[1] => Array
(
[volume] => 86
[edition] => 1
)
[2] => Array
(
[volume] => 86
[edition] => 6
)
[3] => Array
(
[volume] => 85
[edition] => 6
)
[4] => Array
(
[volume] => 67
[edition] => 2
)
[5] => Array
(
[volume] => 67
[edition] => 7
)
)