1. 程式人生 > >11.10/11.11/11.12 安裝PHP511.13安裝PHP7

11.10/11.11/11.12 安裝PHP511.13安裝PHP7

11.10/11.11/11.12 安裝php511.13安裝php7

- 11.10/11.11/11.12 安裝PHP5
- 11.13 安裝PHP7
- 擴展
- php中mysql,mysqli,mysqlnd,pdo到底是什麽
- http://blog.csdn.net/u013785951/article/details/60876816
- 查看編譯參數 http://ask.apelearn.com/question/1295



# 11.10安裝PHP5 上

-  PHP官網www.php.net
-  當前主流版本為5.6/7.1

 1.   cd /usr/local/src/ 
 
 2.   wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
 
 3.   tar zxf php-5.6.30.tar.gz
 
 4.   cd php-5.6.30
 
 5.    ./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
 
 6.  make && make install
 
 7.  cp php.ini-production  /usr/local/php/etc/php.ini


```
[[email protected] ~]# cd /usr/local/src
[[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2
--2017-09-27 21:39:15--  http://cn2.php.net/distributions/php-5.6.30.tar.bz2
正在解析主機 cn2.php.net (cn2.php.net)... 202.108.35.250, 202.108.35.235
正在連接 cn2.php.net (cn2.php.net)|202.108.35.250|:80... 已連接。
已發出 HTTP 請求,正在等待回應... 200 OK
長度:15011816 (14M) [application/octet-stream]
正在保存至: “php-5.6.30.tar.bz2”

100%[====================================================>] 15,011,816   880KB/s 用時 19s     

2017-09-27 21:39:35 (756 KB/s) - 已保存 “php-5.6.30.tar.bz2” [15011816/15011816])

[[email protected] src]# du -sh php-5.6.30.tar.bz2 
15M	php-5.6.30.tar.bz2
[[email protected] src]# 
```
- 先解壓
```
[[email protected] src]# tar jxvf php-5.6.30.tar.bz2 

php-5.6.30/server-tests.php
php-5.6.30/php.ini-development
php-5.6.30/EXTENSIONS
php-5.6.30/README.namespaces
php-5.6.30/pear/
php-5.6.30/pear/install-pear.txt
php-5.6.30/pear/install-pear-nozlib.phar
php-5.6.30/pear/fetch.php
php-5.6.30/pear/Makefile.frag
php-5.6.30/README.SUBMITTING_PATCH
[[email protected] src]# 
```
- 編譯
- --with-apxs2=/usr/local/apache2.4/bin/apxs  指定apache的
- --with-mysql=/usr/local/mysql    指定mysql的 (PHP7 用不到這個)
- --with-mysqli=/usr/local/mysql/bin/mysql_config    指定mysql的
```
[[email protected] src]# cd php-5.6.30/
[[email protected] 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


Configuring extensions
checking size of long... (cached) 8
checking size of int... (cached) 4
checking for int32_t... yes
checking for uint32_t... yes
checking for sys/types.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for string.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for strtoll... yes
checking for atoll... yes
checking for strftime... (cached) yes
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... yes
checking for xml2-config path... 
configure: error: xml2-config not found. Please check your libxml2 installation.
[[email protected] php-5.6.30]#    這裏報錯了,運行echo $?
[[email protected] php-5.6.30]# echo $?
1
[[email protected] php-5.6.30]# echo $?
0
[[email protected] php-5.6.30]# 

```
-  configure: error: xml2-config not found. Please check your libxml2 installation. 搜下xml2
```
[[email protected] php-5.6.30]# yum list | grep xml2
libxml2.x86_64                          2.9.1-6.el7_2.3                @anaconda
libxml2.i686                            2.9.1-6.el7_2.3                base     
libxml2-devel.i686                      2.9.1-6.el7_2.3                base     
libxml2-devel.x86_64                    2.9.1-6.el7_2.3                base     
libxml2-python.x86_64                   2.9.1-6.el7_2.3                base     
libxml2-static.i686                     2.9.1-6.el7_2.3                base     
libxml2-static.x86_64                   2.9.1-6.el7_2.3                base     
mingw32-libxml2.noarch                  2.9.3-1.el7                    epel     
mingw32-libxml2-static.noarch           2.9.3-1.el7                    epel     
mingw64-libxml2.noarch                  2.9.3-1.el7                    epel     
mingw64-libxml2-static.noarch           2.9.3-1.el7                    epel     
python-xml2rfc.noarch                   2.5.2-2.el7                    epel     
tinyxml2.x86_64                         2.1.0-2.20140406git6ee53e7.el7 epel     
tinyxml2-devel.x86_64                   2.1.0-2.20140406git6ee53e7.el7 epel     
xml2.x86_64                             0.5-7.el7                      epel     
[[email protected] php-5.6.30]# 
```
- 我們需要的庫一幫都是 -devel 的包
```
[[email protected] php-5.6.30]# yum install -y libxml2-devel

已安裝:
  libxml2-devel.x86_64 0:2.9.1-6.el7_2.3                                                        

作為依賴被安裝:
  xz-devel.x86_64 0:5.2.2-1.el7                 zlib-devel.x86_64 0:1.2.7-17.el7                

完畢!
完了再次編譯,
[[email protected] 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



checking whether to use system default cipher list instead of hardcoded value... no
checking for DSA_get_default_method in -lssl... no
checking for X509_free in -lcrypto... no
checking for RAND_egd... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL‘s <evp.h>
[[email protected] php-5.6.30]# 
```
- 這裏又報錯了 configure: error: Cannot find OpenSSL‘s <evp.h>
```

[[email protected] php-5.6.30]# yum install -y openssl-devel

已安裝:
  openssl-devel.x86_64 1:1.0.2k-8.el7                                                           

作為依賴被安裝:
  keyutils-libs-devel.x86_64 0:1.5.8-3.el7           krb5-devel.x86_64 0:1.15.1-8.el7           
  libcom_err-devel.x86_64 0:1.42.9-10.el7            libkadm5.x86_64 0:1.15.1-8.el7             
  libselinux-devel.x86_64 0:2.5-11.el7               libsepol-devel.x86_64 0:2.5-6.el7          
  libverto-devel.x86_64 0:0.2.5-4.el7               

作為依賴被升級:
  e2fsprogs.x86_64 0:1.42.9-10.el7               e2fsprogs-libs.x86_64 0:1.42.9-10.el7          
  krb5-libs.x86_64 0:1.15.1-8.el7                libcom_err.x86_64 0:1.42.9-10.el7              
  libselinux.x86_64 0:2.5-11.el7                 libselinux-python.x86_64 0:2.5-11.el7          
  libselinux-utils.x86_64 0:2.5-11.el7           libss.x86_64 0:1.42.9-10.el7                   
  openssl.x86_64 1:1.0.2k-8.el7                  openssl-libs.x86_64 1:1.0.2k-8.el7             

完畢!
[[email protected] php-5.6.30]# 


再繼續 編譯 ./configure

完畢!
[[email protected] 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



checking for gzgets in -lz... yes
checking whether to enable bc style precision math functions... no
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
[[email protected] php-5.6.30]# 
```
- 又出來一個新的錯誤  configure: error: Please reinstall the BZip2 distribution







# 11.11安裝PHP5 中
- 繼續上面的錯誤configure: error: Please reinstall the BZip2 distribution
```
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
[[email protected] php-5.6.30]# yum install -y bzip2-devel


已安裝:
  bzip2-devel.x86_64 0:1.0.6-13.el7                                                             

完畢!
[[email protected] php-5.6.30]# 
```
- 再來繼續編譯./configure
```
[[email protected] 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




checking whether to enable truetype string function in GD... yes
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.
[[email protected] php-5.6.30]# 
```
- 又出錯了error: jpeglib.h not found.
```
[[email protected] php-5.6.30]# yum install -y libjpeg-devel


已安裝:
  libjpeg-turbo-devel.x86_64 0:1.2.90-5.el7                                                     

完畢!
[[email protected] php-5.6.30]# 
```
- 再繼續編譯./configure
```
[[email protected] 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



If configure fails try --with-vpx-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
[[email protected] php-5.6.30]# 



If configure fails try --with-vpx-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
[[email protected] php-5.6.30]# 
```
- 又報錯了error: png.h not found,這次是要安裝png
```
[[email protected] php-5.6.30]# yum install -y libpng-devel


已安裝:
  libpng-devel.x86_64 2:1.5.13-7.el7_2                                                          

完畢!
[[email protected] php-5.6.30]# 
```
- 繼續
```

完畢!
[[email protected] 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



If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
[[email protected] php-5.6.30]# 
```
- 又報錯 error: freetype-config not found
```
[[email protected] php-5.6.30]# yum install -y freetype-devel


已安裝:
  freetype-devel.x86_64 0:2.4.11-15.el7                                                         

作為依賴被升級:
  freetype.x86_64 0:2.4.11-15.el7                                                               

完畢!
[[email protected] php-5.6.30]# 
```
- 繼續./configure
```

完畢!
[[email protected] 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



checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[[email protected] php-5.6.30]# 
```
- 又報錯了error: mcrypt.h not found. Please reinstall libmcrypt.
- 安裝這個mcrypt , mcrypt庫 在epel擴展源裏面,所以想要安裝mcrypt 先需要先安裝epel 擴展源(yum install epel-release), 
```
[[email protected] php-5.6.30]# yum install libmcrypt-devel

依賴關系解決

================================================================================================
 Package                     架構               版本                     源                大小
================================================================================================
正在安裝:
 libmcrypt-devel             x86_64             2.5.8-13.el7             epel              13 k
為依賴而安裝:
 libmcrypt                   x86_64             2.5.8-13.el7             epel              99 k

事務概要
================================================================================================
安裝  1 軟件包 (+1 依賴軟件包)

總下載量:112 k
安裝大小:302 k
Is this ok [y/d/N]: y


已安裝:
  libmcrypt-devel.x86_64 0:2.5.8-13.el7                                                         

作為依賴被安裝:
  libmcrypt.x86_64 0:2.5.8-13.el7                                                               

完畢!
[[email protected] php-5.6.30]# 

```
- 再來一次
```
[[email protected] 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



creating libtool
appending configuration tag "CXX" to libtool

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[[email protected] php-5.6.30]# 

[[email protected] php-5.6.30]# echo $?
0
[[email protected] php-5.6.30]# 

```

- 成功了!
- 下一步接著就是 make  這一步花費的時間長一點










# 11.12安裝PHP5 下
```
[[email protected] php-5.6.30]# make


Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP‘s phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
invertedregexiterator.inc
directorygraphiterator.inc
pharcommand.inc
phar.inc

Build complete.
Don‘t forget to run ‘make test‘.

[[email protected] php-5.6.30]# 
```
- 最後一步 make install 
```

Build complete.
Don‘t forget to run ‘make test‘.

[[email protected] php-5.6.30]# make install


Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/usr/local/src/php-5.6.30/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:           /usr/local/php/include/php/ext/pdo/
[[email protected] php-5.6.30]# 
```
- 看下php的目錄
```
[[email protected] php-5.6.30]# ls /usr/local/php/
bin  etc  include  lib  php
核心的二進制文件
[[email protected] php-5.6.30]# ls /usr/local/php/bin/
pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpize
[[email protected] php-5.6.30]# du -sh /usr/local/php/bin/php
36M	/usr/local/php/bin/php
[[email protected] php-5.6.30]# 
```
```
[[email protected] php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 
37M	/usr/local/apache2.4/modules/libphp5.so
[[email protected] php-5.6.30]# 
```
- 這個/usr/local/apache2.4/modules/libphp5.so 就是我們想要的模塊,php和apache結合起來是通過這個文件實現的

- 看一看php所加載的模塊都有哪些 ,查看它加載模塊的一個命令,這全是靜態的
- /usr/local/php/bin/php -m  這個和httpd -M類似的功能
```
[[email protected] php-5.6.30]# /usr/local/php/bin/php -m
[PHP Modules]
bz2
Core
ctype
date
dom
ereg
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

[[email protected] php-5.6.30]# 
```

- 那php 需不需要啟動?
![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170927/225931610.png?imageslim)

php 作為apache的模塊存在的,
看看apache的模塊
```
[[email protected] php-5.6.30]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using fe80::a152:bbdf:8b2b:db9b. Set the ‘ServerName‘ directive globally to suppress this message
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
[[email protected] php-5.6.30]# 
```
-  這個就是它的模塊文件
```
[[email protected] php-5.6.30]# ls -l /usr/local/apache2.4/modules/libphp5.so 
-rwxr-xr-x 1 root root 37752696 9月  27 22:45 /usr/local/apache2.4/modules/libphp5.so
[[email protected] php-5.6.30]# 
```

-  這個是Apache的配置文件,打開它
-  如果不想用哪個模塊,直接把它註釋掉 前面加個#就行 ,隨用隨取
```

[[email protected] php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf


LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule info_module modules/mod_info.so
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module        modules/libphp5.so

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
```

- 接下來 把配置文件php.ini-prodution 這是它的一個參考配置文件 拷貝到/usr/local/php/etc/php.ini

- 為什麽要放在這 ?   因為之前定義了這個位置,


- 使用-i 可以查看詳細信息,參數
```

[[email protected] php-5.6.30]# /usr/local/php/bin/php -i |less




phpinfo()
PHP Version => 5.6.30

System => Linux aminglinux-001 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64
Build Date => Sep 27 2017 22:41:39
Configure Command =>  ‘./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‘
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => (none)
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20131106
PHP Extension => 20131226
Zend Extension => 220131226
Zend Extension Build => API220131226,TS
PHP Extension Build => API20131226,TS
Debug Build => no
```
-可以看到Loaded Configuration File => (none)


- 把php.ini-production 生產環境中 這個文件拷貝到 /usr/local/php/etc/php.ini
```
[[email protected] php-5.6.30]# ls -l /usr/local/apache2.4/modules/libphp5.so 
-rwxr-xr-x 1 root root 37752696 9月  27 22:45 /usr/local/apache2.4/modules/libphp5.so
[[email protected] php-5.6.30]# vi /usr/local/apache2.4/conf/httpd.conf
[[email protected] php-5.6.30]# /usr/local/php/bin/php -i |less
[[email protected] php-5.6.30]# ls /usr/local/php/etc
pear.conf
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini
[[email protected] php-5.6.30]# /usr/local/php/bin/php -i|less
````


```
System => Linux aminglinux-001 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64
Build Date => Sep 27 2017 22:41:39
Configure Command =>  ‘./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‘
Server API => Command Line Interface
Virtual Directory Support => enabled
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr/local/php/etc/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
PHP API => 20131106
PHP Extension => 20131226
Zend Extension => 220131226
Zend Extension Build => API220131226,TS
:...skipping...
```
-  現在有了加載的配置文件 Loaded Configuration File => /usr/local/php/etc/php.ini





# 11.13 安裝PHP 7



-  cd /usr/local/src/ 
-  wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
-  tar zxf php-7.1.6.tar.bz2
-  cd php-7.1.6
-  ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc  --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
-  make && make install
-  ls /usr/local/apache2.4/modules/libphp7.so
-  cp php.ini-production  /usr/local/php7/etc/php.ini

```
[[email protected] php-5.6.30]# cd ..
[[email protected] src]# 

[[email protected] src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
--2017-09-27 23:40:28--  http://cn2.php.net/distributions/php-7.1.6.tar.bz2
```
- 解壓
```
[[email protected] src]# tar jxvf php-7.1.6.tar.bz2 

php-7.1.6/win32/winutil.c
php-7.1.6/win32/ioutil.c
php-7.1.6/win32/fnmatch.h
php-7.1.6/win32/ftok.c
php-7.1.6/win32/select.c
[[email protected] src]# 
```
- cd php-7.1.6/
- ./configure
```
[[email protected] src]# cd php-7.1.6/
[[email protected] php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc  --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








creating libtool
appending configuration tag "CXX" to libtool

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[[email protected] php-7.1.6]# 

```
- make 這個時間有點長 要10多分鐘
```
[[email protected] php-7.1.6]# make


Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP‘s phar extension be enabled.
directorytreeiterator.inc
directorygraphiterator.inc
pharcommand.inc
clicommand.inc
invertedregexiterator.inc
phar.inc

Build complete.
Don‘t forget to run ‘make test‘.

[[email protected] php-7.1.6]# 
```

-  make install
```
[[email protected] php-7.1.6]# make install


Installing man pages:             /usr/local/php7/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php7/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.2
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.4.2
[PEAR] PEAR           - installed: 1.10.4
Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
You may want to add: /usr/local/php7/lib/php to your php.ini include_path
/usr/local/src/php-7.1.6/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:           /usr/local/php7/include/php/ext/pdo/
[[email protected] php-7.1.6]# 
```

```
[[email protected] php-7.1.6]# ls /usr/local/apache2.4/modules/libphp7.so 
/usr/local/apache2.4/modules/libphp7.so
[[email protected] php-7.1.6]# du -sh !$
du -sh /usr/local/apache2.4/modules/libphp7.so
37M	/usr/local/apache2.4/modules/libphp7.so
[[email protected] php-7.1.6]# 


[[email protected] php-7.1.6]# /usr/local/php7/bin/php -m
[PHP Modules]
bz2
Core
ctype
date
dom
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysqli
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

[[email protected] php-7.1.6]# 
```
- 可以看下
```
[[email protected] php-7.1.6]# !vim
vim /etc/init.d/mariadb


    # Safeguard (relative paths, core dumps..)
    cd $basedir

    echo $echo_n "Starting MySQL"
    if test -x $bindir/mys


[[email protected] php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
#LoadModule authz_dbd_module modules/mod_authz_dbd.so
LoadModule autoindex_module modules/mod_autoindex.so
#LoadModule info_module modules/mod_info.so
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
#LoadModule actions_module modules/mod_actions.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php5_module        modules/libphp5.so
LoadModule php7_module        modules/libphp7.so

<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
                                                                            150,12        28%
```

- LoadModule php5_module        modules/libphp5.so
  LoadModule php7_module        modules/libphp7.so
- 不想用哪個可以註釋掉哪個







- 擴展
- php中mysql,mysqli,mysqlnd,pdo到底是什麽
- http://blog.csdn.net/u013785951/article/details/60876816
名詞解釋:

最開始的初學者,往往搞不清mysqli,mysqlnd,pdo到底是什麽,下面先直接貼出最直觀的名字吧。
```
MYSQL:This extension is deprecated as of PHP 5.5.0, and has been removed as of PHP 7.0.0. 
MYSQLI: MySQL Improved Extension 
MySQLND: MySQL Native Drive 
PDO:The PHP Data Objects。extension defines a lightweight, consistent interface for accessing databases in PHP。
以上摘自 PHP官方手冊: http://php.net/manual/en/book.mysqli.php

用中文說: 
MYSQL 也叫 Original MySQL,PHP4版本的MYSQL擴展,從PHP5起已經被廢棄,並別從PHP7開始已經被移除。

MYSQLI 叫做 “MySQL增強擴展”。

MYSQLND MYSQL NATIVE DIRVER 叫做MYSQL “官方驅動”或者更加直接點的叫做“原生驅動”

PDO PHP Data Objects PHP數據對象,是PHP應用中的一個數據庫抽象層規範。
```
針對本篇文章

再補充幾個名詞解釋:

1 什麽是API?

一個應用程序接口(Application Programming Interface的縮寫),定義了類,方法,函數,變量等等一切 你的應用程序中為了完成特定任務而需要調用的內容。在PHP應用程序需要和數據庫進行交互的時候所需要的API 通常是通過PHP擴展暴露出來(給終端PHP程序員調用)。
上文所說的MYSQL 和MYSQLI擴展就提供了這樣的API。

2什麽是驅動?

驅動是一段設計用來於一種特定類型的數據庫服務器進行交互的軟件代碼。驅動可能會調用一些庫,比如MySQL客戶端庫或者MySQL Native驅動庫。 這些庫實現了用於和MySQL數據庫服務器進行交互的底層協議。
在PHP拓展的角度上看,MYSQL和MYSQLi還是比較上層的拓展,依賴更底層的庫去連接和訪問數據庫。 
上文所說的MYSQLND 就是所說的底層的數據庫驅動。當然,還有一個驅動叫做libmysqlclient。至於如何選擇使用這兩種驅動的哪一種,請看這裏選擇哪一種底層數據庫驅動。

總的來說:

從應用的層面上看,我們通過PHP 的MYSQL或者MYSQLi擴展提供的API去操作數據庫。

從底層來看,MYSQLND提供了底層和數據庫交互的支持(可以簡單理解為和MySQL server進行網絡協議交互)。

而PDO,則提供了一個統一的API接口,使得你的PHP應用不去關心具體要連接的數據庫服務器系統類型。也就是說,如果你使用PDO的API,可以在任何需要的時候無縫切換數據庫服務器。比如MYSQL,SQLITE任何數據庫都行。

即從大部分功能上看,PDO提供的API接口和MYSQLI提供的接口對於普通的增刪改查效果是一致的。

最後貼下代碼:

MYSQL連接:
```
<?php

$conn = @ mysql_connect("localhost", "root", "") or die("數據庫連接錯誤");

mysql_select_db("bbs", $conn);

mysql_query("set names ‘utf8‘");

echo "數據庫連接成功";

?>
1
2
3
4
5
6
7
8
9
10
11
MYSQLI連接:

<?php

$conn = mysqli_connect(‘localhost‘, ‘root‘, ‘‘, ‘bbs‘);

if(!$conn){

die("數據庫連接錯誤" . mysqli_connect_error());

}else{

echo"數據庫連接成功";

}

?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
PDO連接:

<?php

try{

$pdo=new pdo("mysql:host=localhost;dbname=bbs","root","");

}catch(PDDException $e){

echo"數據庫連接錯誤";

}

echo"數據庫連接成功";

?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
想更多去了解他們的區別和聯系,可以手動去編譯一下PHP的源代碼。註意參數

--enable-pdo 
--with-pdo-mysql
--enable-mysqlnd 
--with-mysqli
--with-mysql//php7的已經不再支持,此參數configure 的時候會報ERROR

```
- 查看編譯參數 http://ask.apelearn.com/question/1295


11.10/11.11/11.12 安裝PHP511.13安裝PHP7