Mac上搭建Web服务器--Apache

局域网搭建 Web 服务器测试环境,因为Mac OS X 自带了 Apache 和 PHP 环境,我们只需要简单的启动它就行了。

1.命令:sudo apachectl start

Apache服务器默认的web根目录在:/Library/WebServer/Documents 
Apache的配置文件在:/etc/apache2

相关命令:

停止 Apache:sudo apachectl stop

重启 Apache:sudo apachectl restart

2.浏览器输入:http://localhost

3.将一个html文件拷贝到/Library/WebServer/Documents 文件夹下

 

4.浏览器中访问,测试文件名为test.html的文件,格式:本机IP/静态网页,http://192.168.1.112/test.html

查看IP地址:偏好设置-->网络

 

测试html代码:

<!DOCTYPE html>
<html>
 
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
		<title>first html5 page</title>
		<!-- 
        <link rel="stylesheet" href="/css/style.css">
        <script src="/js/libs/modernizr-2.5.3.min.js">
        -->
		<style type="text/css">
			body {
				margin: 0 auto;
				width: 900px;
				background: #fff;
				font: 100%/1.4 helvetica, arial, sans-serif;
			}
			
			header {
				background: #ccc;
				padding: 20px;
			}
			
			header h1 {
				margin: 0;
			}
			
			nav {
				float: left;
				width: 900px;
				background: #333;
			}
			
			nav ul {
				margin: 0;
				padding: 0;
			}
			
			nav ul li {
				list-style-type: none;
				display: inline;
			}
			
			nav li a {
				display: block;
				float: left;
				padding: 5px 10px;
				color: #fff;
				text-decoration: none;
				border-right: 1px solid #fff;
			}
			
			article {
				clear: left;
				float: left;
				width: 560px;
				padding: 20px 0;
				margin: 0 0 0 30px;
				display: inline;
			}
			
			article h2 {
				margin: 0;
			}
			
			aside {
				float: right;
				width: 240px;
				padding: 20px 0;
				margin: 0 20px 0 0;
				display: inline;
			}
			
			aside h3 {
				margin: 0;
			}
			
			footer {
				clear: both;
				background: #ccc;
				text-align: right;
				padding: 20px;
				height: 1%;
			}
		</style>
		<script type="text/javascript">
		</script>
	</head>
 
	<body>
		<!-- 头部 -->
		<header>
			<h1>头部333333333</h1>
		</header>
		<!-- 导航 -->
		<nav>
			<ul>
				<li id="home">Home</li>
				<li id="about">About</li>
				<li id="contact">Contact</li>
			</ul>
		</nav>
		<!-- 导航 -->
		<section>
			<h1>My Article</h1>
			<article>
				<p>this is first article</p>
				<div id="second_item">this is second article,I'm
					<a href="http://www.cnlbogs.com/hongten">Hongten</a>
					</p>
					<p>this is third article</p>
					<p>this is 4's article</p>
			</article>
		</section>
		<aside></aside>
		<!-- 尾部 -->
		<footer class="footer1">
			<p>
				<a href="mailto:hongtenzone@foxmail.com">hongtenzone@foxmail.com</a> ||
				<a href="http://www.cnlbogs.com/hongten">Hongten</a>
			</p>
		</footer>
	</body>
 
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值