centos 7 8 源码安装php

目录

centos 8 7.4.12

7.0.33 源码安装

centos7_6 源码安装php7.4.12

centos7 php-fpm.service


 

centos 8 7.4.12

安装编译环境

  1. dnf groupinstall 'development tools'
  2. yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel libicu-devel freetype-devel openldap-devel openldap openldap-devel sqlite-devel
  3. cp -frp /usr/lib64/libldap* /usr/lib/

下载源码

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

新建相关目录,将php7.4.12安装到/usr/local/php/php7412目录下。(为了安装其它php 版本。在目录下新建相关版本目录下。)

[root@mysql-proxy php]# pwd
/usr/local/php
[root@mysql-proxy php]# ls
php-7.4.12  php7412  php-7.4.12.tar.gz

wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4

  1. ./autogen.sh && ./configure --prefix=/usr

  2. make && make install

.configure参数

./configure --prefix=/usr/local/php/php7412 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib  --with-libxml-dir  --enable-xml  --disable-rpath  --enable-bcmath  --enable-shmop  --enable-sysvsem  --enable-inline-optimization  --with-curl  --enable-mbregex --enable-mbstring  --enable-intl  --with-mcrypt  --with-libmbfl  --enable-ftp  --with-gd  --enable-gd-jis-conv  --enable-gd-native-ttf  --with-openssl  --with-mhash  --enable-pcntl  --enable-sockets  --with-xmlrpc  --enable-zip  --enable-soap  --with-gettext  --disable-fileinfo  --enable-opcache  --with-pear  --enable-maintainer-zts  --with-ldap=shared  --without-gdbm
make && make install

映射全局命令

ln -s /usr/local/php/php7412/sbin/* /usr/local/sbin/

ln -s /usr/local/php//php7412/bin/* /usr/local/bin/

 查看 php.ini文件存放的位置

php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/php/php7412/lib

cp /usr/local/php/php-7.4.12/php.ini-development /usr/local/php/php7412/lib/php.ini

cp /usr/local/php/php7412/etc/php-fpm.conf.default /usr/local/php/php7412/etc/php-fpm.conf

cp /usr/local/php/php7412/etc/php-fpm.d/www.conf.default /usr/local/php/php7412/etc/php-fpm.d/www.conf

新建php-fpm.services 文件

[root@mysql-proxy php]# more /etc/systemd/system/php-fpm.service 
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
 
[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php/php741/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/php7412/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
 
[Install]
WantedBy=multi-user.target

检查php-fpm运行情况

 netstat -tln |grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN  

7.0.33 源码安装

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

yum install -y epel-release
yum install -y libmcrypt-devel

./configure --prefix=/usr/local/php/php7033 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib  --with-libxml-dir  --enable-xml  --disable-rpath  --enable-bcmath  --enable-shmop  --enable-sysvsem  --enable-inline-optimization  --with-curl  --enable-mbregex --enable-mbstring  --enable-intl  --with-mcrypt  --with-libmbfl  --enable-ftp  --with-gd  --enable-gd-jis-conv  --enable-gd-native-ttf  --with-openssl  --with-mhash  --enable-pcntl  --enable-sockets  --with-xmlrpc  --enable-zip  --enable-soap  --with-gettext  --disable-fileinfo  --enable-opcache  --with-pear  --enable-maintainer-zts  --with-ldap=shared  --without-gdbm

ln -s /usr/local/php/php7033/sbin/* /usr/local/sbin/
 ln -s /usr/local/php//php7033/bin/* /usr/local/bin/

centos7_6 源码安装php7.4.12

configure: error: Cannot find ldap libraries in /usr/lib.

方法

cp -frp /usr/lib64/libldap* /usr/lib

  1. CentOS 7/8 安装 oniguruma和oniguruma-devel 。解决 configure: error: Package requirements (oniguruma) were not met: Package 'oniguruma', required by 'virtual:world', not found 问题。

  2. CentOS 7 安装

  3. yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-6.7.0-1.el7.x86_64.rpm

  4. yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-devel-6.7.0-1.el7.x86_64.rpm

  5. 备用下载:

  6. yum -y http://down.24kplus.com/linux/oniguruma/oniguruma-6.7.0-1.el7.x86_64.rpm

  7. yum -y http://down.24kplus.com/linux/oniguruma/oniguruma-devel-6.7.0-1.el7.x86_64.rpm

  8. CentOS 8 安装

  9. yum config-manager --set-enabled PowerTools

  10. yum -y install oniguruma oniguruma-devel

centos7 php-fpm.service

[root@localhost ~]# cat /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFILE=/usr/local/php/var/run/php-fpm.pid
ExecStart=/usr/local/php/php7033/sbin/php-fpm  --nodaemonize --fpm-config /usr/local/php/php7033/etc/php-fpm.conf
ExecRestart=/bin/kill -USR2 $PIDFILE
ExecStop=/bin/kill -SIGINT $PIDFILE

[Install]
WantedBy=multi-user.target

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值