LNMP環境搭建——PHP篇

來源:互聯網
上載者:User
一、源碼安裝

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... nochecking if the location of ZLIB install directory is defined... yesconfigure: 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.gztar zxvf gd-2.0.33.tar.gzcd gd-2.0.33./configure --prefix=/usr/local/gd2makemake instal

在網上找到了libjpeg,可以用這個庫實現JPG圖片的各種操作;下載:http://freeware.sgi.com/source/libjpeg/libjpeg-6b.tar.gz,
參考README安裝庫,大體步驟如下:

./configureMakeMake install

[ERROR]-3

If configure fails try --with-xpm-dir=<DIR>configure: error: freetype-confignot 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: NOKEYPreparing...                ########################################### [100%]file /etc/php.ini from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64file /usr/lib64/php/modules/curl.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64file /usr/lib64/php/modules/fileinfo.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64file /usr/lib64/php/modules/json.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64file /usr/lib64/php/modules/phar.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64file /usr/lib64/php/modules/zip.so from install of php-common-5.4.40-1.el6.remi.x86_64 conflicts withfilefrom package php-common-5.3.3-26.el6.x86_64error: 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_64Loaded plugins: product-id, security, subscription-managerThis system isnot registered to Red Hat Subscription Management. You can use subscription-manager toregister.Setting up Install ProcessResolving 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 ResolutionError: 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: NOKEYPreparing...                ########################################### [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版本資訊

kallen@kallen:~$ php -vPHP 5.5.9-1ubuntu4.11 (cli) (built: Jul  2201515:23:08) Copyright (c) 1997-2014 The PHP GroupZend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies 
    phpinfo();?>


2.查看PHP已安裝模組

kallen@kallen:~$ php -m[PHPModules]bcmathbz2calendarCorectypedatedbadomeregexiffileinfofilterftpgdgettexthashiconvjsonldaplibxmlmbstringmhashmysqlmysqliopensslpcntlpcrePDOpdo_mysqlpdo_pgsqlpgsqlPharposixreadlineReflectionsessionshmopSimpleXMLsoapsocketsSPLstandardsysvmsgsysvsemsysvshmtokenizerwddxxmlxmlreaderxmlwriterZendOPcachezipzlib[ZendModules]ZendOPcache

3.MySQL串連測試

$link=mysql_connect('localhost','root','*');    if(!$link)        echo"Connection Error!";    elseecho"Connected Successfully!"    mysql_close();?>

未完續待!

著作權聲明:本文為博主原創文章,未經博主允許不得轉載|Copyright ©2011-2015, Kallen Ding, All Rights Reserved.

以上就介紹了LNMP環境搭建——PHP篇,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.