39.安装PH5-PH7

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/11.11/11.12 安装PHP5:

PHP官网www.php.net

当前主流版本为5.6/7.1

有些过老的版本可能不兼容7版本。7的性能比5有很大的提升

cd /usr/local/src/

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

tar zxf php-5.6.32.tar.gz

cd php-5.6.32

./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=/usr/local/php 指定安装目录

--with-apxs2 apxs2是Apache的一种工具,可以自动的把扩展的模块放到Apache的目录里,就是在我们用httpd -M的时候可以加载出来。阿鑫在做的时候,修改了他的路径(find一下apxs2,查到目录,修改一下就可以了)

--with-config-file-path=/usr/local/php/etc 指定php的配置文件

--with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config 指定这三种mysql不同的库。相当于php与mysql相互通信的驱动,所以是定义mysql的函数或者驱动的

后面的都是指定php的模块的

make && make install

cp php.ini-production /usr/local/php/etc/php.ini 我们指定了他的配置文件,要拷贝到那里去( --with-config-file-path).。如果是开发环境就用 php.ini-development,php.ini-production用于生产环境

知识点:

/usr/local/php/bin/ PHP的核心文件

/usr/local/apache2.4/modules/libphp5.so 这是我们安装php5的模块。我们需要的

/usr/local/php/bin/ -m 查看php加载的模块有哪些(静态的)。是可以扩展的,增加.so的文件

/usr/local/apache2.4/bin/httpd -M 可以查看Apache的模块。最后就是我们安装的php5的模块

php作为Apache的扩展模块存在的。也就是说Apache需要借助php module,也就是借助这个.so的文件

vim /usr/local/apache2.4/conf/httpd.conf 可以查看Apache的模块。php也在其中

实例:

[root@localhost]# cd /usr/local/src

[root@localhost src]# wget http://cn2.php.net/distributions/php-5.6.32.tar.gz

[root@localhost src]#tar zxf php-5.6.32.tar.gz

[root@localhost src]# cd php-5.6.32/

[root@localhost php-5.6.32]# ./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

以下的几个报错,安装PH5.6.32

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

#yum install -y libxml2-devel

2.configure: error: Cannot find OpenSSL's <evp.h>
#yum install -y openssl-devel

3.configure: error: Please reinstall the BZip2 distribution

#yum install -y bzip2 bzip2-devel

4.configure: error: jpeglib.h not found.
#yum -y install libjpeg-devel

5.configure: error: png.h not found.

#yum install -y libpng libpng-devel

6.configure: error: freetype-config not found.

#yum install -y freetype freetype-devel

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

#yum install -y epel-release

#yum install -y libmcrypt-devel

编译完成

1Thank you for using PHP. 2 3config.status: creating php5.spec 4config.status: creating main/build-defs.h 5config.status: creating scripts/phpize 6config.status: creating scripts/man1/phpize.1 7config.status: creating scripts/php-config 8config.status: creating scripts/man1/php-config.1 9config.status: creating sapi/cli/php.1 10config.status: creating sapi/cgi/php-cgi.1 11config.status: creating ext/phar/phar.1 12config.status: creating ext/phar/phar.phar.1 13config.status: creating main/php_config.h 14config.status: executing default commands

安装PH7提示报错

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
 

#yum install -y perl* 

​#yum install -y httpd-devel

#find / -name apxs  得到的路径是:/usr/sbin/apxs

于是修改--with-apsx2=/usr/sbin/apxs指定到正确路径

还有n个报错,都是缺少一些库。安装就好了

[root@localhost php-5.6.32]# echo $? 直到成功。configure成功

0

[root@localhost php-5.6.32]# make 开始make

1xt/standard/crypt_blowfish.lo ext/standard/crypt_sha512.lo ext/standard/crypt_sha256.lo ext/standard/php_crypt_r.lo ext/standard/array.lo ext/standard/base64.lo ext/standard/basic_functions.lo ext/standard/browscap.lo ext/standard/crc32.lo ext/standard/crypt.lo ext/standard/cyr_convert.lo ext/standard/datetime.lo ext/standard/dir.lo ext/standard/dl.lo ext/standard/dns.lo ext/standard/exec.lo ext/standard/file.lo ext/standard/filestat.lo ext/standard/flock_compat.lo ext/standard/formatted_print.lo ext/standard/fsock.lo ext/standard/head.lo ext/standard/html.lo ext/standard/image.lo ext/standard/info.lo ext/standard/iptc.lo ext/standard/lcg.lo ext/standard/link.lo ext/standard/mail.lo ext/standard/math.lo ext/standard/md5.lo ext/standard/metaphone.lo ext/standard/microtime.lo ext/standard/pack.lo ext/standard/pageinfo.lo ext/standard/quot_print.lo ext/standard/rand.lo ext/standard/soundex.lo ext/standard/string.lo ext/standard/scanf.lo ext/standard/syslog.lo ext/standard/type.lo ext/standard/uniqid.lo ext/standard/url.lo ext/standard/var.lo ext/standard/versioning.lo ext/standard/assert.lo ext/standard/strnatcmp.lo ext/standard/levenshtein.lo ext/standard/incomplete_class.lo ext/standard/url_scanner_ex.lo ext/standard/ftp_fopen_wrapper.lo ext/standard/http_fopen_wrapper.lo ext/standard/php_fopen_wrapper.lo ext/standard/credits.lo ext/standard/css.lo ext/standard/var_unserializer.lo ext/standard/ftok.lo ext/standard/sha1.lo ext/standard/user_filters.lo ext/standard/uuencode.lo ext/standard/filters.lo ext/standard/proc_open.lo ext/standard/streamsfuncs.lo ext/standard/http.lo ext/standard/password.lo ext/tokenizer/tokenizer.lo ext/tokenizer/tokenizer_data.lo ext/xml/xml.lo ext/xml/compat.lo ext/xmlreader/php_xmlreader.lo ext/xmlwriter/php_xmlwriter.lo TSRM/TSRM.lo TSRM/tsrm_strtok_r.lo main/main.lo main/snprintf.lo main/spprintf.lo main/php_sprintf.lo main/fopen_wrappers.lo main/alloca.lo main/php_scandir.lo main/php_ini.lo main/SAPI.lo main/rfc1867.lo main/php_content_types.lo main/strlcpy.lo main/strlcat.lo main/mergesort.lo main/reentrancy.lo main/php_variables.lo main/php_ticks.lo main/network.lo main/php_open_temporary_file.lo main/output.lo main/getopt.lo main/streams/streams.lo main/streams/cast.lo main/streams/memory.lo main/streams/filter.lo main/streams/plain_wrapper.lo main/streams/userspace.lo main/streams/transports.lo main/streams/xp_socket.lo main/streams/mmap.lo main/streams/glob_wrapper.lo Zend/zend_language_parser.lo Zend/zend_language_scanner.lo Zend/zend_ini_parser.lo Zend/zend_ini_scanner.lo Zend/zend_alloc.lo Zend/zend_compile.lo Zend/zend_constants.lo Zend/zend_dynamic_array.lo Zend/zend_dtrace.lo Zend/zend_execute_API.lo Zend/zend_highlight.lo Zend/zend_llist.lo Zend/zend_vm_opcodes.lo Zend/zend_opcode.lo Zend/zend_operators.lo Zend/zend_ptr_stack.lo Zend/zend_stack.lo Zend/zend_variables.lo Zend/zend.lo Zend/zend_API.lo Zend/zend_extensions.lo Zend/zend_hash.lo Zend/zend_list.lo Zend/zend_indent.lo Zend/zend_builtin_functions.lo Zend/zend_sprintf.lo Zend/zend_ini.lo Zend/zend_qsort.lo Zend/zend_multibyte.lo Zend/zend_ts_hash.lo Zend/zend_stream.lo Zend/zend_iterators.lo Zend/zend_interfaces.lo Zend/zend_exceptions.lo Zend/zend_strtod.lo Zend/zend_gc.lo Zend/zend_closures.lo Zend/zend_float.lo Zend/zend_string.lo Zend/zend_signal.lo Zend/zend_generators.lo Zend/zend_virtual_cwd.lo Zend/zend_ast.lo Zend/zend_objects.lo Zend/zend_object_handlers.lo Zend/zend_objects_API.lo Zend/zend_default_classes.lo Zend/zend_execute.lo main/internal_functions_cli.lo sapi/cgi/cgi_main.lo sapi/cgi/fastcgi.lo -lcrypt -lresolv -lcrypt -lrt -lmysqlclient_r -lmcrypt -lpng -lz -ljpeg -lbz2 -lz -lrt -lm -ldl -lnsl -lxml2 -lz -lm -ldl -lssl -lcrypto -lxml2 -lz -lm -ldl -lfreetype -lmysqlclient -lm -lrt -ldl -lmysqlclient -lm -lrt -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt -o sapi/cgi/php-cgi 2Generating phar.php 3Generating phar.phar 4PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. 5clicommand.inc 6directorytreeiterator.inc 7invertedregexiterator.inc 8directorygraphiterator.inc 9pharcommand.inc 10phar.inc 11 12Build complete. 13Don't forget to run 'make test'.

[root@localhost php-5.6.32]# echo $? 查看是否成功

0

[root@localhost php-5.6.32]# make install

1Installing PEAR environment: /usr/local/php/lib/php/ 2[PEAR] Archive_Tar - installed: 1.4.3 3[PEAR] Console_Getopt - installed: 1.4.1 4[PEAR] Structures_Graph- installed: 1.1.1 5[PEAR] XML_Util - installed: 1.4.2 6[PEAR] PEAR - installed: 1.10.5 7Wrote PEAR system config file at: /usr/local/php/etc/pear.conf 8You may want to add: /usr/local/php/lib/php to your php.ini include_path 9/usr/local/src/php-5.6.32/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin 10ln -s -f phar.phar /usr/local/php/bin/phar 11Installing PDO headers: /usr/local/php/include/php/ext/pdo/

[root@localhost php-5.6.32]# echo $? 查看是否成功

0

[root@localhost php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini

!!阿鑫在./configure的时候,因为--with exps的路径写错了。阿鑫的电脑路径是apache2,跟着阿铭老师写了2.4结果导致不成功。这点需要注意

----------------------------------------------------------------------------------------------------------------------------------------------------

11.13 安装PHP7:

cd /usr/local/src/

wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

tar xjvf php-7.1.6.tar.bz2 //tar -xvf axin.tar 解包,后面跟打包名

tar zxf php-7.1.6.tar.bz2 (报错,z : 表示 tar 包是被 gzip 压缩过的,所以解压时需要用 gunzip 解压

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

1Thank you for using PHP. 2 3config.status: creating php7.spec 4config.status: creating main/build-defs.h 5config.status: creating scripts/phpize 6config.status: creating scripts/man1/phpize.1 7config.status: creating scripts/php-config 8config.status: creating scripts/man1/php-config.1 9config.status: creating sapi/cli/php.1 10config.status: creating sapi/cgi/php-cgi.1 11config.status: creating ext/phar/phar.1 12config.status: creating ext/phar/phar.phar.1 13config.status: creating main/php_config.h 14config.status: executing default commands

make

1Generating phar.php 2Generating phar.phar 3PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled. 4directorytreeiterator.inc 5directorygraphiterator.inc 6pharcommand.inc 7clicommand.inc 8invertedregexiterator.inc 9phar.inc 10 11Build complete. 12Don't forget to run 'make test'.

&& make install

1Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf 2You may want to add: /usr/local/php7/lib/php to your php.ini include_path 3/usr/local/src/php-7.1.6/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin 4ln -s -f phar.phar /usr/local/php7/bin/phar 5Installing PDO headers: /usr/local/php7/include/php/ext/pdo/

ls /usr/local/apache2.4/modules/libphp7.so

/usr/local/apache2.4/modules/libphp7.so

cp php.ini-production /usr/local/php7/etc/php.ini 解释跟php5一样

ls /usr/local/apache2.4/modules 下就有libphp7.so。查看Apache的模块

1libphp5.so mod_authn_dbm.so mod_cache_disk.so mod_file_cache.so mod_macro.so mod_proxy_scgi.so mod_session.so mod_userdir.so 2libphp7.so mod_authn_file.so mod_cache.so mod_filter.so mod_mime.so mod_proxy.so mod_setenvif.so mod_version.so 3mod_access_compat.so mod_authn_socache.so mod_cache_socache.so mod_headers.so mod_negotiation.so mod_proxy_uwsgi.so mod_slotmem_shm.so mod_vhost_alias.so 4mod_actions.so mod_authz_core.so mod_cgid.so mod_include.so mod_proxy_ajp.so mod_proxy_wstunnel.so mod_socache_dbm.so mod_watchdog.so 5mod_alias.so mod_authz_dbd.so mod_dav_fs.so mod_info.so mod_proxy_balancer.so mod_ratelimit.so mod_socache_memcache.so 6mod_allowmethods.so mod_authz_dbm.so mod_dav.so mod_lbmethod_bybusyness.so mod_proxy_connect.so mod_remoteip.so mod_socache_redis.so 7mod_auth_basic.so mod_authz_groupfile.so mod_dbd.so mod_lbmethod_byrequests.so mod_proxy_express.so mod_reqtimeout.so mod_socache_shmcb.so 8mod_auth_digest.so mod_authz_host.so mod_dir.so mod_lbmethod_bytraffic.so mod_proxy_fcgi.so mod_request.so mod_speling.so 9mod_auth_form.so mod_authz_owner.so mod_dumpio.so mod_lbmethod_heartbeat.so mod_proxy_fdpass.so mod_rewrite.so mod_status.so 10mod_authn_anon.so mod_authz_user.so mod_env.so mod_log_config.so mod_proxy_ftp.so mod_sed.so mod_substitute.so 11mod_authn_core.so mod_autoindex.so mod_expires.so mod_log_debug.so mod_proxy_hcheck.so mod_session_cookie.so mod_unique_id.so

/usr/local/php7/bin/php -m 查看php7加载的模块

1dom 2exif 3fileinfo 4filter 5gd 6hash 7iconv 8json 9libxml 10mbstring 11mcrypt 12mysqli 13openssl 14pcre 15PDO 16pdo_mysql 17pdo_sqlite 18Phar 19posix 20Reflection 21session 22SimpleXML 23soap 24sockets 25SPL 26sqlite3 27standard 28tokenizer 29xml 30xmlreader 31xmlwriter 32zlib 33 34[Zend Modules]

/usr/local/apache2.4/bin/apachectl -M 查看Apache加载了几个php。最下面就是php7和php5

1AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message 2Loaded Modules: 3 core_module (static) 4 so_module (static) 5 http_module (static) 6 mpm_event_module (static) 7 authn_file_module (shared) 8 authn_core_module (shared) 9 authz_host_module (shared) 10 authz_groupfile_module (shared) 11 authz_user_module (shared) 12 authz_core_module (shared) 13 access_compat_module (shared) 14 auth_basic_module (shared) 15 reqtimeout_module (shared) 16 filter_module (shared) 17 mime_module (shared) 18 log_config_module (shared) 19 env_module (shared) 20 headers_module (shared) 21 setenvif_module (shared) 22 version_module (shared) 23 unixd_module (shared) 24 status_module (shared) 25 autoindex_module (shared) 26 dir_module (shared) 27 alias_module (shared) 28 php5_module (shared) 29 php7_module (shared)

我们如何在PHP7和PHP5之间选择切换,修改配置文件:

vim /usr/local/apache2.4/conf/httpd.conf 在里面找到PHP5或PHP7(可/ 搜索php5.so),前面加#注释,注释掉这一个,就是使用另一个

#LoadModule php5_module modules/libphp5.so

LoadModule php7_module modules/libphp7.so

实例:

[root@localhost ~]# cd /usr/local/src

[root@localhost src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2

[root@localhost src]# ls

[root@localhost src]# tar -jxvf php-7.1.6.tar.bz2

[root@localhost src]# ls

apr-1.6.3 apr-util-1.6.1.tar.gz mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz php-5.6.32.tar.bz2

apr-1.6.3.tar.gz httpd-2.4.34 mysql-5.6.39-linux-glibc2.12-x86_64.tar.gz php-7.1.6

apr-util-1.6.1 httpd-2.4.34.tar.gz php-5.6.32 php-7.1.6.tar.bz2

[root@localhost src]# cd php-7.1.6/

[root@localhost php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2/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

[root@localhost php-7.1.6]# echo $?

0

[root@localhost php-7.1.6]# make

[root@localhost php-7.1.6]# echo $?

0

[root@localhost php-7.1.6]# make install

[root@localhost php-7.1.6]# echo $?

0

[root@localhostphp-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )