代码改变世界

PHP编译安装

2018-02-04 15:25  親親宝贝  阅读(303)  评论(0编辑  收藏  举报
前提:必须先安装好MySQL以及Apache
 

1.准备好源码包并配置好yum源,需要的源码包包括:

libmcrypt-2.5.8-9.el6.x86_64.rpm
libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
mhash-0.9.9.9-3.el6.x86_64.rpm
mhash-devel-0.9.9.9-3.el6.x86_64.rpm
php-5.5.33.tar.gz

1.png

 

2.安装依赖环境包:

rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm
rpm -ivh libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
rpm -ivh mhash-0.9.9.9-3.el6.x86_64.rpm
rpm -ivh mhash-devel-0.9.9.9-3.el6.x86_64.rpm
yum install libxml2 -y
yum install libxml2-devel -y
yum install bzip2 -y
yum install bzip2-devel
yum install libjpeg -y
yum install libjpeg-devel -y
yum install libpng -y
yum install libpng-devel -y
yum install libcurl -y
yum install libcurl-devel -y
yum install readline-devel -y
yum install t1lib-devel -y
yum install libXpm -y
yum install libXpm-devel -y
yum install freetype -y
yum install freetype-devel -y

 

3.解包并编译

tar -xf php-5.5.33.tar.gz && cd php-5.5.33

./configure \
--prefix=/usr/local/php55 \
--with-mysql=/usr/local/mysql \
--with-openssl \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-mbstring \
--with-gd \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-xpm-dir \
--with-t1lib \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-libxml-dir=/usr \
--enable-xml \
--enable-sockets \
--with-mcrypt \
--with-config-file-path=/usr/local/php55/etc \
--with-config-file-scan-dir=/usr/local/php55/etc/php.d \
--with-bz2 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mhash \
--enable-zip \
--enable-ftp \
--with-curl \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-bcmath \
--enable-soap \
--with-iconv \
--enable-inline-optimization \
--with-gettext \
--enable-shared \
--enable-opcache \
--enable-maintainer-zts \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-readline

2.png

预处理完成是下面这个样子

3.png

然后我们就可以 make && make install 了

4.png

过程会比较漫长,请耐心等待...

编译安装完成:

5.png

 

4.收尾工作

cp php.ini-production /usr/local/php55/etc/php.ini
echo 'export PATH=$PATH:/usr/local/php55/bin' >> /etc/profile.d/php.sh

6.png

 

配置Apache支持php

vim /etc/httpd/httpd.conf

7.png

8.png

 

配置php.ini

vim /usr/local/php55/etc/php.ini

9.png

10.png

11.png

12.png

 

5.编辑测试php文件,重启Apache测试

vim /usr/local/httpd/htdocs/index.php

<?php
    phpinfo();
?>

13.png

service httpd restart

14.png

到此,php编译安装成功。