baiyunjn 发表于 2018-12-14 11:46:39

LAMP搭建3:PHP安装

  1.进入/usr/local/src/目录下载安装包php-5.4.36.tar.bz2
  # cd /usr/local/src
  # ls
  php-5.4.36.tar.bz2
  2.解压安装包
  # tar jxvf php-5.4.36.tar.bz2
  # echo $?
  0
  3.进入安装目录
  # cd php-5.4.36
  4.配置安装选项
  # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --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 --disable-ipv6
  php编译安装中常见配置错误处理请参考:
  (1)http://www.poluoluo.com/jzxy/201505/364819.html
  (2)http://blog.sina.com.cn/s/blog_75a07c3b0101kcwb.html
  错误1:configure: error: Cannot find OpenSSL's
  解决:# yum install -y openssl openssl-devel
  错误2:configure: error: Please reinstall the BZip2 distribution
  解决:# yum install bzip2 bzip2-devel
  错误3:configure: error: jpeglib.h not found.
  解决:# yum -y install libjpeg-devel
  错误4:configure: error: png.h not found.
  解决:# yum -y install libpng-devel
  错误5:configure: error: freetype-config not found.
  解决:# yum -y install freetype-devel
  错误6:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  解决:由于centos官方源中没有libmcrypy-devel这个包,我们需要安装一个工具epel,然后再安装libmcrypy-devel。
  # rpm -ivh 'http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm'
  # yum list |grep -i mcrypt
  libmcrypt.i686                              2.5.8-9.el6                  epel
  libmcrypt-devel.i686                        2.5.8-9.el6                  epel
  libtomcrypt.i686                            1.17-21.el6                  epel
  libtomcrypt-devel.i686                      1.17-21.el6                  epel
  libtomcrypt-doc.noarch                      1.17-21.el6                  epel
  mcrypt.i686                                 2.6.8-10.el6               epel
  php-mcrypt.i686                           5.3.3-5.el6                  epel
  # yum install -y libmcrypt-devel
  直到配置全部正确:
  # echo $?
  0
  5.编译:
  # make
  # echo $?
  0
  6.安装:
  # make install
  # echo $?
  0
  7.查看安装结果:
  # ls /usr/local/php/
  binetcincludelibphp
  8.将php加入系统环境变量:
  # vim /etc/profile.d/path.sh
  #!/bin/bash
  export PATH=$PATH:/etc/init.d/:/usr/local/mysql/bin/:/usr/local/apache2/bin/:/usr/local
  /php/bin/
  # source /etc/profile.d/path.sh
  9.测试PHP
  # php -m# -m选项查看php的静态模块
  # php -i# -i选项列出php配置的详细信息,包括模块的
  部分配置选项说明:
  # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --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 --disable-ipv6
  --with-apxs2帮助安装动态模块的工具
  # ls /usr/local/apache2/modules/
  httpd.explibphp5.somod_deflate.somod_expires.somod_rewrite.so
  Apache目录下多了一个动态模块libphp5就是apxs的功劳
  --with-mysql说明php依赖MySQL,所以才先安装MySQL
  




页: [1]
查看完整版本: LAMP搭建3:PHP安装