温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS下怎么部署Apache服务

发布时间:2022-02-17 10:31:12 来源:亿速云 阅读:146 作者:iii 栏目:开发技术

本篇内容介绍了“CentOS下怎么部署Apache服务”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

CentOS下怎么部署Apache服务

编译安装开发环境

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

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

安装man, vim, wget 工具

#yum install man vim wget -y

编译安装httpd

因为这次要编译安装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

编译安装apr

tar xf apr-1.5.2.tar.bz2cd apr-1.5.2
./configure --prefix=/usr/local/aprecho $? ###如果执行结果是0,则继续执行make && make install

编译安装apr-util

tar xf apr-util-1.5.4.tar.bz2cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/aprecho $? ###如果执行结果是0,则继续执行make && make install

正式开始编译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.25cd 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服务器的方法(最小化安装)

CentOS下怎么部署Apache服务 有如上提示则继续执行:make && make install

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

配置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.shsource /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

“CentOS下怎么部署Apache服务”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI