云主机配置
- 购买centos的云主机
- 使用ssh访问云主机
ssh [email protected]
编写html文件
<html>
<title>Hermann_Hesse</title>
<head></head>
<body>
<h1>Hermann Hesse</h1>
<a href="https://en.wikipedia.org/wiki/Hermann_Hesse">From Wikipedia</a>
<p>Hermann Karl Hesse (2 July 1877 - 9 August 1962) was a German-born poet, novelist, and painter. His best-known
works include Demian, Steppenwolf, Siddhartha, and The Glass Bead Game, each of which explores an individual's
search for authenticity, self-knowledge and spirituality. In 1946, he received the Nobel Prize in Literature.
</p>
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Hermann_Hesse.jpg/220px-Hermann_Hesse.jpg">
</div>
<h2>Famous Bibliography</h2>
<ul>
<li>(1922) Siddhartha <em>novel</em></li>
<li>(1927) Der Steppenwolf <em>novel</em></li>
<li>(1943) Das Glasperlenspiel <em>(The Glass Bead Game; also published as Magister Ludi) novel</em></li>
</ul>
</body>
</html>
在centos云主机搭建apache环境
- 安装Apache
sudo yum install httpd
- 安装完成后,启用并启动Apache服务
sudo systemctl enable httpd
sudo systemctl start httpd
- 打开HTTP和HTTPS端口80和443,以便外部能够访问
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
浏览器中打开服务器IP地址,看到默认的Apache欢迎页面,说明apache安装成功
apache工作目录配置
打开apache的主配置文件
nano /etc/httpd/conf/httpd.conf
参数DocumentRoot是网站数据目录,默认为/var/www/html
打开http://serverIP,将自动访问/var/www/html 下的index.html
使用scp命令,将文件上传到云主机/var/www/html目录下
scp /path/filename [email protected]:/path
此时打开http://serverIP,可显示自定义的网页
配置域名解析
修改域名解析的记录值为云主机的域名地址
便可以直接使用网址访问到该页面