猫言猫语

严以律己·宽以待人·自强不息·知行合一

解决 PHP SoapClient 产生大量 CLOSE-WAIT TCP 连接

| 解决 PHP SoapClient 产生大量 CLOSE-WAIT TCP 连接已关闭评论

服务器上使用 PHP SoapClient 作为 WebService 客户端调用第三方接口,发现存在大量 CLOSE-WAIT 状态 TCP 连接。

解决办法是设置 keep_alive 参数,使 SoapClient 不保持连接,具体 PHP 代码如下:

<?php
new SoapClient("http://webservice.test/", [
    "keep_alive" => false,
]);

Dubbo Admin 安装

| Dubbo Admin 安装已关闭评论

wget https://github.com/apache/dubbo-admin/archive/0.2.0.tar.gz
tar zxvf 0.2.0.tar.gz
cd dubbo-admin-0.2.0
./mvnw clean package
java -jar dubbo-admin-distribution/target/dubbo-admin-0.2.0.jar --server.port=8081

CentOS 7 安装 nginx

| CentOS 7 安装 nginx已关闭评论

yum install -y epel-release
yum install -y nginx

Debian 9 安装 ZooKeeper

| Debian 9 安装 ZooKeeper已关闭评论

sudo apt install zookeeperd
sudo systemctl enable zookeeper
sudo systemctl restart zookeeper
[email protected]:/var/lib/zookeeper# /usr/share/zookeeper/bin/zkCli.sh
Connecting to localhost:2181
Welcome to ZooKeeper!
JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 1]
[zk: localhost:2181(CONNECTED) 0] create /config.json {}
Created /config.json
[zk: localhost:2181(CONNECTED) 1]
[zk: localhost:2181(CONNECTED) 0] get /config.json
{}
cZxid = 0xb
ctime = Fri Apr 03 17:27:50 GMT+00:00 2020
mZxid = 0xb
mtime = Fri Apr 03 17:27:50 GMT+00:00 2020
pZxid = 0xb
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 2
numChildren = 0
[zk: localhost:2181(CONNECTED) 1]
[zk: localhost:2181(CONNECTED) 0] delete /config.json
[zk: localhost:2181(CONNECTED) 1]

解决 macOS zsh ssh 乱码

| 解决 macOS zsh ssh 乱码已关闭评论

最近使用 macOS zsh ssh 登录远程服务器时候,终端会出现如下提示内容:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

显示中文字符时会不规则的乱码,有些字符乱,有些字符不乱

解决办法是编辑 ~/.zshrc 文件,手动设置一下终端环境的语言编码:

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Laravel 的 3 种运行环境

| Laravel 的 3 种运行环境已关闭评论

Laravel 可以在通过 APP_ENV 环境变量修改运行时环境,默认的 APP_ENV 是 local,其实他还可以设置其他值,分别是:

local 对应的 development 环境
testing 对应的 test 环境
production 对应的 production 环境

使 PHPUnit 支持 Session

| 使 PHPUnit 支持 Session已关闭评论

当使用PHPUnit测试的PHP代码中包含session_start()时,就会出现以下的错误提示:

PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

E

Time: 110 ms, Memory: 12.00MB

There was 1 error:

1) ExampleTest::testBasicExample
ErrorException: session_start(): Cannot start session when headers already sent

解决办法是打开phpunit.xml文件,设置processIsolation属性为true