安裝PHP5、安裝php7

安裝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

如果出現(xiàn)錯誤
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 
(線上環(huán)境用php.ini-production,開發(fā)環(huán)境用 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 #查看編譯參數(shù)
[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相關(guān)

[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

總結(jié)了一些常見的configure錯誤信息和解決這些錯誤的經(jīng)驗。

1、configure: error: No curses/termcap library found
網(wǎng)上有的說法是:–with-named-curses-libs=/usr/lib/libncursesw.so.5
其實是不對的,雖然能解決configure的錯誤,但是make的時候會提示錯誤,正確的做法應(yīng)該是
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服務(wù)還需要
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

擴(kuò)展
php中mysql,mysqli,mysqlnd,pdo到底是什么 http://blog.csdn.net/u013785951/article/details/60876816
查看編譯參數(shù) http://ask.apelearn.com/question/1295

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容