标签 linux 下的文章

1、下载源码包

wget https://www.php.net/distributions/php-7.4.20.tar.gz

2、安装必要工具软件依赖

sudo apt install -y build-essential gcc libcurl3-dev pkg-config libxml2-dev libssl-dev sqlite3 libsqlite3-dev libbz2-dev libgmp3-dev libonig-dev libedit-dev libreadline-dev libxslt1-dev autoconf postgresql

3、解压,配置

tar xvf php-7.4.20.tar.gz
cd php-7.4.20/
./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74/ini_path --with-config-file-scan-dir=/usr/local/php74/config_path   --enable-mysqlnd   --with-pdo-mysql   --with-pdo-mysql=mysqlnd   --enable-bcmath   --enable-fpm   --with-fpm-user=www-data   --with-fpm-group=www-data   --enable-mbstring   --enable-phpdbg   --enable-shmop   --enable-sockets   --enable-sysvmsg   --enable-sysvsem   --enable-sysvshm   --with-zlib   --with-curl   --with-pear   --with-openssl   --enable-pcntl   --with-readline

make -j8 && make install

4、运行

/usr/local/php74/bin/php -v

PHP 7.4.20 (cli) (built: Jun 21 2021 16:10:21) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

hexdump 查看二进制文件

echo "https://const.net.cn" > bin.data
hesy@hesy-ThinkPad-P15v-Gen-1:~/2021/linux$ hexdump -C bin.data 
00000000  68 74 74 70 73 3a 2f 2f  63 6f 6e 73 74 2e 6e 65  |https://const.ne|
00000010  74 2e 63 6e 0a                                    |t.cn.|
00000015

hexdump 自定义格式显示二进制文件

hexdump -e '4/1 "%02X " "\n"' bin.data 
68 74 74 70
73 3A 2F 2F
63 6F 6E 73
74 2E 6E 65
74 2E 63 6E
0A         
hexdump -e '8/1 "%02X " "\n"' bin.data 
68 74 74 70 73 3A 2F 2F
63 6F 6E 73 74 2E 6E 65
74 2E 63 6E 0A         
hexdump -e '16/1 "%02X " "\n"' bin.data 
68 74 74 70 73 3A 2F 2F 63 6F 6E 73 74 2E 6E 65
74 2E 63 6E 0A                                 
hexdump -e '16/1 "%_p " "\n"' bin.data 
h t t p s : / / c o n s t . n e
t . c n .           
hexdump -e '16/1 "%03d " "\n"' bin.data 
104 116 116 112 115 058 047 047 099 111 110 115 116 046 110 101
116 046 099 110 010 

hexdump 将二进制文件转为十六进制文件

hexdump -e '16/1 "%02X " "\n"' bin.data > hex.data
xxd -r -p hex.data bin.data.1
md5sum *
84d86c7c482190d90838c5de11d99d06  bin.data
84d86c7c482190d90838c5de11d99d06  bin.data.1
a100e4d2a6bcf2faceb56f106dfb1c6b  hex.data

xxd 查看二进制文件

xxd -c 4 -p bin.data 
68747470
733a2f2f
636f6e73
742e6e65
742e636e
0a
xxd -c 8 -p bin.data 
68747470733a2f2f
636f6e73742e6e65
742e636e0a
xxd -c 16 -p bin.data 
68747470733a2f2f636f6e73742e6e65
742e636e0a

xxd 将十六进制文件转为二进制文件

xxd -r -p input.txt output.bin    
xxd -c 16 -p bin.data > hex.data
xxd -r -p hex.data bin.data.1
md5sum *
84d86c7c482190d90838c5de11d99d06  bin.data
84d86c7c482190d90838c5de11d99d06  bin.data.1
2d8c913c2685ef14e39fa97a28c3ad79  hex.data