编译安装php7.2
centos-7.0 64
groupadd www
useradd -g www www
1、先安装如下依赖包
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 recode-devel libxslt-devel autoconf
2、下载并配置
cd /usr/local/src
wget /distributions/php-7.2.
tar -xf php-7.2.
cd php-7.2.18
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--with-config-file-scan-dir=/usr/local/php/etc/ \
--with-fpm-user=www \
--with-fpm-group=www \
--with-pear \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-zlib \
--with-iconv-dir \
--with-mhash \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-xsl \
--with-recode \
--with-libxml-dir \
--with-xmlrpc \
--with-gettext \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-gd-jis-conv \
--enable-zip \
--enable-xml \
--enable-bcmath \
--enable-calendar \
--enable-shmop \
--enable-dba \
--enable-wddx \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-opcache \
--enable-pcntl \
--enable-fpm \
--enable-maintainer-zts \
--disable-debug
编译出现问题,可参考:/
3、编译安装
make && make install
cd /usr/local/php/bin
./php -v
./php -m
证明安装成功了。
4、环境变量
vi /etc/profile
PATH=$PATH:/usr/local/php/bin
export PATH
source /etc/profile
这样,/usr/local/php/bin 下的所有程序就可以全局执行了
pear peardev pecl phar php php-cgi php-config phpdbg phpize
5、生成
根据上面的配置,phpini应该在 /usr/local/php/etc 下面,
或者,php -r "phpinfo();" | grep ''
但是,在该目录下并没有文件,需要手动生成。
find / -name *
/usr/local/src/php-7.2.18/-production
/usr/local/src/php-7.2.18/-development
根据环境,复制一个到 /usr/local/php/etc 下面,并改名为
cp /usr/local/src/php-7.2.18/-development /usr/local/php/etc
cd /usr/local/php/etc
mv -development
php -v
php -m
如果需要启动fpm,还需要继续进行
cd /usr/local/src/php-7.2.18/sapi/fpm
cp -fpm /etc//php-fpm
chmod +x /etc//php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cp /usr/local/php/etc/ /usr/local/php/etc/
cp /usr/local/php/etc// /usr/local/php/etc//
/etc//php-fpm start
参考 /u010861514/article/details/51926575