首页 > 文章详情 > PHP7.2 源码编译安装

PHP7.2 源码编译安装

原创 YuanDong 2019-10-08 浏览量(649)
  • 下载源码包至 /usr/local/src/ (建议去官网下载)
官网[https://www.php.net/downloads.php](https://www.php.net/downloads.php)
wget https://www.php.net/distributions/php-7.2.21.tar.gz
  • 解压源码包
tar -zxvf php-7.2.12.tar.gz
  • 切换到源码包路径
cd php-7.2.12
  • 配置编译检测
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip
---------- 注解 ---------------
--prefix=/usr/local/php 指定PHP安装目录
--with-config-file-path=/usr/local/php/etc 指定PHP配置文件目录
  • 编译可能会报错 需要安装php 需要的扩展模块 这里列出了平常需要的,根据自己需要的模块 选择性安装
yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
  • 编译安装PHP
make && make install
  • 复制配置文件
[root@localhost php-7.2.12]# cp php.ini-production /usr/local/php/etc/php.ini
[root@localhost php-7.2.12]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-7.2.12]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@localhost php-7.2.12]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.2.12]# chmod +x /etc/init.d/php-fpm //给执行权限
[root@localhost php-7.2.12]# ln -s /etc/init.d/php-fpm /usr/bin/ //创建软链接
  • 添加开机自动启动
chkconfig php-fpm on
  • 启动PHP服务
service php-fpm start

PHP相关命令

#启动php
service php-fpm start

#关闭PHP
service php-fpm stop

#重启PHP
service php-fpm restart

#查看是否已经成功启动PHP
ps -ef | grep php

热门评论 (0)

网友评论 0 条评论 / 0 人参与