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

相關文章
相關標籤/搜索