参考:
https://www.sunanzhi.com/archives/27/
安装
1、到官网获取下载地址 https://www.php.net/downloads
2、下载并解压
cd /home/install/php74
wget https://www.php.net/distributions/php-7.4.25.tar.gz
tar -zxvf php-7.4.25.tar.gz
3、进入解压目录编译配置
cd php-7.4.25
sudo ./configure --prefix=/usr/local/php74 \
--with-config-file-path=/etc --enable-fpm --enable-inline-optimization \
--disable-debug --enable-mysqlnd --enable-static --disable-rpath --enable-shared --enable-soap --with-xmlrpc \
--with-openssl --with-mhash --with-zlib \
--enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl \
--with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pear \
--enable-opcache --enable-ftp --with-gdbm --with-openssl-dir --with-jpeg --with-zlib-dir \
--with-freetype --enable-gd --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --with-sqlite3\
--enable-mbstring --enable-mbregex --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
--with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg \
--enable-sysvsem --enable-sysvshm --with-xsl --with-zip --enable-mysqlnd-compression-support --enable-intl \
--with-config-file-path=/usr/local/php74/etc \
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ (这句如果 libzip 没有报错不用复制)
注意 --with-config-file-path 指定 php.ini
编译时可能会出现一些错误 configure error
1. configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
处理:yum install sqlite-devel -y
2. configure: error: Please reinstall the BZip2 distribution
处理:yum install bzip2 bzip2-devel -y
3. configure: error: Package requirements (libcurl >= 7.15.5) were not met:No package 'libcurl' found
处理:yum install libcurl libcurl-devel -y
4. configure: error: GNU MP Library version 4.2 or greater required.
处理:yum install gmp-devel -y
5. configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:
No package 'icu-uc' found
No package 'icu-io' found
No package 'icu-i18n' found
处理:yum install libicu-devel -y
6. configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found
处理:yum install oniguruma-devel -y
7. configure: error: Please reinstall readline - I cannot find readline.h
处理:yum install readline-devel -y
8. configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:No package 'libzip' found
处理:yum remove libzip libzip-devel
cd /home/install/libzip1.2
wget https://hqidi.com/big/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
#####完成后#####
make[2]: Nothing to be done for `install-exec-am'.
/usr/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 libzip.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/home/install/libzip1.2/libzip-1.2.0'
make[1]: Leaving directory `/home/install/libzip1.2/libzip-1.2.0'
#####完成后#####
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
echo $PKG_CONFIG_PATH
#####显示#####
/usr/local/lib/pkgconfig
#####显示#####
4、安装
make && make install
配置
1、切换到 源代码目录
cd /home/install/php74/php-7.4.25
2、拷贝 php.ini文件
cp php.ini-production /usr/local/php74/etc/php.ini
3、服务管理
# 通过 service 管理
cd /home/install/php74/php-7.4.25/sapi/fpm
cp init.d.php-fpm /etc/init.d/php74-fpm
chmod 755 /etc/init.d/php74-fpm
# 配置完成之后
service php74-fpm start
# 自动开机启动
vi /etc/rc.d/rc.local
# 添加 下面一行并保存
/etc/init.d/php74-fpm start
# 然后执行加载配置
ldconfig
########################### 分割
# 通过 systemd 管理
cd /home/install/php74/php-7.4.25/sapi/fpm
cp php-fpm.service /lib/systemd/system/php74-fpm.service
vi /usr/lib/systemd/system/php74-fpm.service
# ProtectSystem=full 改成下面这个配置并保存
ProtectSystem=false
# 重载一下命令
systemctl daemon-reload
# 加入开机启动
systemctl enable php74-fpm.service
# 启动服务
systemctl start php74-fpm.service
4、配置php-fpm
cd /usr/local/php74/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php74/etc/php-fpm.d
cp www.conf.default www.conf
# 如果需要修改 监听端口
vi /usr/local/php74/etc/php-fpm.d/www.conf
# listen = 1270.0.0.1:9000 改成 你想要监听的端口
5、修改php.ini
时区
vi /usr/local/php74/etc/php.ini
# 修改并保存
date.timezone = "Asia/Shanghai"
安装其他拓展
redis 拓展
1、去官方拓展获取redis
拓展地址 https://pecl.php.net/get/redis-5.3.4.tgz
2、下载解压
cd /home/install/php-redis
wget https://pecl.php.net/get/redis-5.3.4.tgz
tar zxvf redis-5.3.4.tgz
3、指定版本安装
cd /home/install/php-redis/redis-5.3.4
/usr/local/php74/bin/phpize
./configure --with-php-config=/usr/local/php74/bin/php-config
make && make install
4、修改php.ini
文件
vi /usr/local/php74/etc/php.ini
# 末尾添加 redis.so 并保存
[redis]
extension=redis.so
5、重启 php
systemctl restart php74-fpm.service
标签:enable,--,php74,fpm,源码,install,php,安装 From: https://www.cnblogs.com/tkzc2013/p/16742880.html