Apache搭建http网站服务器入门教程

本文详细介绍如何在CentOS 7上使用Apache HTTP服务器搭建个人网站。内容包括域名解析、Apache安装配置、创建测试页面等步骤,适用于初学者快速上手。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Apache搭建http网站服务器入门教程

准备工具

  • 一台带有Linux系统的主机,这里使用CentOS 7.1 64位系统
  • 一个备案过的域名,这里使用www.hellopage.cn
  • 一台可以访问网络的pc,这里使用的Win7_pro_sp1

步骤

1.解析域名

在域名管理控制台添加对主机ip的解析,如下图

926430-20160416112125051-1968036936.png

926430-20160416112134363-1608528813.png

2.Apache安装

启动CentOS系统,安装httpd

# yum install httpd
3.配置Apache环境
# vim /etc/httpd/conf/httpd.conf

添加如下代码至文件末尾

926430-20160416112142598-444151178.png

同时修改文件的以下部分,来修改默认的主目录

926430-20160416112723988-214235413.png

同时别忘了创建此目录,否则会报错

# cd /var/www/html
# mkdir hellopage

最后重新启动httpd

# /bin/systemctl start httpd.service
4.测试

1.打开浏览器,输入www.hellopage.cn,若出现如下页面,则建立成功

    Testing 123..
    This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that this site is working properly. This server is powered by CentOS.

2.在刚刚创建的/var/www/html/hellopage/下创建html

# cd /var/www/html/hellopage/
# touch index.html
# vim index.html

添加如下代码

<!DOCTYPE html>
<html>
<head>
    <title>God Sacred</title>
</head>
<body>
    <p>hello world!</p>
</body>
</html>

3.重新登录网站www.hellopage.cn

926430-20160416112204191-265968186.png

转载于:https://www.cnblogs.com/ScratchingBear/p/5397940.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值