本文主要是介绍自己编译 LAMP Centos 7.2+Apache2.4+ Mysqlnd 5.6+PHP 7 详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
源码包列表:
安装前准备
1) 获取源码包
2) 检查安装时使用的编译工具是否存在
gcc 、cmake
3) 卸载默认的低版本环境
1.安装libxml2 最新库文件
cd /usr/local/src
tar --zxvf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr/local/libxml2make && make install
2.安装libmcrypt最新库文件
cd /usr/local/src/
tar --zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install
cd /usr/local/src/libmcrypt-2.5.8/libltdl
./configure --enable-ltdl-install
make && make install
3 . 安装zlib 最新库文件
cd /usr/local/src/
tar --zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlibmake && make install
4. 安装libpng 最新库文件
cd /usr/local/src/
tar --zxvf libpng-1.6.21.tar.gz
cd libpng-1.6.21
./configure --prefix=/usr/local/libpng
make && make install
bug:
configure: error: ZLib not installed
解决办法:
export LDFLAGS="-L/usr/local/zlib/lib"
export CPPFLAGS="-I/usr/local/zlib/include"
5. 安装jpeg9 最新库文件
mkdir /usr/local/jpeg9
mkdir /usr/local/jpeg9/bin
mkdir /usr/local/jpeg9/lib
mkdir /usr/local/jpeg9/include
mkdir --p /usr/local/jpeg9/man/man1
cd /usr/local/src/
tar --zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b
./configure \
--prefix=/usr/local/jpeg9 \
--enable-shared \
--enable-staticmake && make install
6.安装freetype 最新库文件
cd /usr/local/src/
tar --zxvf freetype-2.4.0.tar.gz
cd freetype-2.4.0
./configure –prefix=/usr/local/freetype
make && make install
7.安装autoconf 最新库文件
cd /usr/local/src/
先安装这个文件
tar -zvxf m4-1.4.17.tar.gz
cd m4-1.4.17
./configure
make
make install
tar –zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure
make && make install
bug:
GNU M4 1.4.6 or later is required; 1.4.13 is recommend
解决办法
wget -O m4-1.4.9.tar.gz http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
tar -zvxf m4-1.4.9.tar.gz
cd m4-1.4.9
./configure
make
make install
8.安装最新的GD 库文件
cd /usr/local/src
(先安装这一个libXpm 防止后面安装php7.0.3 出现bug)
yum install libXpm-devel.x86_64
tar -zxvf libgd-2.1.1.tar.gz
cd libgd-2.1.1
./configure \
--prefix=/usr/local/gd2/ \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg9/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/
make && make install
9.安装最新的Apache 服务器
1) 安装Apache 组件apr
cd /usr/local/srctar –zxvf apr-1.5.2.tar.gzcd apr-1.5.2./configure --prefix=/usr/local/aprmake && make install
2) 安装Apache 组件apr-util:
cd /usr/local/src
tar –zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make && make install
3) 安装Apache 组件Pcre
cd /usr/local/src
tar –zxvf pcre-8.38.tar.gz
cd pcre-8.38
./configure –prefix=/usr/local/pcre
make && make install
4) 安装openssl
centos7自带版本openssl1.0.1e,不卸载系统自带openssl,直接源码编译openssl1.0.1r
tar -zxvf openssl-1.0.1r.tar.gz
cd openssl-1.0.1r
./config --prefix=/usr/local/openssl -fPIC enable-shared
make && make install
mv /usr/bin/openssl /usr/bin/openssl.1.0.1e
ln –s /usr/local/openssl/bin/openssl /usr/bin/openssl
5) 安装apache
cd /usr/local/src
tar –zxvf httpd-2.4.18.tar.gz
cd httpd-2.4.18
./configure
--prefix=/usr/local/apache
--sysconfdir=/etc/httpd
--enable-so --enable-cgi
--enable-ssl --enable-rewrite
--with-ssl=/usr/local/openssl
--with-pcre=/usr/local/pcre
--with-z=/usr/local/zlib
--with-apr=/usr/local/apr
--with-apr-util=/usr/local/apr-util
--enable-modules=most
--enable-mpms-shared=all
--with-mpm=event
--disable-userdir
--enable-deflate=shared
--enable-expires=shared
--enable-rewrite=shared
--enable-static=support
make && make install
systemctl stop firewalld.service
systemctl disable firewalld.service
/usr/local/apache/bin/apachectl start
图2 Apache 安装成功测试
10。安装 php7
先安装
yum install libXpm-devel
在PHP的./configure配置中添加: –with-xpm-dir=/usr/lib
关闭selinux
2、修改配置文件需要重启机器:
修改/etc/selinux/config 文件
将SELINUX=enforcing改为SELINUX=disabled
重启机器即可
cd php-7.1.7
./configure --prefix=/usr/local/php \--with-apxs2=/usr/local/http2/bin/apxs \--with-mysql=mysqlnd \--with-pdo-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-freetype-dir=/usr/local/freetype \--with-gd=/usr/local/gd2 \--with-zlib-dir=/usr/local/zlib \--with-libxml-dir=/usr/local/libxml2 \--with-jpeg-dir=/usr/local/jpeg9 \--with-png-dir=/usr/local/libpng \--enable-mbstring=all \--enable-mbregex \--enable-shared \--with-xmp-dir=/usr/libmake && make install
1)复制php.ini配置文件到指定目录
cp php.ini-development /usr/local/php/lib/php.ini
2) 配置Apache使其支持php
vi /etc/httpd
2.1) 在httpd.conf(Apache主配置文件)中增加:
AddType application/x-httpd-php .php
2.2) 找到下面这段话:
<IfModule dir_module>DirectoryIndex index.html
</IfModule>
在index.html 前面添加index.php
2.3) 建立php测试网页
vi /usr/local/httpd2/htdocs/index.php
输入如下内容:
<?php
phpinfo();
?>
2.4) 重启apache
/usr/local/http2/bin/apachectl restart
2.5) 再次浏览器查看http://虚拟机IP
如果看到php信息,工作就完成了!
11. 安装mysql :
参考: http://blog.csdn.net/u011513939/article/details/68952073
这篇关于自己编译 LAMP Centos 7.2+Apache2.4+ Mysqlnd 5.6+PHP 7 详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!