修复symfony下swiftmail 无法发送邮件的问题

wpcraft项目中,本来是支持在部分情况下自动发送邮件的,但是今天测试一下发现好像不好使了,并且印象中好像没有修改到swiftmail的配置,甚至一度怀疑是smtp服务器把我的IP屏蔽了的缘故,但是后来试了一下phpmail却可以正常发送邮件,对比了一下,好像swiftmail默认的配置缺少点东西,于是按如下补上,修改app/config/parameters.yml

swiftmailer:
    transport: '%mailer_transport%'
    host: '%mailer_host%'
    username: '%mailer_user%'
    password: '%mailer_password%'
    port: '587'
    encryption: 'tls'
    spool: { type: memory }

添加了portencryption两个参数,结果一切正常,至于为什么突然要加这两项配置,我也挺纳闷…

做了一个极简的让wordpress支持markdown的插件,支持代码高亮

用过一些markdown的插件,要么就是用起来麻烦,要么就是写作体验差,于是只能手动撸一个了,安装后,写作时使用那个文本编辑器,直接写markdown的语法即可。

代码以及使用方法: https://github.com/yeskn-studio/markdown-one

编译安装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插件