站点刚更新,有问题请联系QQ 2535458415

CentOS7.3 安装php7.4.12

编程 王苗森 3219℃ 0评论

CentOS7.3 安装php7.4.12

  • 值得注意的是,在php7.4中,很多./configure指令发生了变化,坑太多了,我把过程记录了下来,以后方便查找。
  1. 安装yum 依赖
yum -y install libxml2 libxml2-devel curl-devel bzip2-devel.x86_64 libXpm-devel gmp-devel icu libicu libicu-devel postgresql-devel libxslt-devel libpng-devel libpng freetype-devel libsqlite3x-devel oniguruma-devel libjpeg libjpeg-devel
  1. 安装libzip
    下载地址:https://libzip.org/download/
cd /usr/src
yum install cmake3 -y
ln -s /usr/bin/cmake3 /usr/bin/cmake
wget https://libzip.org/download/libzip-1.6.1.tar.gz
tar zxvf libzip-1.6.1.tar.gz
cd libzip-1.6.1
mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && make && make install
  1. 安装jpeg(可选)
    一定要下v6b的
cd /usr/src
wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
mkdir /usr/man
mkdir /usr/man/man1
./configure --prefix=/usr
make && make install
  1. 安装pcre2
    下载地址:https://ftp.pcre.org/pub/pcre/
cd /usr/src
wget https://ftp.pcre.org/pub/pcre/pcre2-10.34.zip
unzip pcre2-10.34.zip
cd pcre2-10.34
./configure --prefix=/usr/pcre2 \
--enable-pcre2-16 \
--enable-pcre2-32 \
--enable-jit \
--enable-jit-sealloc
make && make install
export PKG_CONFIG_PATH=/usr/pcre2/lib/pkgconfig/
  1. 安装php7.4.12
    下载地址:https://www.php.net/downloads
cd /usr/src
wget https://www.php.net/distributions/php-7.4.2.tar.gz
tar zxvf php-7.4.2.tar.gz
cd php-7.4.2
./configure --prefix=/usr/php \
--with-jpeg \
--with-pdo-pgsql \
--with-zlib-dir \
--with-freetype \
--enable-mbstring \
--with-libxml=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--enable-gd \
--with-pgsql \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--with-zip \
--with-pdo-mysql \
--with-mysqli \
--with-openssl \
--with-fpm-user=www \
--with-fpm-group=www \
--with-libdir=/lib/x86_64-linux-gnu/ \
--enable-ftp \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-opcache \
--enable-fpm \
--with-iconv \
--with-xpm=/usr \
--enable-static \
--disable-debug \
--disable-ipv6 \
--disable-fileinfo
make && make install
  1. 配置php
cd /usr/src/php-7.4.2
cp php.ini-production /usr/php/lib/php.ini
cp /usr/php/etc/php-fpm.conf.default /usr/php/etc/php-fpm.conf
cp /usr/php/etc/php-fpm.d/www.conf.default /usr/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
/etc/init.d/php-fpm start
chkconfig --add php-fpm
  1. 自定义php
    vi /usr/php/lib/php.ini
  • short_open_tag = On
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
  • expose_php = Off
  • max_execution_time = 300
  • max_input_time = 300
  • post_max_size = 32M
  • upload_max_filesize = 32M
  • date.timezone = Asia/Shanghai
  • opcache.enable=1
  • opcache.enable_cli=1
  • opcache.memory_consumption=128
  • opcache.interned_strings_buffer=8
  • opcache.max_accelerated_files=4000
  • opcache.revalidate_freq=60

vi /usr/php/etc/php-fpm.d/www.conf

  • listen.backlog = 511 去掉注释
    listen.owner = www
    listen.group = www
    listen.mode = 0660
    

    去掉注释

  • listen.allowed_clients = 127.0.0.1 去掉注释

  • pm.max_children = 10
  • pm.start_servers = 5
  • pm.min_spare_servers = 5
  • pm.max_spare_servers = 10
  • request_terminate_timeout = 600

vi /usr/php/etc/php-fpm.conf

  • pid = run/php-fpm.pid
  • error_log = log/php-fpm.log

    去掉注释
    重新启动php-fpm service php-fpm restart

转载请注明:医学园地 » CentOS7.3 安装php7.4.12

喜欢 (30)

您必须 登录 才能发表评论!

(1)个小伙伴在吐槽