---
title: "让自己的电脑变成虚拟服务器"
author: "myangle89"
date: "2013-02-20T11:32:50Z"
tags: []
categories: ["互联网"]
slug: "untitled"
draft: false
lastmod: "2013-02-20T11:32:50Z"
id: 1808311
url: "https://myangle89.iteye.com/blog/1808311"
---

自己开发了博客系统？小webapp？

不想买域名买空间怎么办？

手把手教你如何让自己的电脑成为小型服务器，让外网的电脑可以访问你的网址（项目）

 

第一步：先去下载“花生壳”软件，软件下载地址：http://www.oray.com/peanuthull/download.php

第二步：安装，并注册个账号，申请个免费域名xxx.xxx

第三步：到tomcat目录下找到server.xml修改（这里的xxx.xxx就是你申请的域名）：

 

**\[html]** [view plain](http://blog.csdn.net/huxiweng/article/details/7296210 "view plain")[copy](http://blog.csdn.net/huxiweng/article/details/7296210 "copy")[print](http://blog.csdn.net/huxiweng/article/details/7296210 "print")[?](http://blog.csdn.net/huxiweng/article/details/7296210 "?")

1. &lt;Host name="xxx.xxx"  appBase="webapps"
2. unpackWARs="true" autoDeploy="true"
3. xmlValidation="false" xmlNamespaceAware="false"&gt;

第四步：修改server.xml(这里的xxx.xxx就是你申请的域名)

 

 

**\[html]** [view plain](http://blog.csdn.net/huxiweng/article/details/7296210 "view plain")[copy](http://blog.csdn.net/huxiweng/article/details/7296210 "copy")[print](http://blog.csdn.net/huxiweng/article/details/7296210 "print")[?](http://blog.csdn.net/huxiweng/article/details/7296210 "?")

1. &lt;Engine name="Catalina" defaultHost="xxx.xxx"&gt;

第五步：到路由器中设置虚拟服务器

 

转发规则 ——&gt;虚拟服务器——&gt;添加新条目

 

服务端口号：   (XX-XX or XX) IP地址： 协议：   状态：  

服务端口号:8080（主要是为了和tomcat的端口相同，如果你讲tomcat中的端口号设为80，那这边也设为80）

 

ip地址:就是你本机的ip地址

协议：all

状态：生效

第六步：重启tomcat，然后在浏览器中输入:xxx.xxx:8080（如果端口号为80，就不需要输入端口号），如果打开的是tomcat的首页，那就ok了。你可以发布你的项目到tomcat中，外网就可以访问你的项目了！