• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

LNMP环境搭建——PHP篇

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

一、源代码安装

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支持
  • 内置了一个简单的Webserver
  • 提供了数组简短语法
  • 直接对函数返回值进行数组取值
  • 终于删除魔术方法及安全模式

推荐使用 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();
?

>

未完续待。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
策略模式和php实现发布时间:2022-07-10
下一篇:
适用于php-5.2的php.ini中文版发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap