centos 7 通过源码安装apache
一: 1.源码安装方式:源码安装的好处是用户可以定制软件功能,安装需要的模块,不需要的功能可以不用安装,也可以选择安装路径,
卸载软件也方便,只需要删除对应的安装目录即可。
2.源码方式编译安装过程:
a.源码安装软件一般有以下几个步骤组成: 下载解压源码、分析安装平台环境(configure)、编译安装软件(make 、make install)
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-rewrite
报错: 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;
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz (下载apr)
#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 (环境监测)
make (编译) #make install (安装pcre) (#yum -y install gcc-c++ (安装c++) )
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的编译环境和版本)
©著作权归作者所有:来自51CTO博客作者基层通信兵的原创作品,如需转载,请注明出处,否则将追究法律责任更多相关文章
- 老板又出难题,气得我写了个自动化软件
- Fabric 源码学习:如何实现批量管理远程服务器?
- Ansible 之 通过yum模块安装软件
- GUI实战|Python做一个文档图片提取软件
- Centos8基础,Yum软件包管理
- Python 进阶之源码分析:如何将一个类方法变为多个方法?
- 学算法的那些年,吴师兄接触的网站、软件、视频、书籍大揭秘
- 软件设计原则
- 用Python和Tableau对母婴商品销量进行数据分析(附Python源码及Tab