Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

编译php7.4.19[0]

Posted on 2023年11月14日 by

centos8 4vcpu+2GRAM

  • 基础编译条件
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel  freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc gcc-c++ libsqlite3x-devel  autoconf apr* automake numactl bison bzip2-devel cpp curl-devel fontconfig-devel gettext-devel kernel-headers keyutils-libs-devel krb5-devel libcom_err-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff* make openssl-devel patch pcre-devel perl  telnet zlib-devel libtirpc-devel gtk* ntpstat na* bison* lrzsz cmake ncurses-devel libxslt-devel gdbm-devel readline-devel gmp-devel nano unzip nano wget tar
  • 前提

1)编译oniguruma

cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/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

2)编译pcre(yum install pcre2-devel pcre2替代)

cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/pcre2-10.36.tar.gz
tar xvf pcre2-10.36.tar.gz
cd pcre2-10.36
./configure --prefix=/usr/local/pcre2 --enable-pcre2-16 --enable-pcre2-32 --enable-jit --enable-jit-sealloc
make
make install
export PKG_CONFIG_PATH=/usr/local/pcre2/lib/pkgconfig/

3)编译libgd-2.3

cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/libgd-2.3.1.tar.gz
tar xvfz libgd-2.3.1.tar.gz
cd libgd-2.3.1
./configure --prefix=/usr/local/libgd
make
make install

4)安装libpng(yum install libpng libpng-devel 也可不编译)

yum list | grep libpng #检查和删除已有的libpng
cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/libpng-1.6.37.zip
unzip  libpng-1.6.37.zip
tar -xvf libpng-1.6.37.tar.xz
cd libpng-1.6.37
./configure --prefix=/usr/local/lib/libpng
make
make install

5)安装zlib(yum install zlib zlib-devel也可不编译)

cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make 
make install

6)安装libzip

cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/libzip-1.7.3.tar.gz
tar -zxvf libzip-1.7.3.tar.gz
cd libzip-1.7.3
mkdir build
cd build
cmake ..
make
make install
export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"

7)安装freetype(可不装)

wget https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
tar -zxvf freetype-2.9.tar.gz
cd freetype-2.9
./configure --prefix=/usr/local/freetype
make 
make install

8)安装jpegsrc(可不装)

wget  http://www.ijg.org/files/jpegsrc.v9d.tar.gz
tar -zxvf jpegsrc.v9d.tar.gz
cd jpeg-9d
./configure --prefix=/usr/local/libjpeg --enable-shared
make 
make install
  • 安装php7.4.19
cd /lnmp
wget https://www.fanlog.org/wp-content/uploads/2021/06/php-7.4.19.tar.gz
tar xvf php-7.4.19.tar.gz 
cd php-7.4.19

./configure \
--prefix=/usr/local/php \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysqli \
--with-pdo_mysql \
--with-pdo_sqlite \
--enable-mysqlnd \
--with-zlib \
--with-zlib-dir  \
--with-curl \
--enable-gd \
--with-jpeg \
--with-freetype \
--with-openssl \
--enable-bcmatch \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-exif \
--enable-opcache \
--with-external-pcre \
--with-pear \
--with-zip


make
make install

cd /lnmp/php-7.4.19
cp php.ini-development /usr/local/php/lib/php.ini 
cd /usr/local/php/etc/
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf 
cd /lnmp/php-7.4.19
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
nano /usr/local/php/lib/php.ini
添加如下内容:
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,phpinfo, mail

与安装的版本不同,需要如下修改:

通过which php 找到当前运行的php 为/usr/bin/php
rm /usr/bin/php
rm /usr/bin/php-cgi
rm /usr/bin/phpize

ln -s  /usr/local/php/bin/php   /usr/bin/php
ln -s  /usr/local/php/bin/php-cgi   /usr/bin/php-cgi
ln -s /usr/local/php/bin/phpize   /usr/bin/phpize

rm /usr/lib/systemd/system/php-fpm.service
nano /usr/lib/systemd/system/php-fpm.service
修改如下:
[Unit]
Description=php-fpm
After=network.target

[Service]
Type=forking
ExecStart=/etc/init.d/php-fpm start
ExecReload=/etc/init.d/php-fpm reload
ExecStop=/etc/init.d/php-fpm stop
#PrivateTmp=true

[Install]
WantedBy=multi-user.target
systemctl enable php-fpm
systemctl status php-fpm
systemctl stop php-fpm
systemctl start php-fpm
  • 安装pear
cd /lnmp
curl -O https://pear.php.net/go-pear.phar
/usr/local/php/bin/php  /lnmp/go-pear.phar

直接回车

 

参考资料:

  1. https://www.php.net/manual/zh/install.unix.nginx.php
  2. https://www.cnblogs.com/lyc94620/p/13201379.html
  3. https://commandnotfound.cn/php/2/17/PHP-7.3.8-Linux-%E4%B8%8B%E7%9A%84%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85
  4. https://www.ziruchu.com/art/61
  5. https://www.codeleading.com/article/63874669784/
  6. https://amon.org/php74
  7. https://www.aplus.pub/archives/478
  8. https://help.dreamhost.com/hc/en-us/articles/214392988-How-do-I-install-PEAR-

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT