php編譯安裝

編程語言 PHP OpenSSL MySQL linux運維日記 2017-05-14

下載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

相關推薦

推薦中...