目录
安装编译环境
下载源码
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
./autogen.sh && ./configure --prefix=/usr
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
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/
configure: error: Cannot find ldap libraries in /usr/lib.
方法
cp -frp /usr/lib64/libldap* /usr/lib
CentOS 7/8 安装 oniguruma和oniguruma-devel 。解决 configure: error: Package requirements (oniguruma) were not met: Package 'oniguruma', required by 'virtual:world', not found 问题。
CentOS 7 安装
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
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
备用下载:
yum -y http://down.24kplus.com/linux/oniguruma/oniguruma-6.7.0-1.el7.x86_64.rpm
yum -y http://down.24kplus.com/linux/oniguruma/oniguruma-devel-6.7.0-1.el7.x86_64.rpm
CentOS 8 安装
yum config-manager --set-enabled PowerTools
yum -y install oniguruma oniguruma-devel
[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