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

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

准备工具

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

步骤

1.解析域名

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

2.Apache安装

启动CentOS系统,安装httpdapache

# yum install httpd

3.配置Apache环境

# vim /etc/httpd/conf/httpd.conf

添加以下代码至文件末尾vim

同时修改文件的如下部分,来修改默认的主目录浏览器

同时别忘了建立此目录,不然会报错服务器

# 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.cnthis

相关文章
相关标签/搜索