源码安装——能够按照本身的需求安装,这是源码安装的好处,而二进制安装没法选择html
大部分的源码安装步骤大体相同,具体细节能够参考解压缩以后的README和INSTALL
apache
README: 介绍了软件包的功能和安装介绍vim
INSTALL:介绍了软件包的安装指南windows
理解源码安装centos
进入INSTALL中查看安装指南部分,大体内容:浏览器
$ ./configure --prefix=PREFIX 指定基目录,全部安装的文件都放在这个目录下bash
--sysconfdir=DIR 另外也能够指定相关的配置文件存放的基目录服务器
更多关于./configure的设置能够借助./configure --help查看app
./configure 以后会在解压后的目录下生成一个Makefile文件,下一步的make就是靠这个文件编译ide
$ make 编译,把源码文件编译成二进制文件
前两步的过程任何用户都能执行,而下一步是真正的拷贝文件,须要拥有root权限
普通用户能够使用sudo命令临时拥有root权限
$ make install 复制源码包文件
$ PREFIX/bin/apachectl start
注意:上述的全部步骤必须保证在解压以后的目录下进行
具体案例
分别在centos6及centos7上使用源码包部署httpd服务。
1.从ftp://172.18.0.1/pub/Sources/sources/httpd/ 下载httpd源码包(这只是我这的服务器,其余的小伙伴要在apache官网下载)
下载好以后能够使用rz或lftp命令将windows中的文件拷贝至Linux系统下
rz 和lftp 须要提早安装
~]# yum provides *bin/rz* Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile lrzsz-0.12.20-27.1.el6.x86_64 : The lrz and lsz modem communications programs Repo : centos6 Matched from: Filename : /usr/bin/rz yum install lrzsz-0.12.20-27.1.el6.x86_64
~]# yum provides *bin/lftp* Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile lftp-4.0.9-14.el6.x86_64 : A sophisticated file transfer program Repo : centos6 Matched from: Filename : /usr/bin/lftpget Filename : /usr/bin/lftp yum install lftp-4.0.9-14.el6.x86_64
lftp的具体方法:
lftp 172.18.0.1:/pub/Sources/sources/httpd> get httpd-2.4.29.tar.bz2
lftp 172.18.0.1:/pub/Sources/sources/httpd> exit (退出)
tar -zxvf httpd-2.4.29.tar.bz2 解压缩
2.安装Development tools包组
源码安装必需要安装的包组,大体就是配置Linux编译环境的开发工具
yum groupinstall "Development Tools"
3.查看README INSTALL文件
cd httpd-2.2.34
4. ./configure --prefix=/app/apache
5.make
6.make install (需root权限)
7./app/apache/bin/apachectl start
8.清空防火墙
centos7:systemctl stop firewalld.service
systemctl disable firewalld.service
centos6:service iptables stop
service iptables save
9.netstat -tnl
查看监听状态
10.vim命令编辑文件 /app/apache/htdocs/index.html
打开浏览器输入http://IP地址(ifconfig查看)
能够看到网页显示hello world字样