编译安装php7.3

下载源码

cd ~ && wget http://cn2.php.net/distributions/php-7.3.0.tar.bz2

安装依赖

yum install -y bzip2 libxml2-devel libicu-devel gcc-c++

解压配置安装

tar -jxvf php-7.3.0.tar.bz2
cd php-7.3.0
./configure --prefix=/usr/local/php@7.3 --with-config-file-path=/etc/php@7.3 --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --enable-intl --enable-mbstring --enable-pcntl --enable-sockets --enable-zip --enable-mysqlnd

# 我的web用户是apache,因此fpm用户指给了apache

提示:

error: Please reinstall the libzip distribution

尝试yum安装,但是yum版本过低,转为编译安装。

安装libzip

cd ~ && wget https://libzip.org/download/libzip-1.5.1.tar.xz
xz -d libzip-1.5.1.tar.xz
tar -xvf libzip-1.5.1.tar
cd libzip-1.5.1
mkdir build
cd build && cmake ..

提示cmake版本过低

安装cmake

cd ~ && yum remove cmake -y
wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz
tar xvf cmake-3.6.2.tar.gz && cd cmake-3.6.2/
./bootstrap
gmake && gmake install
ln -s /usr/local/bin/cmake /usr/bin/
cmake --version

继续编译libzip

cd ~/libzip-1.5.1/build
cmake .. && make && make install

继续编译php

cd ~/php-7.3.0
./configure --prefix=/usr/local/php@7.3 --with-config-file-path=/etc/php@7.3 --enable-fpm --with-fpm-user=apache --with-fpm-group=apache --enable-intl --enable-mbstring --enable-pcntl --enable-sockets --enable-zip --enable-mysqlnd

提示:

error: off_t undefined; check your library configuration

根据https://segmentfault.com/q/1010000007346459

# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf

# 更新配置

ldconfig -v

继续

./configure --prefix=/usr/local/php@7.3 --with-config-file-path=/etc/php@7.3 --enable-fpm --with-fpm-user=_www --with-fpm-group=_www --enable-intl --enable-mbstring --enable-pcntl --enable-sockets --enable-zip --enable-mysqlnd

成功了,make it!

make && make install

测试时,在另外一个1G服务器上提示内存不足,创建swap分区临时解决:

mkdir /var/swap
dd if=/dev/zero of=/var/swap/swap_1G bs=2048 count=524288
chmod 0600 /var/swap/swap_1G
mkswap /var/swap/swap_1G
swapon /var/swap/swap_1G
echo "/var/swap/swap_1G swap swap default 0 0" >> /etc/fstab

# 检查
free --si -h

# 继续make
make && make install

后续操作

/usr/local/php@7.3/bin/php --version
/usr/local/php@7.3/bin/php --ini

# 此目录没有自动创建,创建它
mkdir /etc/php@7.3/php.ini

cp php.ini-production /etc/php@7.3/php.ini

#修改时区
sed -i 's/^;date.timezone =$/date.timezone = Asia\/Shanghai/g' /etc/php@7.3/php.ini

# 配置fpm
cp /usr/local/php@7.3/etc/php-fpm.conf.default /etc/php@7.3/php-fpm.conf
cp -r /usr/local/php@7.3/etc/php-fpm.d/ /etc/php@7.3
mv /etc/php@7.3/php-fpm.d/www.conf.default /etc/php@7.3/php-fpm.d/www.conf

sed -i 's#^include.*#include=/etc/php@7.3/php-fpm.d/*.conf#g' /etc/php@7.3/php-fpm.conf
#或手动修改/etc/php@7.3/php-fpm.conf最后的include行为:include = /etc/php@7.3/php-fpm.d/*.conf

mkdir -p /var/php@7.3/run
sudo chown -R apache /var/php@7.3

mkdir /var/php@7.3/run -p
sed -i 's#^pid =.*#pid = /var/php@7.3/run/php-fpm.pid#g' /etc/php@7.3/php-fpm.conf
#或手动修改/etc/php@7.3/php-fpm.conf中pid文件设置:pid = /var/php@7.3/run/php-fpm.pid

# 启动fpm(如果你的9000端口被占用了可能还需要修改端口)
/usr/local/php@7.3/sbin/php-fpm -y /etc/php@7.3/php-fpm.conf

# 重启fpm
kill -USR2 `cat /var/php@7.3/run/php-fpm.pid`

# 停止fpm
kill -INT `cat /var/php@7.3/run/php-fpm.pid`

Mac上清理Docker.qcow2文件的脚本

Docker.qcow2越来越大了,平时docker用的不多,来自谷歌搜索,如下:

#!/bin/bash
# Copyright 2017 Théo Chamley
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
# to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

echo "This will remove all your current containers and images except for:"
echo ${IMAGES}
read -p "Are you sure? [yes/NO] " -n 1 -r
echo # (optional) move to a new line

if [[ ! $REPLY =~ ^[Yy]$ ]]
  then
  exit 1
fi

TMP_DIR=$(mktemp -d)
pushd $TMP_DIR >/dev/null
open -a Docker
echo "=> Saving the specified images"
for image in ${IMAGES}; do
  echo "==> Saving ${image}"
  tar=$(echo -n ${image} | base64)
  docker save -o ${tar}.tar ${image}
  echo "==> Done."
done

echo "=> Cleaning up"
echo -n "==> Quiting Docker"

osascript -e 'quit app "Docker"'

while docker info >/dev/null 2>&1; do
  echo -n "."
  sleep 1
done;

echo ""
echo "==> Removing Docker.qcow2 file"

rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
echo "==> Launching Docker"
open -a Docker
echo -n "==> Waiting for Docker to start"
  until docker info >/dev/null 2>&1; do
  echo -n "."
  sleep 1
done;
echo ""
echo "=> Done."
echo "=> Loading saved images"
for image in ${IMAGES}; do
  echo "==> Loading ${image}"
  tar=$(echo -n ${image} | base64)
  docker load -q -i ${tar}.tar || exit 1
  echo "==> Done."
done
popd >/dev/null
rm -r ${TMP_DIR}

laravel执行phpunit报错:Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable

laravel执行phpunit报错:

Illuminate\Contracts\Container\BindingResolutionException: Target 
[Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable

出现这个错误可能是本地的phpunit版本和项目的phpunit版本不一致导致的,因此方法有二:

  • 使用项目的phpunit,即将phpunit改成vendor/bin/phpunit
  • 升级项目的phpunit,或者降级本机phpunit

charles连接手机的问题

手机无法连接到电脑

可以用ping命令ping一下手机的IP试试连通性。

  • 关闭电脑和手机上的代理软件;
  • 关闭开启wifi几次之后,试试;
  • 关闭开启电脑的网络试试。

有连接记录但是显示unknow

  • 手机访问 chls.pro/ssl 安装证书;
  • 设置 -> 关于本机 -> 证书信任设置 开启刚才安装的证书;

chrome无法代理

  • 关闭switchomega插件

使用pecl安装php扩展

mac最近brew安装PHP扩展似乎不是很好使,于是想到使用pecl来安装了

pecl很大概率需要使用代理

下面的命令是安装php5.6版本的,具体安装什么版本可能需要去pecl.net网站上自己查看。

sudo pecl channel-update pecl.php.net
pecl search xdebug
sudo pecl install xdebug-2.5.5
sudo pecl install redis-2.2.8

删除mac中launchpad上的图标

首先,mac上所有的软件都是.app结尾的,在系统中,一般有两个目录含有.app文件,一个是 /Applications目录,这个目录的程序是所有用户共享的,还有一个目录是~/Applications/,这里面的程序只能自己使用

在launchpad上,一般长按程序图标,会出现经典的图标抖动界面,此时,点击图标左上角的x,即可删除,但是有的程序左上角没有x,那就只能在上面提到的两个目录里手动删除了。

有时删除后,发现launchpad上图标还在,那么执行这个命令:

defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock

就解决了,这个命令会重置launchpad上的图标顺序,但是不会对系统照成伤害。

博客被人使用穷举法尝试登录

IP为“193.201.224.200”的这位兄弟不知道跟他有什么仇什么怨,一直在请求我的登录接口,企图进入到我的博客后台,遂暂时简单手动屏蔽一下这个IP吧,

本来打算在nginx层面屏蔽的,但是不够完美,而我的系统里的iptables也不是吃素的:

iptables -I INPUT -s 193.201.224.200 -j DROP
iptables --list

搞定,虽然我知道这篇文章发出来说有人都能看到,没关系,我这一个小小博客,啥也有没有,就几篇水文而已,博客运行也没什么风什么浪,我到是想见识见识。