美文网首页我爱编程
安装PHP5、安装php7

安装PHP5、安装php7

作者: 强出头 | 来源:发表于2018-04-11 23:49 被阅读0次

安装PHP5

安装PHP5
[root@wsl-001 ~]# cd /usr/local/src/
[root@wsl-001 src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
[root@wsl-001 src]# tar zxvf php-5.6.30.tar.gz 
[root@wsl-001 src]# cd php-5.6.30/
[root@wsl-001 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

如果出现错误
configure: error: Cannot find OpenSSL's <evp.h>
[root@wsl-001 php-5.6.30]# yum install openssl openssl-devel
configure: error: Please reinstall the BZip2 distribution
[root@wsl-001 php-5.6.30]# yum install bzip2 bzip2-devel
configure: error: jpeglib.h not found.
[root@wsl-001 php-5.6.30]# yum -y install libjpeg-devel
configure: error: png.h not found.
[root@wsl-001 php-5.6.30]# yum install libpng
[root@wsl-001 php-5.6.30]# yum install libpng-devel
configure: error: freetype-config not found.
[root@wsl-001 php-5.6.30]# yum install freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[root@wsl-001 php-5.6.30]# yum install libmcrypt libmcrypt-devel



[root@wsl-001 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
[root@wsl-001 php-5.6.30]# echo $?
0
[root@wsl-001 php-5.6.30]# make && make install
[root@wsl-001 php-5.6.30]# echo $?
0
[root@wsl-001 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]

[root@wsl-001 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::20c:29ff:fe45:ec93. 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)
 php5_module (shared)  (php支持模块)
[root@wsl-001 php-5.6.30]# vim  /usr/local/apache2.4/conf/httpd.conf
[root@wsl-001 php-5.6.30]# cp php.ini-production /usr/local/php/etc/php.ini 
(线上环境用php.ini-production,开发环境用 php.ini-development)
模块随用随取

安装php7

安装php7
[root@wsl-001 php-7.1.6]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
[root@wsl-001 php-7.1.6]# tar jvxf php-7.1.6.tar.bz2
[root@wsl-001 php-7.1.6]# cd php-7.1.6/
[root@wsl-001 php-7.1.6]# ./configure --help #查看编译参数
[root@wsl-001 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
[root@wsl-001 php-7.1.6]# make && make install
[root@wsl-001 php-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini

查看php相关

[root@wsl-001 php-7.1.6]# ls /usr/local/apache2.4/modules/libphp
libphp5.so  libphp7.so 
(查看加载模块)
[root@wsl-001 php-7.1.6]# /usr/local/php7/bin/php -m
[root@wsl-001 php-7.1.6]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe45:ec93. 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)
 php5_module (shared)
 php7_module (shared)

更改Apache使用的php

[root@wsl-001 php-7.1.6]# vim /usr/local/apache2.4/conf/httpd.conf
LoadModule php5_module        modules/libphp5.so
LoadModule php7_module        modules/libphp7.so

总结了一些常见的configure错误信息和解决这些错误的经验。

1、configure: error: No curses/termcap library found
网上有的说法是:–with-named-curses-libs=/usr/lib/libncursesw.so.5
其实是不对的,虽然能解决configure的错误,但是make的时候会提示错误,正确的做法应该是
centos: yum -y install ncurses-devel
debian: apt-get install libncurses5-dev
2、configure: error: xml2-config not found. Please check your libxml2 installation.
centos: yum -y install libxml2 libxml2-devel
debian: apt-get install libxml2-dev
3、configure: error: Cannot find OpenSSL’s
centos: yum -y install openssl-devel
4、configure: error: libjpeg.(a|so) not found
centos: yum -y install gd
centos: yum -y install gd-devel
debian: apt-get install libjpeg-dev
5、configure: error: libpng.(a|so) not found.
apt-get install libpng12-dev
6、configure: error: cannot find output from lex; giving up
yum -y install flex
7、configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev
8、configure: error: libxpm.(a|so) not found.
centos: yum -y install libxpm-dev
debian: apt-get install libxpm-dev
9、configure: error: freetype.h not found.
centos: yum install freetype-devel
debian: apt-get install libfreetype6-dev
10、configure: error: …No recognized SSL/TLS toolkit detected
centos: yum -y install libssl-dev
debian: apt-get install libssl-dev
11、Configure: error: Please reinstall the BZip2 distribution
centos: yum install bzip2 bzip2-devel
debian: apt-get install bzip2-devel
12、Configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/
centos: yum install curl curl-devel (For Redhat & Fedora)

install libcurl4-gnutls-dev (For Ubuntu)

13、Configure: error: Unable to locate gmp.h
centos: yum install gmp-devel
14、Configure: error: Cannot find MySQL header files under /usr. Note that the MySQL client library is not bundled anymore!
yum install mysql-devel (For Redhat & Fedora)

apt-get install libmysql++-dev (For Ubuntu)

15、Configure: error: Please reinstall the ncurses distribution
Solutions :
centos: yum install ncurses ncurses-devel
16、Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solutions :
centos: yum install unixODBC-devel
17、Configure: error: Cannot find pspell
Solutions :
centos: yum install pspell-devel
18、configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Solutions :
yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)

apt-get install libmcrypt-dev

19、Configure: error: snmp.h not found. Check your SNMP installation.
Solutions :
yum install net-snmp net-snmp-devel
20、开启LDAP服务还需要
yum -y install openldap-devel openldap-servers openldap-clients
21、configure: error: cannot find output from lex; giving up
centos: yum -y install flex
22、configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
centos: yum -y install zlib-devel openssl-devel
debian: apt-get install zlib1g-dev

扩展
php中mysql,mysqli,mysqlnd,pdo到底是什么 http://blog.csdn.net/u013785951/article/details/60876816
查看编译参数 http://ask.apelearn.com/question/1295

相关文章

网友评论

    本文标题:安装PHP5、安装php7

    本文链接:https://www.haomeiwen.com/subject/apczhftx.html