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

centos之搭建Apache环境

5次阅读
没有评论

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

导读 Apache 是世界使用排名第一的 Web 服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的 Web 服务器端软件之一。它快速、可靠并且可通过简单的 API 扩充,将 Perl/Python 等解释器编译到服务器中。今天我们就一起来和大家学习 centos 如何搭建安装 apache 环境

centos 之搭建 Apache 环境

一、安装

安装之前先将服务器的防火墙关掉。

systemctl stop firewalld

systemctl disable firewall

第一步:

安装 apr

下载:

wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.bz2

解压该文件:

tar -jvxf apr-1.6.3.tar.bz2

检测:

cd apr-1.6.3
./configure --prefix=/usr/local/apr/

编译:

make
make install

第二步:

安装 apr-util

下载:

wget -c http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2

解压该文件:

tar -jvxf apr-util-1.6.1.tar.bz2

检测:

cd apr-util-1.6.3
./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/

编译:

make
make install

第三步:

安装 pcre

下载:

wget -c http://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2

解压该文件:

tar -jvxf pcre-8.42.tar.bz2

检测:

cd pcre-8.42
./configure --prefix=/usr/local/pcre/

编译:

make
make install

第四步:
安装 httpd

下载:

wget -c http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.bz2

解压该文件:

tar -jvxf httpd-2.4.29.tar.bz2

检测:

cd httpd-2.4.29
./configure --prefix=/usr/local/httpd/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/

编译:

make
make install

第五步:

 配置 /usr/local/apache2/conf/httpd.conf

ServerName www.examda.com:80
改为
ServerName localhost:80

第六步:

启动 apache 服务

/usr/local/apache2/bin/apachectl start
二、检测

使用浏览器访问本地 IP

出现 It works! 成功

三、报错处理

(1)configure: error: APR not found. Please read the documentation.

这是没有安装 apr 或者 apr 安装失败导致的,重新安装 apr。

安装请查看第一步。

(2)configure: error: APR-util not found. Please read the documentation.

这是没有安装 apr-util 或者 apr-util 安装失败导致的,重新安装 apr-util。

安装请查看第二步。

(3)configure: error: no acceptable C compiler found in $PATH

这是没有安装 gcc 编译器或者 gcc 编译器安装失败导致的,重新安装 gcc。

yum install -y gcc

(4)xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录

这是没有安装 expat-devel 或者 expat-devel 安装失败导致的,重新安装 expat-devel。

yum install -y expat-devel

(5)configure: error: Invalid C++ compiler or C++ compiler flags

这是没有安装 gcc-c++ 或者 gcc-c++ 安装失败导致的,重新安装 gcc-c++。

yum install -y gcc-c++

(6)configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

这是没有安装 pcre 或者 pcre 安装失败导致的,重新安装 pcre。

安装请查看第三步。

阿里云 2 核 2G 服务器 3M 带宽 61 元 1 年,有高配

腾讯云新客低至 82 元 / 年,老客户 99 元 / 年

代金券:在阿里云专用满减优惠券

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