在Centos7下编译部署LAMP环境

这是原来的做法,实在是受不了,各种报错,做了一半,但是很有借鉴意义,对于编译安装软件有很大的帮助

0x01 下载软件和安装库

约定下载的位置:/usr/local/src

0x02 解压所有的安装包

约定解压的位置:/usr/local/src/

tar zxvf autoconf-2.61.tar.gz
tar zxvf libpng-1.2.31.tar.gz 
tar zxvf libxml2-2.9.2.tar.gz
tar zxvf freetype-2.3.4.tar.gz 
tar zxvf mysql-5.6.40.tar.gz 
tar zxvf gd-2.0.35.tar.gz 
tar zxvf php-5.6.10.tar.gz 
tar zxvf httpd-2.4.46.tar.gz 
tar zxvf phpMyAdmin-4.4.13.1-all-languages.tar.gz 
tar zxvf jpegsrc.v6b.tar.gz 
tar zxvf ZendOptimizer330a.tar.gz 
tar zxvf zlib-1.2.3.tar.gz 
tar zxvf libmcrypt-2.5.8.tar.gz 

0x03 删除所有的.tar.gz文件

root@boluo-HK src]# rm -rf *.tar.gz

0x04 安装支持文件库

1、安装libxml2支持库

[root@boluo-HK ~]# cd /usr/local/src/libxml2-2.6.30/
[root@boluo-HK libxml2-2.6.30]# ./configure --prefix=/usr/local/libxml2
[root@boluo-HK libxml2-2.6.30]# make && make install

2、安装libmcrypt支持库

[root@boluo-HK ~]# cd /usr/local/src/libmcrypt-2.5.8/
[root@boluo-HK libmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@boluo-HK libmcrypt-2.5.8]# make && make install

3、安装zlib支持库

[root@boluo-HK ~]# cd /usr/local/src/zlib-1.2.3/
[root@boluo-HK zlib-1.2.3]# ./configure --prefix=/usr/local/zlib
[root@boluo-HK zlib-1.2.3]# make && make install

4、安装libpng支持库

[root@boluo-HK ~]# cd /usr/local/src/libpng-1.2.31/
[root@boluo-HK libpng-1.2.31]# ./configure --prefix=/usr/local/libpng
[root@boluo-HK libpng-1.2.31]# make && make install

5、安装jpeg6文件库

[root@boluo-HK ~]# mkdir /usr/local/jpeg6
[root@boluo-HK ~]# mkdir /usr/local/jpeg6/bin
[root@boluo-HK ~]# mkdir /usr/local/jpeg6/lib
[root@boluo-HK ~]# mkdir /usr/local/jpeg6/include
[root@boluo-HK ~]# mkdir -p /usr/local/jpeg6/man/man1
[root@boluo-HK ~]# cd /usr/local/src/jpeg-6b/
[root@boluo-HK jpeg-6b]# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static 
[root@boluo-HK jpeg-6b]# make && make install

如果你在安装jpeg6库文件报以下错误,请点击这里

./libtool --mode=compile gcc -O2  -I. -c ./jcapimin.c
make: ./libtool:命令未找到
make: *** [jcapimin.lo] 错误 127

6、安装freetype库文件

[root@boluo-HK ~]# cd /usr/local/src/freetype-2.3.4/
[root@boluo-HK freetype-2.3.4]# ./configure --prefix=/usr/local/freetype
[root@boluo-HK freetype-2.3.4]#  make && make install

7、安装autoconf库文件

先安装M4 1.4的依赖否则会报configure: error: GNU M4 1.4 is required 的需求

再安装perl-5.16.1依赖否则会报

Can't locate Data/Dumper.pm in @INC (@INC contains: ../lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at ../lib/Autom4te/C4che.pm line 33.
BEGIN failed--compilation aborted at ../lib/Autom4te/C4che.pm line 33.
Compilation failed in require at ../bin/autom4te line 37.
BEGIN failed--compilation aborted at ../bin/autom4te line 37.
make[2]: *** [autoconf.in] Error 2
make[2]: Leaving directory /tmp/autoconf-2.69/bin' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/tmp/autoconf-2.69'
make: *** [all] Error 2

wget http://ftp.gnu.org/gnu/m4/m4-1.4.1.tar.gz
tar zxvf m4-1.4.1.tar.gz
./configure
make && make install
wget https://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
tar zxvf perl-5.16.1.tar.gz
./configure.gnu 
make && make install
[root@boluo-HK ~]# cd /usr/local/src/autoconf-2.61/
[root@boluo-HK autoconf-2.61]# ./configure
[root@boluo-HK autoconf-2.61]# make && make install

8、安装gd库文件

cd /usr/local/src/gd-2.0.35/
./configure --prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/ --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype
vim gd_png.c
修改 找到“png.h”改成“/usr/local/libpng/include/png.h”

 make && make install

0x05 安装Apache服务器

先安装依赖

wget https://archive.apache.org/dist/apr/apr-1.4.6.tar.gz
wget https://archive.apache.org/dist/apr/apr-util-1.4.1.tar.gz
tar zxvf ./apr-1.4.6.tar.gz
tar zxvf ./apr-utli-1.4.1.tar.gz
cp -rf ./apr-1.4.6  ./httpd-2.4.6/srclib/apr
cp -rf ./apr-util-1.4.1  ./httpd-2.4.6/srclib/apr-util

apache-2.2与新出的apache-2.4安装不同的地方在于,2.4版的已经不自带apr库,所以在安装apache-2.4之前,需要下载apr。
[root@boluo-HK ~]# cd /usr/local/src/httpd-2.4.46/
[root@boluo-HK httpd-2.4.46]# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd --with-z=/usr/local/zlib/ --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
[root@boluo-HK httpd-2.4.46]# make && make install

结果 make && make install 报错

yum install gcc gcc-c++ prce-devel expat-devel
yum install -y libxml2-devel
cd /usr/local/src/httpd-2.4.46/
make clean

命令注释:

#./configure  \   //执行当前目录下软件自代的配置命令
 --prefix=/usr/local/apache2 \      //指定Apache软件安装的位置
 --sysconfdir=/etc/httpd  \     //指定Apache服务器的配置文件存放位置
 --with-z=/usr/local/zlib/ \                //指定zlib库文件的位置
 --with-included-apr  \                //使用捆绑APR/APR-Util的副本
 --enable-so \                         //以动态共享对象(DSO)编译
 --enable-deflate=shared \               //缩小传输编码的支持
 --enable-expires=shared \               //期满头控制
 --enable-rewrite=shared \               //基于规则的URL操控
 --enable-static-support                 //建立一个静态链接版本的支持

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×