Linux9.4 安装PHP

安装PHP5

PHP官网www.php.net
当前主流版本为5.6/7.1

cd /usr/local/src/ 
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zxf php-5.6.30.tar.gz
cd php-5.6.30
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
prefix安装目录
with-apxs2是apache工具,自动把扩展模块放到moudles目录,且在配置文件加上一行,配置成功
with-config-file-path指定配置文件所在路径
with-mysql指定MySQL路径
with-pdo-mysql     
with-mysqli    指定MySQL库  路径等
目的为了让php支持MySQL
后续为一些Php需要的模块

安装报错:

1. configure: error: xml2-config not found. Please check your libxml2 installation.

[root@chy002 php-5.6.30]# yum list|grep xml2
libxml2.x86_64                            2.9.1-6.el7_2.3              @base
libxml2-python.x86_64                     2.9.1-6.el7_2.3              @base
libxml2.i686                              2.9.1-6.el7_2.3              base
libxml2-devel.i686                        2.9.1-6.el7_2.3              base
libxml2-devel.x86_64                      2.9.1-6.el7_2.3              base
libxml2-static.i686                       2.9.1-6.el7_2.3              base
libxml2-static.x86_64                     2.9.1-6.el7_2.3              base
mingw32-libxml2.noarch                    2.9.3-1.el7                  epel
mingw32-libxml2-static.noarch             2.9.3-1.el7                  epel
mingw64-libxml2.noarch                    2.9.3-1.el7                  epel
mingw64-libxml2-static.noarch             2.9.3-1.el7                  epel
python-xml2rfc.noarch                     2.5.2-2.el7                  epel
tinyxml2.x86_64                           2.1.0-2.20140406git6ee53e7.el7
tinyxml2-devel.x86_64                     2.1.0-2.20140406git6ee53e7.el7
xml2.x86_64                               0.5-7.el7                    epel

因为缺少的是库文件,所以使用后缀有devel的包
[root@chy002 php-5.6.30]# yum install -y libxml2-devel.x86_64

2. configure: error: Cannot find OpenSSL's <evp.h>

[root@chy002 php-5.6.30]# yum install -y openssl-devel.i686

 

3.  configure: error: libcrypto not found!

出现这个问题是因为问题2的openssl包安装错了,应该是x86_64的

 

4. configure: error: Please reinstall the BZip2 distribution

[root@chy002 php-5.6.30]# yum install -y bzip2-devel.x86_64

 

5.  configure: error: jpeglib.h not found.

[root@chy002 php-5.6.30]# yum install -y libjpeg-devel

 

6.  configure: error: png.h not found.

[root@chy002 php-5.6.30]# yum install -y libpng-devel.x86_64

 

7.   configure: error: freetype-config not found.

[root@chy002 php-5.6.30]# yum install -y freetype-devel.x86_64

 

8.  configure: error: mcrypt.h not found. Please reinstall libmcrypt.

[root@chy002 php-5.6.30]# yum install -y libmcrypt-devel.x86_64

 

make && make install
cp php.ini-production /usr/local/php/etc/php.ini

 

主要的二进制文件

[root@chy002 php-5.6.30]# du -sh /usr/local/php/bin/
71M     /usr/local/php/bin/

 

php和apache结合的模块

[root@chy002 php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so
37M     /usr/local/apache2.4/modules/libphp5.so

 

php所有静态模块显示

[root@chy002 php-5.6.30]# /usr/local/php/bin/php -m
[PHP Modules]
bz2
Core
... ...
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

 

php需要启动吗?

可以看下apache的模块 ,发现最后一个就是Php模块,所以不用启动,存在该模块即可。apache配置文件可以配置加载某些模块。

 

posted @ 2018-02-28 21:47  chyuanliu  阅读(178)  评论(0编辑  收藏  举报