码迷,mamicode.com
首页 > Web开发 > 详细

LNMP环境搭建——PHP篇

时间:2015-08-13 10:02:46      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:php   zlib   pdo   bcmath   mbstring   

一、源码安装

1.编译安装

./configure  --prefix=/usr/local/php\
--with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl \
--enable-ftp --enable-sockets --disable-ipv6 --with-gd \
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local \
--with-freetype-dir=/usr/local --enable-gd-native-ttf \
--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \
--with-gettext --with-libxml-dir=/usr/local --with-zlib \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \
--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make install

2.错误处理

[ERROR]-1

checking for ZLIB support... no 
checking if the location of ZLIB install directory is defined... yes 
configure: error: Cannot find libz

[ERROR]-2

checking whether to enable JIS-mapped Japanese font support in GD... no 
If configure fails try --with-vpx-dir=<DIR> 
configure: error: jpeglib.h not found.

【解决办法】

wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd2
make
make instal

在网上找到了libjpeg,可以用这个库实现JPG图片的各种操作;下载:http://freeware.sgi.com/source/libjpeg/libjpeg-6b.tar.gz
参考README安装库,大体步骤如下:

./configure
Make
Make install

[ERROR]-3

If configure fails try --with-xpm-dir=<DIR> 
configure: error: freetype-config not found.

[ERROR]-4

checking whether to enable JIS-mapped Japanese font support in GD... no 
configure: error: vpx_codec.h not found.

[Bzip2 Install]

tar -xzvf bzip2-1.0.6.tar.gz

进入解压后的目录:cd bzip2-1.0.6
为编译做准备,创建libbz2.so动态链接库(这一步很重要,安装python的时候如果没有这一步,python安装不上bz2模块):

make -f Makefile-libbz2_so

编译安装: make && make install

二、RPM安装

[root@kallen ~]# rpm -ivh php-common-5.4.40-1.el6.remi.x86_64.rpm 
warning: php-common-5.4.40-1.el6.remi.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
Preparing...                ########################################### [100%]
file /etc/php.ini from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64
file /usr/lib64/php/modules/curl.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64
file /usr/lib64/php/modules/fileinfo.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64
file /usr/lib64/php/modules/json.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64
file /usr/lib64/php/modules/phar.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64
file /usr/lib64/php/modules/zip.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts with file from package php-common-5.3.3-26.el6.x86_64


error: Failed dependencies:
 libmysqlclient.so.18()(64bit) is needed by php-mysql-5.4.40-1.el6.remi.x86_64
 libmysqlclient.so.18(libmysqlclient_16)(64bit) is needed by php-mysql-5.4.40-1.el6.remi.x86_64
 libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by php-mysql-5.4.40-1.el6.remi.x86_64

三、YUM安装

1.PHP-5.4

php5.4于2012年5月8号发布,从php5.4.0开始php加入了一些新特色如:

  • Traits支持
  • 内置了一个简单的Web服务器
  • 提供了数组简短语法
  • 直接对函数返回值进行数组取值
  • 最终删除魔术方法及安全模式

推荐使用 Webtatic EL6的YUM源来安装php5.4,我们首先安装Webtatic EL6 YUM源,关于YUM源的安装配置请参考《在RHEL6中配置YUM源》一文;

rpm -Uvh http://repo.webtatic.com/yum/el6/latest.rpm  
yum -y install php54w php54w-bcmath php54w-cli \
php54w-common php54w-devel php54w-fpm php54w-gd \
php54w-imap php54w-ldap php54w-mbstring php54w-mcrypt \
php54w-mysql php54w-odbc php54w-pdo php54w-pear \
php54w-pecl-igbinary php54w-xml php54w-xmlrpc \
php54w-opcache php54w-intl php54w-pecl-memcache 

如果安装失败,建议您先卸载以前的php再进行安装,使用

 yum remove php php-*

附带的php扩展列表:

Package Provides
php54w mod_php
php54w-bcmath
php54w-cli php-cgi, php-pcntl, php-readline
php54w-common php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php54w-dba
php54w-devel
php54w-embedded php-embedded-devel
php54w-enchant
php54w-fpm
php54w-gd
php54w-imap
php54w-interbase php_database, php-firebird
php54w-intl
php54w-ldap
php54w-mbstring
php54w-mcrypt
php54w-mssql
php54w-mysql php-mysqli, php_database
php54w-odbc php-pdo_odbc, php_database
php54w-pdo
php54w-pgsql php-pdo_pgsql, php_database
php54w-process php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php54w-pspell
php54w-recode
php54w-snmp
php54w-soap
php54w-tidy
php54w-xml php-dom, php-domxml, php-wddx, php-xsl
php54w-xmlrpc
php54w-zts

[root@kallen ~]# yum install php54w-gd.x86_64
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php54w-gd.x86_64 0:5.4.41-1.w6 will be installed
--> Processing Dependency: libt1.so.5()(64bit)for package: php54w-gd-5.4.41-1.w6.x86_64
--> Finished Dependency Resolution
Error: Package: php54w-gd-5.4.41-1.w6.x86_64 (webtatic)
           Requires:libt1.so.5()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

解决办法:

[root@kallen ~]# rpm -ivh t1lib-5.1.2-6.el6_2.1.x86_64.rpm 
warning: t1lib-5.1.2-6.el6_2.1.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:t1lib                   ########################################### [100%]

2.PHP-5.5

[root@kallen ~]# yum remove php  php-bcmath php-cli php-common  php-devel php-fpm    php-gd php-imap  php-ldap php-mbstring php-mcrypt php-mysql   php-odbc   php-pdo   php-pear  php-pecl-igbinary  php-xml php-xmlrpc
[root@kallen ~]# yum install php55w  php55w-bcmath php55w-cli php55w-common  php55w-devel php55w-fpm    php55w-gd php55w-imap  php55w-ldap php55w-mbstring php55w-mcrypt php55w-mysql   php55w-odbc   php55w-pdo   php55w-pear  php55w-pecl-igbinary  php55w-xml php55w-xmlrpc php55w-opcache php55w-intl php55w-pecl-memcache

四、版本测试

1.查看PHP版本信息

(1) 查看版本号

kallen@kallen:~$ php -v
PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul  2 2015 15:23:08) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies 

(2) 查看安装信息
在Apache的document root目录下编辑测试页面index.php,内容如下:

<?php
    phpinfo();
?>

通过http://localhost:port/php/index.php访问:
技术分享
技术分享

2.查看PHP已安装模块

kallen@kallen:~$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mbstring
mhash
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache 

3.MySQL连接测试

<?php
    $link=mysql_connect(‘localhost‘,‘root‘,‘*‘);
    if(!$link)
        echo "Connection Error!";
    else
        echo "Connected Successfully!"
    mysql_close();
?>

未完续待!

版权声明:本文为博主原创文章,未经博主允许不得转载|Copyright ©2011-2015, Kallen Ding, All Rights Reserved.

LNMP环境搭建——PHP篇

标签:php   zlib   pdo   bcmath   mbstring   

原文地址:http://blog.csdn.net/beautifulencounter/article/details/47301215

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!