centos 安装php5.4和pthreads

本文提供了一份详细的PHP5.4+pthreads扩展的安装教程,包括下载、配置、安装过程及解决常见错误的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

之前通过yum安装了php5.4,现在需要安装pthreads拓展,./configure --enable-maintainer-zts不可用,只能重新安装一次php

1.下载php5.4和pthreads并解压。

# wget http://www.php.net/distributions/php-5.4.36.tar.gz

# wget http://pecl.php.net/get/pthreads-1.0.0.tgz

# tar zxvf php-5.4.36.tar.gz

# tar zxvf  pthreads-1.0.0.tgz

2. 将 解压的 pthreads-1.0.0放入php-5.4.36下的ext目录下

# mv pthreads-1.0.0 php-5.4.36/ext

3.重新配置资源

# cd php-5.4.36

# ./buildconf --force

       查看一下是否已经有pthreads

# ./configure --help | grep pthreads


     如果没有,执行下面命令重新配置

# rm -rf aclocal.m4

# rm -rf autom4te.cache/

# ./configure --help | grep pthreads

4.配置需要一起安装的拓展

# ./configure --enable-debug --enable-maintainer-zts --enable-pthreads --prefix=/usr --with-config-file-path=/etc --enable-fpm --with-mysql  --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pdo-mysql --with-gd --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng  --with-jpeg-dir=/usr/local/jpeg9 --with-vpx-dir=/usr/local/vpx --with-mcrypt=/usr/local/libmcrypt  --with-mysqli  --with-freetype-dir=/usr/local/freetype --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --enable-ctype


5.安装

# make

# make install

6.配置php-fpm配置为服务

# cp /root/php-5.4.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 

# cp /usr/etc/php-fpm.conf.default /usr/etc/php-fpm.conf

# chmod 755 /etc/init.d/php-fpm

# chkconfig –add php-fpm

最后,php-fpm以服务的方式启动、停止和重启:
# service php-fpm start
# service php-fpm stop

# service php-fpm reload


至此php+pthreads安装成功


第4步遇见的错误

1.configure: error: no acceptable C compiler found in $PATH

解决方式 

#yum install gcc-c++

2.configure: error: xml2-config not found. Please check your libxml2 installation.

解决方式

# yum install libxml2

# yum install libxml2-devel -y

3.configure: error: jpeglib.h not found.

解决方式 

# yum -y install libjpeg-devel

4. configure: error: vpx_codec.h not found.

解决方式

# yum -y install libvpx-devel

5.configure: error: png.h not found.

解决方式

# yum -y install libpng-devel

6.configure: Cannot find OpenSSL's <evp.h>

解决方式

# yum install openssl openssl-devel

7.configure:Please reinstall the libcurl distribution -

    easy.h should be in <curl-dir>/include/curl/

解决方式

# yum -y install curl-devel

8.configure:freetype.h not found.

解决方式

# yum install freetype-devel

9.configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决方式:

# yum install libmcrypt libmcrypt-devel 


参考文章:

http://php.net/manual/en/pthreads.installation.php

https://blog.youkuaiyun.com/zyz511919766/article/details/14002497/

https://blog.youkuaiyun.com/dabao1989/article/details/22898857

https://www.cnblogs.com/beyang/p/6972412.html

<think>好的,用户想在CentOS 7上安装PHP 5.4,我需要先确认这个需求的可行性。首先,PHP 5.4是一个比较旧的版本,官方支持早已结束,可能存在安全风险。但用户可能有遗留项目需要维护,所以必须安装这个版本。 接下来,我需要考虑CentOS 7的默认仓库是否包含PHP 5.4CentOS 7默认的仓库可能提供的是较新的PHP版本,比如5.4可能已经不在官方源中了。这时候可能需要添加第三方仓库,比如Remi仓库或者Webtatic。 然后,安装步骤方面,可能需要先启用EPEL仓库,因为Remi等仓库依赖EPEL。接着添加Remi仓库,然后通过yum安装指定版本的PHP。需要确保用户知道如何启用特定仓库,并安装正确的包。 另外,安装完成后,需要检查PHP是否成功安装,版本是否正确。还要提醒用户注意安全,因为旧版本没有安全更新,建议仅在测试环境使用,或者考虑升级到更高版本。 可能遇到的问题包括依赖关系冲突、仓库配置错误等。需要给出解决这些问题的建议,比如如何查找可用的包,如何清理缓存等。还要提醒用户安装必要的扩展,比如mysql、gd等,可能需要手动指定。 最后,总结步骤,确保用户能一步步按照指导操作,并强调安全风险,提供替代方案,比如使用Docker容器运行旧版PHP,以避免影响主系统。</think>以下是在CentOS 7系统上安装PHP 5.4的详细步骤(注意:PHP 5.4已于2014年停止官方支持,建议仅用于测试环境): --- ### **安装步骤** 1. **添加EPEL仓库** ```bash sudo yum install epel-release ``` 2. **安装Remi仓库** ```bash sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm ``` 3. **启用PHP 5.4仓库** ```bash sudo yum-config-manager --enable remi-php54 ``` 4. **安装PHP 5.4核心** ```bash sudo yum install php ``` 5. **验证安装版本** ```bash php -v # 应显示类似:PHP 5.4.x (cli)... ``` --- ### **扩展安装** ```bash # 安装常用扩展(按需选择) sudo yum install php-mysql php-gd php-mbstring php-xml ``` --- ### **配置调整** 1. **主配置文件路径** ```bash /etc/php.ini ``` 2. **重启Web服务** ```bash # 根据使用的Web服务器选择 sudo systemctl restart httpd # Apache sudo systemctl restart nginx # Nginx ``` --- ### **风险提示** 1. **安全漏洞**:PHP 5.4已停止安全更新,存在被攻击风险 2. **兼容性问题**:可能与新版MySQL/MariaDB不兼容 3. **替代方案建议**: - 使用Docker运行旧版环境 - 升级到PHP 7.4+(通过`remi-php74`仓库) --- ### **故障排查** - 如果找不到包:`sudo yum clean all && sudo yum makecache` - 依赖冲突:尝试`sudo yum install --skip-broken` 建议生产环境优先考虑PHP 7.4+版本,可通过`remi-php74`仓库安装
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值