一、yum安装apache
1.先要更换yum源(步骤参考下帖)
2.输入命令进行安装
yum -y install httpd
然后出现下面的界面
可以顺便安装一个手册
yum -y install httpd-manual #apache的手册
3.进行一下基础设置
systemctl start httpd #重新启用
systemctl enable httpd #启用
firewall-cmd --list-all #列出防火墙信息
firewall-cmd --permanent --add-service=http #永久允许http
firewall-cmd --reload #防火墙重新加载策略
4.验证一下
/var/www/html apache的/目录,默认发布目录
var/www/html/index.html apache的默认发布文件内容
vim var/www/html/index.html 写默认发布文件内容
我们进入上面的目录,创建index.html然后简单编辑一下。
在浏览器输入虚拟机IP,查看(可以查看到配置的内容,配置成功)
二、编译安装apache
(删除一下上面步骤安装的apache,没有安装则不需要)
yum remove -y "httpd*"
1.下载软件:apr,apr-util,prce,httpd(从apache官方网站下载)
2.安装apr apr-util pcre三个依赖包:(以下方法为编译安装)
tar zxf apr-1.5.2.tar.gz #解压
./configure --prefix=/usr/local/apr #安装路径
make && make install #编译
tar zxf apr-util-1.5.4.tar.gz #解压
./configure --prefix=/usr/local/web/apr-util \ --with-apr=user/local/apr ##安装路径
make && make install #编译
tar zxf pcre-8.38.tar.gz #解压
./configure --prefix=/user/local/pcre #安装路径
make && make install #编译
3、解压apache软件压缩包和编译安装apache软件。
tar zxf httpd-2.4.53. tar.gz #解压包
./configure --prefix=/usr/local/apache 2.4.53 #指定apache的安装目录(进入解压的目录)
-- enable-expiress \ #提供对内容的压缩传输编码的支持
-- enable-headers\ #激活允许通过配置文件控制HTTP的内容
--enable -modules -most\ #编译安装模块,most表示包括大部分模块
--enable-so \ #激活apache的DSO支持
--enable-rewrite \ #激活基于URL规则的重写功能
--with-mpm=worker \ #配置apache的mpm模式为worker模式
--with-apr=usr/local/apr \ #指定apr依赖包的安装位置(相对位置)
--with-apr-util=/usr/local/apr-util \ #指定apr-util依赖包的安装位置
--with-pcre=/usr/local/pcre #指定pcre依赖包的安装位置
执行完上面步骤后
make && make install #进行编译
4.验证方法同yum安装。