Write the Code. Change the World.

3月 19

本来 php7.3 使用的蛮好的。突然有一个旧项目,框架所使用的 php 版本是 php5.6。这个时候就尴尬了。不可能一一去修改源码。这个时候,就得再安装一个 php5.6。还好 nginx 配合多版本 php 使用非常的方便。

PHP 下载地址: http://php.net/releases/

下载编译安装

# 还是一样,习惯将文件下载的 `/usr/local/src` 下

cd /usr/local/src

wget http://cn2.php.net/get/php-5.6.40.tar.gz

tar -xzvf php-5.6.40.tar.gz

cd php-5.6.40

# 下边就开始配置

配置如下:

# 因为之前有一个 /alidata/service/php 目录,这里使用 php5.6 加以区分
./configure --prefix=/alidata/service/php5.6 \
--with-config-file-path=/alidata/service/php5.6/etc \
--enable-inline-optimization --disable-debug \
--disable-rpath --enable-shared --enable-opcache \
--enable-fpm --with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--enable-session \
--enable-ftp \
--enable-xml \
--with-curl --with-zlib \
--enable-zip \
--with-bz2 \
--enable-pdo \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-readline

注意要使用的库一定要带上。比如 gd 库。要不额外弄,伤脑筋。
继续阅读

3月 08

centos 使用 yum 安装的时候,很多程序不是最新的。这个时候,就得下载源码包进行安装。 libzip 就是这样的。下边进行操作。

# 先卸载旧的
yum -y remove libzip-devel

# 找到最新版本的,并下载
# https://libzip.org/ 官网

wget https://libzip.org/download/libzip-1.5.1.tar.gz

tar -zxvf libzip-1.5.1.tar.gz

cd libzip-1.5.1

mkdir build

cd build

cmake ..

make && make install

如果安装过程中,出现 cmake 版本过低 ,请参考:
centos 安装最新版本的 camke

当然,安装旧版本的 libzip可能不这样。请参考下边的链接:
https://www.cnblogs.com/itbsl/p/10208926.html

3月 08

找到最新版本的 cmake

https://cmake.org

进 cmake 官网,找到最新版本的下载地址。当前最新版本是 3.14.0

下载安装

在做安装之前,可以先卸载之前旧版本

yum -y remove cmake

按照以下操作:

wget https://cmake.org/files/v3.6/cmake-3.14.0.tar.gz

tar -xzvf cmake-3.14.0.tar.gz

cd cmake-3.14.0 

./bootstrap

gmake

gmake install

2023年1月30日,另外编辑。cmake 后边的版本不需要 ./bootstrap 和 install。直接将解压的文件夹复制过去就可以。下边以分割线来描述这一整个过程。


CMake 官方下载页面:https://cmake.org/download/ 选择对应的版本,最好是最新的稳定下载。

cd /usr/local/src/

wget https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.tar.gz

tar -xzvf cmake-3.25.2-linux-x86_64.tar.gz

mv cmake-3.25.2-linux-x86_64 /usr/local/cmake

然后将 cmake的可执行文件目录添加到系统环境变量中。

# 添加
echo 'export PATH="/usr/local/cmake/bin:$PATH"' >> ~/.bashrc

# 生效
source ~/.bashrc

这样就完成了。如果后边想升级。还是这样来一遍就可以。

https://osfere.com/linux/how-to-install-latest-cmake-on-centos#comment-68

如果在 bootstrap 的时候,出现下边这样的错误:

Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)

而你 openssl 明明已经装了,并且也有软链,为什么还是不行呢。上边也提到了报错的行数,找到函数位置是 find_package(OPENSSL),还是没找到这玩意。于是尝试将package以及lib添加到环境变量中试试看,并使环境变量生效看看,竟然好了。

vim /etc/profile

# 添加

export OPENSSL_ROOT_DIR=/usr/local/openssl


export OPENSSL_LIBRARIES=/usr/local/openssl/lib/


# 生效

source /etc/profile

然后继续后边的操作了

参考:https://hant-kb.kutu66.com/openssl/post_12667981

查看编译后的cmake版本

/usr/local/bin/cmake --version

新建软连接

ln -s /usr/local/bin/cmake /usr/bin/

终端查看版本

cmake --version