php5安裝

技術小阿哥發表於2017-11-27

PHP官網www.php.net

當前主流版本為5.6/7.1

cd /usr/local/src/ 

wget http://cn2.php.net/distributions/php-5.6.30.tar.gz

tar zxf php-5.6.30.tar.gz

cd php-5.6.30

./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2.4/bin/apxs –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-pdo-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –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

–prefix= 指定安裝目錄 –with-apxs2=Apache的工具,不需要人工的干涉,自動的把擴充套件模組放到modules模組裡,並且在配置檔案里加一行loadmoduls,能夠httpd -M的時候把模組載入出來。所以要先安裝Apache,要指定這個工具地址

make && make install

cp php.ini-production /usr/local/php/etc/php.ini //配置檔案路徑/usr/local/php/etc因為這下面是空的(開發環境可使用php.ini-development)

/usr/local/php/bin/php -i|less //檢視php相關資訊

Loaded Configuration File => /usr/local/php/etc/php.ini

ls /usr/local/php/bin/ //php核心二進位制檔案

pear peardev pecl phar phar.phar php php-cgi php-config phpize

du -sh /usr/local/apache2.4/modules/libphp5.so //php擴充套件模組。Apache需要

37M /usr/local/apache2.4/modules/libphp5.so

/usr/local/php/bin/php -m //檢視載入的模組有哪些(顯示靜態檔案,也可動態擴充套件模組安裝)

[root@lsx-001 php-5.5.38]# du -sh /usr/local/php

77M /usr/local/php

[root@lsx-001 php-5.5.38]# du -sh /usr/local/apache2/modules/libphp5.so 

35M /usr/local/apache2/modules/libphp5.so Apache結合php依賴libphp5

[root@lsx-001 php-5.5.38]# /usr/local/php/bin/php –m 檢視載入的模組(靜態的)

[PHP Modules] 

bz2

Core

ctype

date

Apache配置檔案

[root@lsx-001 php-5.5.38]# vi /usr/local/apache2/conf/httpd.conf

錯誤:

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

解決辦法:

yum list|grep libxml2

yum install -y libxml2-devel.x86_64

2.error: Cannot find OpenSSL`s <evp.h>

yum list|grep OpenSSL -i

yum install -y openssl-devel.x86_64

3.error: Please reinstall the BZip2 distribution

yum install -y bzip2-devel.x86_64

4.error: jpeglib.h not found.

yum install -y libjpeg-turbo-devel.x86_64

5.error: png.h not found.

yum install -y libpng-devel.x86_64

6.error: freetype-config not found.

yum install -y freetype-devel.x86_64

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

yum install -y epel-release

yum install -y libmcrypt-devel

本文轉自 蝦米的春天 51CTO部落格,原文連結:http://blog.51cto.com/lsxme/2051885,如需轉載請自行聯絡原作者


相關文章