php 安装xhprof

当前环境 ubuntu20.04 php7.4.3

用pecl install xhprof

安装完成后修改php.ini 添加扩展和设置日志输出

## 添加扩展
extension=xhprof.so
## 设置输出路径
xhprof.output_dir=/home/asd/xhprof/log

完成后重启php

在入口文件增加代码

xhprof_enable(XHPROF_FLAGS_NO_BUILTINS | XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY);

注册php在终止执行时的函数

register_shutdown_function(function(){
	$data = xhprof_disable();   //返回运行数据
	//xhprof_lib 在下载的包里存在这个目录,记得将目录包含到运行的php代码中
	include '/usr/share/php/xhprof_lib/utils/xhprof_lib.php';
	include '/usr/share/php/xhprof_lib/utils/xhprof_runs.php';
	$objXhprofRun = new \XHProfRuns_Default();
	$objXhprofRun->save_run($data, "test"); //test 表示文件后缀
});

运行。发现/home/asd/xhprof/log下有日志文件

查看关系图

将/usr/share/php/xhprof_html 设置成可以通过nginx访问,访问index.php文件可以查看图

查看图之前需要安装 sudo apt install graphviz

jquery使用

  1. 除了自己。其它同类元素都取消选中 $(‘.menu_checkbox’).not(this).prop(‘checked’, false);
  2. 获取标签后边的文字,<input type=’checkbox’ />全选 `$("input")[0].nextSibling.nodeValue;`
  3. ajax请求 post json:
$.ajax({
                url: apiPath,
                data: JSON.stringify(postData),
                type: 'POST',
                dataType: 'json',
                contentType: "application/json"
            }).done(function (response) {
                 console.log(response);
            }).fail(function (response) {
                console.log(response);
            });

docker mysql 没有 root 用户

docker mysql 没有 root 用户,需要创建 root

  1. flush privileges; 解决 ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables option so it cannot execute 这个问题
  2. CREATE USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘123’;
  3. GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION;
  4. flush privileges;

xdebug3配置

xdebug2配置

zend_extension=”xdebug.so”

xdebug.remote_enable=on

xdebug.remote_port=9001

xdebug.remote_host=127.0.0.1

在升级3.0版本后,remote_enable 被mode 取代,remote_host被 client_host 取代,remote_port改为 client_port,默认为9003端口,client_host默认为 localhost,所以3之后的配置为

zend_extension=”xdebug.so”
xdebug.mode=debug
xdebug.client_host=127.0.0.1

我本地是9003端口,所以此处省略端口配置

activemq 增加连接的用户名密码

编辑 activemq.xml 在broker标签内,加一下代码

<plugins>

            <simpleAuthenticationPlugin>

                <users>

                    <authenticationUser username="user" password="user123" groups="users" />

                </users>

            </simpleAuthenticationPlugin>

        </plugins>

重启后即可

mysql8 Public Key Retrieval is not allowed

mysql8 之后,用户的密码验证改为caching_sha2_password,MySQL5.7及之前为mysql_native_password。

方法一:

登录MySQL后输入:

ALTER USER ‘your user name’@’your host’ IDENTIFIED WITH mysql_native_password BY ‘YourPassword’;

FLUSH PRIVILEGES;

方法二:

编辑my.cnf文件,更改默认的身份认证插件。

vi /etc/my.cnf

在[mysqld]中添加下边的代码
default_authentication_plugin=mysql_native_password

然后重启MySQL

centos7 安装java8

  1. 下载jdk , tar格式或rpm格式
  2. 安装 rpm -Uvh jdk_your_version_.rpm   # 安装java
  3. 配置环境变量, vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/java/jdk1.8.0_271-amd64/
   export JRE_HOME=/usr/java/jdk1.8.0_271-amd64/jre
   export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

docker 国内镜像

docker pull image 非常慢,需要加国内镜像

vim /etc/docker/daemon.json
## 填写以下内容
 {
    "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
 }

## 重启docker
systemctl restart docker