jxdiscuz 发表于 2018-12-14 13:31:15

LAMP中的php编译安装

  

  下载安装包:wgethttp://cn2.php.net/distributions/php-5.6.29.tar.gz
  php编译安装步骤:
  一,配置编译参数./configure
  ./configure   \
  >--prefix=/usr/local/php\
  >--with-apxs2=/usr/local/apache2/bin/apxs\   //安装该参数后会出现php_module模块
  >--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
  ./configure编译之后遇到的一些错误信息:
  1.configure: error: Cannot find OpenSSL's
  解决方法:yum install -yopensslopenssl-devel
  2.checking for BZip2 in default path... not found
  configure: error: Please reinstall the BZip2 distribution
  解决方法:yum install -y bzip2 bzip2-devel
  3.configure: error: jpeglib.h not found.
  解决方法:yum install -ylibjpeg-turbolibjpeg-turbo-devel
  4.configure: error: png.h not found.
  解决方法:yum install -ylibpnglibpng-devel
  5.configure: error: freetype-config not found.
  解决方法:yuminstall-yfreetype   freetype-devel
  6.configure: error: mcrypt.h not found. Please reinstall libmcrypt.
  解决方法:yum   install-y   epel-release
     yum    install-ylibmcrypt-devel
  (因为Centos默认的yum源没有libmcrypt-devel这个包,只能借epel的yum源)
  7.checking for xml2-config path...
  configure: error: xml2-config not found. Please check your libxml2 installation.
  解决方法:yuminstall-ylibxml2-devel
  二,编译make
  三,安装make install
  安装完成后,还不能使用,还需要进一步配置一下
  拷贝php配置文件:(在./configure配置参数时的目录下)
  cpphp.ini-production   /usr/local/php/etc/php.ini
  (这一步必须得有,要不然后面不能正常解析php文件)
http://s4.运维网.com/wyfs02/M00/8B/A1/wKioL1hTceLR_lp9AAD3rJ4QBs0970.png-wh_500x0-wm_3-wmp_4-s_777933021.png
  修改apache配置文件
  vi/usr/local/apache2/conf/httpd.conf
  1.找到:
  
      AllowOverride None
      Options None
      Order allow,deny
      Deny from all
  
  改为:
  
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
  
  说明:如果不修改这个地方,我们访问网站会禁止访问,显示403
  2.找到: AddType application/x-gzip .gz .tgz
  在该行下面添加: AddType application/x-httpd-php .php
  说明:要想支持PHP脚本解析,必须要加上对应的类型
  3.找到:
  
      DirectoryIndex index.html index.htm
  
  改为:
  
      DirectoryIndex index.html index.htm index.php
  
  说明:增加针对php的索引,如果一个站点默认页为index.php,那么就得加上这个index.php的支持。
  4.找到:
  #ServerNamewww.example.com:80
  改为:
  ServerName   localhost:80
  说明:如果不去掉#,启动apache时,会有警告信息
  5.去掉/user/local/apache2/conf/httpd.conf里#Include conf/extra/httpd-vhosts.conf的井号,解析localhost下的php提示404.
  原因:/usr/local/apache2/confhttpd.conf下的php文件在doucmentroot=/usr/local/apache2/htdocs下;而/usr/local/apache2/conf/extra/httpd-vhosts.conf下的php文件在doucmentroot=/data/www下。两个路径不一样所以不能通用php文件
  6.要想使用curllocalhost/1.php:要开启httpd服务,该命令才可以使用
  




页: [1]
查看完整版本: LAMP中的php编译安装