最新消息:

php编译安装

PHP linuxyunweiriji 57浏览 0评论

下载php:

cd /usr/local/src

wget http://am1.php.net/distributions/php-5.3.27.tar.gz

解压:

tar -zxvf php-5.3.27.tar.gz

配置编译参数:

cd php-5.3.27

./configure \ –prefix=/usr/local/php \ –with-apxs2=/usr/local/apache/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-gd

报错

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

yum install -y libxml2-devel

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

yum install -y openssl openssl-devel

configure: error: Please reinstall the BZip2 distribution

yum install -y bzip2 bzip2-devel

configure: error: jpeglib.h not found.

原因:GD库没有安装

yum -y install libjpeg-devel

configure: error: png.h not found.

yum install -y libpng-devel

configure: error: freetype.h not found.

yum install -y freetype-devel

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

CentOS源不能安装libmcrypt-devel,由于版权的原因没有自带mcrypt的包

1、安装第三方yum源

wget http://www.atomicorp.com/installers/atomic

sh ./atomic

2、使用yum命令安装

yum install -y php-mcrypt libmcrypt libmcrypt-devel

error: Cannot find libmysqlclient_r under /usr/local/mysql.

路径问题,一般编译前添加环境变量就可以解决,例如这里只要:

export MYSQL_LIB_DIR=/usr/lib64/mysql

这里的/usr/lib64/mysql就是那个提示缺少的so文件所在文件夹

./configure\

–prefix=/usr/local/php\

–with-config-file-path=/usr/local/php/etc\

–with-mysql-dir=/usr\

–with-mysqli=/usr/bin/mysql_config\

–with-iconv-dir\

–with-freetype-dir=/usr/include/freetype2/freetype\

–with-jpeg-dir=/data/apps/libs\

–with-png-dir=/data/apps/libs\

–with-zlib\

–with-libxml-dir=/usr\

–enable-xml\

–disable-rpath\

–enable-bcmath\

–enable-shmop\

–enable-sysvsem\

–enable-inline-optimization\

–with-curl\

–enable-mbregex\

–enable-fpm\

–enable-mbstring\

–with-mcrypt=/data/apps/libs\

–with-gd\

–enable-gd-native-ttf\

–with-openssl\

–with-mhash\

–enable-pcntl\

–enable-sockets\

–with-xmlrpc\

–enable-zip\

–enable-soap\

–enable-opcache \

–with-pdo-mysql\

–enable-maintainer-zts

编译:

make

安装:

make install

拷贝配置文件:

cp php.ini-production /usr/local/php/etc/php.ini

apache结合php

Apache主配置文件为:/usr/local/apache/conf/httpd.conf

vim /usr/local/apache/conf/httpd.conf

LoadModule php5_module modules/libphp5.so

(注意,在apache安装目录下,modules下有libphp5.so,这是php安装时添加进去的,如果没有,php你需要重装下)

找到

AddType application/x-gzip .gz .tgz

在该行下面添加:

AddType application/x-httpd-php .php

找到:

<IfModule dir_module> DirectoryIndex index.html index.htm index.php </IfModule>

ServerName修改为:

ServerName localhost:80

重新加载

/usr/local/apache2/bin/apachectl graceful

yum install xulrunner.i686

yum install libXtst.i686

转载请注明:PHP学习 » php编译安装

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址