阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.5上编译安装Apache

146次阅读
没有评论

共计 2718 个字符,预计需要花费 7 分钟才能阅读完成。

Linux 系统:CentOS 6.5 mini 版,如果是 VMware 虚拟机,网卡要求“桥接

1、编译安装前首先 yum 安装“开发环境”“兼容库”“中文支持”即执行如下命令

#yum groupinstall “Development tools” “Compatibility libraries” “Chinese Support [zh]” -y

安装 man, vim, wget 工具

#yum install man vim wget -y

2、因为这次要编译安装 httpd2.4.25,此版本需要更高版本的 apr 和 apr-util。

因此要首先编译安装 apr 和 apr-util。

wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.bz2

wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.bz2

2.1 编译安装 apr

tar xf apr-1.5.2.tar.bz2

cd apr-1.5.2

./configure –prefix=/usr/local/apr

echo $?  ### 如果执行结果是 0,则继续执行 make && make install

2.2 编译安装 apr-util

tar xf apr-util-1.5.4.tar.bz2

cd apr-util-1.5.4

./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr

echo $?  ### 如果执行结果是 0,则继续执行 make && make install

3、重量级选手出厂了,正式开始编译 httpd-2.4.25

wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.25.tar.bz2

多次编译经验得知,缺少 pcre 相关文件,openssl is too old

执行如下命令:

yum install pcre-devel openssl openssl-devel -y

tar xf httpd-2.4.25

cd httpd-2.4.25

./configure  –prefix=/usr/local/apache –sysconfdir=/etc/httpd –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/

CentOS 6.5 上编译安装 Apache

有如上提示则继续执行:make && make install

再执行 echo$? 如果结果是 0,则说明 httpd2.4.25 到此编译成功,然后进行简单的配置,就可以使用了

4、配置 httpd

关闭 linux 防火墙

service httpd stop

关闭 SELinux

setenforce 0

复制启动文件

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

把 httpd 的环境变量添加到“环境变量”

echo ‘export PATH=$PATH:/usr/local/apache/bin’ > /etc/profile.d/httpd.sh

chmod +x /etc/profile.d/httpd.sh

source /etc/profile.d/httpd.sh

编辑 httpd 的配置文件:

vim /etc/httpd/httpd.conf

在 ServerRoot 下一行,添加 ServerName localhost

如果想把 Apache 服务加入到开机启动,可以修改服务启动脚本:

vim /etc/init.d/httpd

在第二行下添加:# chkconfig:235 85 15

                # description: This is apache server

保存退出

执行命令 service httpd start #提示 lynx 找不到???那就 yum install lynx -y

执行命令 netstat -ntlp #查看 httpd 是否启动,是否有 80 端口

最后在你的浏览器输入虚拟机 IP 地址

It works!

则 Apache,安装成功

1、编译安装 – 默认的 index.html 首页在 /usr/local/apache/htdocs

2、配置文件:/etc/httpd/httpd.conf

3、启动脚本:/etc/init.d/httpd

4、cgi-bin 文件目录:/etc/local/apache/cgi-bin

更多 Apache 相关教程见以下内容

CentOS6.8 编译安装 Apache2.4.25、MySQL5.7.16、PHP5.6.29  http://www.linuxidc.com/Linux/2016-12/138993.htm

CentOS 6.6 下安装 Apache 2.2.31 http://www.linuxidc.com/Linux/2017-02/140803.htm

Apache 配置多站点访问及二级域名配置  http://www.linuxidc.com/Linux/2017-03/141339.htm

Ubuntu 16.04 LTS 安装 Apache2+PHP7.0+MySQL+phpMyAdmin 图文详解  http://www.linuxidc.com/Linux/2017-02/140098.htm

CentOS 6 下 Apache 和 Tomcat 整合  http://www.linuxidc.com/Linux/2017-04/143021.htm

Apache 启用 gzip 压缩模块节约网站带宽  http://www.linuxidc.com/Linux/2017-04/142821.htm

Apache 配置 https  http://www.linuxidc.com/Linux/2017-02/140801.htm

Linux 下 Apache 安装及实例  http://www.linuxidc.com/Linux/2017-02/140800.htm

Apache2.4.6 服务器安装及配置  http://www.linuxidc.com/Linux/2017-01/140006.htm

Ubuntu 16.04 下搭建 Web 服务器(MySQL+PHP+Apache) 教程  http://www.linuxidc.com/Linux/2017-01/139570.htm

CentOS 7 下 Apache 2.4.18 编译安装详解  http://www.linuxidc.com/Linux/2017-03/142003.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-04/143273.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计2718字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中