Centos下编译php

2020-08-25 14:26:21 浏览数 (1)

1.下载php的源码

我是在官网下好,然后通过ftp发给服务器的

2.安装依赖包

代码语言:javascript复制
sudo yum install gcc gcc-c   libxml2 libxml2-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel  zlib zlib-devel   
    glibc glibc-devel glib2 glib2-devel openssl-devel bzip2-devel libcurl-devel t1lib-devel gmp-devel libc-client-devel openldap-devel unixODBC-devel   
    mysql-devel expat-devel libxslt-devel libmcrypt libmcrypt-devel libedit wget  

3.将源码解压到 /usr/src文件夹

代码语言:javascript复制
sudo tar -zxvf php-5.4.8.tar.gz -C /usr/src

4.执行

代码语言:javascript复制
./configure 
--prefix=/usr/local/php 
--with-mcrypt=/usr/local/libmcrypt 
--with-zlib --enable-mbstring 
--with-openssl 
--with-mysql 
--with-mysqli --with-mysql-sock 
--with-gd --with-jpeg-dir=/usr/lib 
--with-bz2 
--with-pdo-mysql 
--with-gettext 
--with-curl 
--with-pdo-mysql 
--enable-sockets 
--enable-bcmath 
--enable-xml 
--enable-zip 
--enable-gd-native-ttf 
--enable-pdo 
--enable-fpm 

5.进行编译安装

代码语言:javascript复制
make
make install

6.安装后的一些配置

代码语言:javascript复制
    cp php.ini-production /usr/local/php5/etc/php.ini  
    cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf  
    mkdir /usr/local/php5/etc/php.d  
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm  
    chmod u x /etc/init.d/php-fpm  
    service php-fpm start  
    chkconfig php-fpm on  

0 人点赞