一: 1.源码安装方式:源码安装的好处是用户能够定制软件功能,安装须要的模块,不须要的功能能够不用安装,也能够选择安装路径,
卸载软件也方便,只须要删除对应的安装目录便可。
2.源码方式编译安装过程:
a.源码安装软件通常有如下几个步骤组成: 下载解压源码、分析安装平台环境(configure)、编译安装软件(make 、make install)linux
configure文件通常是个可执行文件,能够在当前目录下直接输入“./configure”进行软件安装的环境测试,若是提示缺乏某些安装包,就须要进行安装,直到测试经过。一般的, 源码安装都须要GCC或者CC编译器,这些编译器通常在安装系统时定制安装包中的开发工具选项下。 make是常常用的编译命令,对于一个包含不少源文件的应用程序,使用make和makefile工具能够简单快速的解决各个源文件之间复杂的依赖关系。 3. 源码包安装注意事项: 经过源码方式安装软件,须要把开发工具等基础模块安装号,好比 gcc、gcc-c++、libgcc、glibc、make、automake等开发工具或基础包;还要安装 一些相应的开发包,通常是文件名包括dev的,好比glibc-devel、gettext-devel;还有一些开发库,好比以lib开头的开发库。 源代码通常以 file.tar.gz file.tar.bz2打包,file.tar.gz和file.tar.bz2格式的解包命令以下: #tar jxvf file.tar.bz2 ; # tar zxvf file.tar.gz 解压后可发现 README或readme和INSTALL或install,这些都是安装说明; configure比较重要的一个参数是 --prefix,用 --prefix参数,咱们能够指定软件安装目录,当不须要这个软件时,直接删除软件安装目录便可。 #more /etc/redhat-release (查看linux系统版本)
4.源码安装Apache HTTp server :
1.下载http server :# wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.gz
2.解压 : # tar zxvf httpd-2.4.46.tar.gz
3.进入源码包 : # cd httpd-2.4.46
4.查看说明文件 : INSTALL 或者 README
5.# ./configure --prefix=/usr/local/apache2 (指定安装到 目录/usr/local/apache2 下) --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewritec++
报错: checking for ARP...no
configure:error:ARP not found.please read...
解决方法:1.在apr官网: https://apr.apache.org下载: apr 1.7.0和apr-util 1.6.1; apache
#wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz (下载 apr-util) 解压: #tar zxvf apr-1.7.0.tar.gz #cd apr-1.7.0 # ./configure --prefix=/usr/local/apr #make (编译) # make install (执行安装操做) 完成 apr-1.7.0的安装 解压 apr-util-1.6.1 #tar zxvf apr-util-1.6.1.tar.gz # ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr (执行./configure,进行环境测试) # make (执行编译) 报错:fatal error: expat.h: no such file.... make:***[all-recursive] Error 1 上面错误是由于缺乏某个包或者库文件,多是expat.h文件没有安装。解决: #yum install expat (不可行) # yum install expat-devel (错误排除) # make install
解决完错误继续安装apache
依然报错: configure: error:APR-util not found .
解决: # ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
依然报错: configure: error : pcre-config for libpcre not found. (说明pcre还没安装)
解决: 在pcre官网: www.pcre.org 下载pcre : #wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
解压pcre : # tar zxvf pcre-8.40.tar.gz 进入pcre目录 :# cd pcre-8.40 #./configure --prefix=/usr/local/pcre (环境监测)app
6. 继续安装apache :#./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 7.执行make报错: collect2:error:ld returned 1 exit status 解决:在app 目录下 #cp -r apr-1.7.0 httpd-2.4.46/srclib/apr #cp -r apr-util-1.6.1 httpd-2.4.46/srclib/apr-util 继续报错:解决 #./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most --enable-proxy-http=shared --enable-rewrite --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --with-included-apr 8.# make (编译) 9.# make install (安装)
无报错,完成安装。 验证安装是否正确: 进入安装目录: # cd /usr/local/apache2/ #cd /bin #./httpd -V (查看httpd的编译环境和版本)ide