安装php5
一.下载:
wget http://cn2.php.net/distributions/php-5.4.45.tar.bz2
二.解压
tar -jxvf php-5.4.45.tar.bz2
三.配置编译参数:
[root@localhost src]# cd php-5.4.45
[root@localhost php-5.4.45]# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=/usr/local/mysql \
--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 \
--disable-ipv6
在这一步,遇到如下错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
解决办法是:
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel
还有错误:
configure: error: Cannot find OpenSSL's
解决办法是:
yum install -y openssl openssl-devel
错误:
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
解决办法:
yum install -y bzip2 bzip2-devel
错误:
configure: error: png.h not found.
解决办法:
yum install -y libpng libpng-devel
错误:
configure: error: freetype.h not found.
解决办法:
yum install -y freetype freetype-devel
错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决方法:
cd .. 退出当前目录
下载地三方源
wget http://www.atomicorp.com/installers/atomic
sh ./atomic \\运行脚本
然后在安装3个依赖包
yum install php-mcrypt libmcrypt libmcrypt-devel
错误:
configure: error: jpeglib.h not found.
解决方法:
yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel -y
或者安装一个yum扩展包yum install -y epel-release
在重新编译一下 。
二:编译
#make
#eshop $?
三:编译安装
#makeinstall
#eshop $?
四:拷贝PHP的配置文件:
#cp/usr/local/src/php-5.4.36/php.ini-production /usr/local/php/etc/php.ini
下面是 编译时的一些参数
--with-apxs2=/usr/local/apache2/bin/apxs 这个工具是自动帮助我们安装扩展模块的,它会生成一个动态模块在apache2/modules
--with-mysql=/usr/local/mysql php也是依赖mysql的,所以要先安装mysql。apache然后在安装PHP;mysql和apache可以颠倒。
小技巧 /usr/local/php/bin/php 是执行文件 和 /usr/local/apache2/bin/apachectl 一样
/usr/local/php/bin/php -m 查看php模块
这些是静态模块;动态模块需要我们自己去编译
安装php7
• cd /usr/local/src/
• wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
• tar zxf php-7.1.6.tar.bz2
安装一个扩展源:yum install -y epel-release.noarch
如果没有包,yum install -y bzip2-devel libjpeg-turbo-devel libpng-devel freetype-devel libtomcrypt-devel openssl-devel php-mcrypt libmcrypt libmcrypt-devel gcc libtool-ltdl-devel expat-devel pcre-devel libxml2-devel libcurl-devel perl-Data-Dumper libaio bzip2
• 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 (--enable-pdo --enable-mysqlnd )这2个参数先暂时不加,需要研究
• make && make install
• ls /usr/local/apache2.4/modules/libphp7.so
• cp php.ini-production /usr/local/php7/etc/php.ini