Home > php教程 > php手册 > centos64位lamp配置第三步:编译php5.3.27

centos64位lamp配置第三步:编译php5.3.27

WBOY
Release: 2016-06-06 20:02:19
Original
961 people have browsed it

下载php-5.3.27.tar.gz,解压tar -zxvf php-5.3.27,确保已经安装了yum -y install wget gcc-c ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libevent libevent-devel libxml2 libxml2-devel libmcrypt libmcrypt-devel curl-deve

下载php-5.3.27.tar.gz,解压tar -zxvf php-5.3.27,确保已经安装了yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libevent libevent-devel libxml2 libxml2-devel  libmcrypt libmcrypt-devel curl-devel libpng-devel libtool-ltdl-devel libjpeg* libpng* freetype* zlib zlib-devel openldap openldap-devel libxslt-devel* bzip2-devel

执行:cp -frp /usr/lib64/libldap* /usr/lib/

安装mhash:

# tar zxvf mhash-0.9.9.tar.gz<br> # cd mhash-0.9.9

# mkdir -p /usr/local/mhash<br> # ./configure prefix=/usr/local/mhash<br> # make && make install<br>

安装libmcrpt:

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz<br>

tar -zxvf libmcrypt-2.5.7.tar.gz <br> cd libmcrypt-2.5.7 <br> mkdir -p /usr/local/libmcrytp <br> ./configure prefix=/usr/local/libmcrytp/   #默认也可以<br> make<br> make install <br>

这些准备环境。

<br>

进入php-5.3.27目录,执行./configure,如果是在nginx之前编译,要去掉

<span><strong>--with-apxs2=/usr/local/apache/bin/apxs,--with-iconv=/usr/local/libiconv改为--with-iconv</strong></span>
Copy after login
:
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-bz2 --with-gettext --with-mhash --with-mcrypt --with-iconv=/usr/local/libiconv --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-pdo --enable-gd-native-ttf --enable-bcmath --enable-mbstring --enable-zip --enable-soap --enable-sockets --enable-ftp --without-pear --enable-fpm --enable-inline-optimization
Copy after login
<br>

下面是参考:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local/libiconv --with-libxml-dir=/usr --enable-xml --with-curl --with-curlwrappers --with-mhash --with-mcrypt=/usr/local/libmcrytp --with-gd --enable-gd-native-ttf --with-xsl --with-openssl --with-ldap --with-ldap-sasl --with-xmlrpc --without-pear --with-plugins=innobase --without-debug --with-charset=utf8 --with-collation=utf8_unicode_ci --with-extra-charsets=utf8 --with-pthread --enable-static --enable-safe-mode --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-thread-safe-client --with-mysqld-user=mysql --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-pdo --with-big-tables --without-debug --with-jpeg-dir=/usr/lib --with-png-dir --with-freetype-dir --with-zlib --enable-mbstring --with-pear --enable-mbregex --enable-zend-multibyte --enable-sockets --enable-soap --enable-exif --with-mhash=/usr/local/mhash --with-apxs2=/usr/local/apache/bin/apxs --enable-fpm --enable-inline-optimization<br>

完成后会看到thank you for use php字样

  make

make install

没有出现error就ok了。

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

sed -i 's/;date.timezone =/date.timezone = Asia\/Shanghai/g' /usr/local/php/etc/php.ini<br> sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php/etc/php.ini<br> sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini<br> sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini<br> sed -i '262i output_buffering = On' /usr/local/php/etc/php.ini<br>

配置php-fpm:

cp sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

<br>

# cd /usr/local/php/etc/

# cp php-fpm.conf.default php-fpm.conf

# vi php-fpm.conf    //一般配置的依据如下

内存小于4G服务器(值可逐级递减):

修改如下参数:

pm=dynamic

pm.max_children=40

pm.start_servers=10

pm.min_spare_servers=10

pm.max_spare_servers=40

 ******************************

内存大于4G服务器(值可逐级递增):

修改如下参数:

pm=static

pm.max_children=100

<br>

<br>

安装pdo-mysql:

tar zxvf PDO_MYSQL-1.0.2.tgz<br> cd PDO_MYSQL-1.0.2/<br> /usr/local/php/bin/phpize<br> ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql<br> make && make install<br>

修改Php.ini:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"<br> extension = "pdo_mysql.so"<br>

 service php-fpm start<br>

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

查找AddType

添加:AddType application/x-httpd-php .php

查找DirectoryIndex,在DirectoryIndex后面添加index.php

DirectoryIndex index.php index.html

        查找:LoadModule php5_module modules/libphp5.so

        如果没有就添加,使用phpinfo()测试,能输出php信息就ok了。

        

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template