1. 程式人生 > >PHP編譯安裝

PHP編譯安裝

php編譯安裝

php官方下載地址: http://www.php.net/downloads.php

下載php:

[[email protected] httpd-2.2.16]# cd /usr/local/src [[email protected] src]# wget http://am1.php.net/distributions/php-5.3.27.tar.gz

解壓:

[[email protected] src]# tar zxvf php-5.3.27.tar.gz (bz2格式用:tar jvxf .....

配置編譯參數:

[[email protected]

/* */ src]# cd php-5.3.27 [[email protected] php-5.3.27]# ./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

在這一步,遇到如下錯誤:

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

解決辦法是:

yum install -y libxml2-devel

還有錯誤:

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

解決辦法是:

yum install -y openssl openssl-devel

錯誤:

checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution

解決辦法:

yum install -y bzip2 bzip2-devel

錯誤:

configure: error: png.h not found.

解決辦法:

yum install -y libpng libpng-devel

錯誤:

configure: error: freetype.h not found.

解決辦法:

yum install -y freetype freetype-devel

錯誤:

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

解決辦法:

rpm -ivh "http://www.aminglinux.com/bbs/data/attachment/forum/month_1211/epel-release-6-7.noarch.rpm" yum install -y epel-release yum install -y libmcrypt-devel

因為centos6.x 默認的yum源沒有libmcrypt-devel 這個包,只能借助第三方yum源或者epel的yum源。

在這一步,也許還會遇到諸多錯誤,遇到上面未列出的錯誤時,請參照 http://blog.sina.com.cn/s/blog_167f23bf50102xdki.html

編譯:

[[email protected] php-5.3.27]# make

安裝:

[[email protected] php-5.3.27]# make install

拷貝配置文件:

[[email protected] php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini

Apache主配置文件為:/usr/local/apache2/conf/httpd.conf

#vim /usr/local/apache2/conf/httpd.conf

找到:

AddType application/x-gzip .gz .tgz

在該行下面添加:

AddType application/x-httpd-php .php

找到:

<IfModule dir_module>

DirectoryIndex index.html + index.php

</IfModule>

在DirectoryIndex index.htm後面加上index.php

找到:

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

將該行改為:

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

找到:

#ServerName www.example.com:80

修改為:

ServerName localhost:80


本文出自 “12350027” 博客,謝絕轉載!

PHP編譯安裝