﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-编程自动化-随笔分类-linux</title><link>http://www.cppblog.com/AutomateProgram/category/16808.html</link><description>当音乐和传说在深夜中沉寂后，程序的每个字符还在跳动！</description><language>zh-cn</language><lastBuildDate>Thu, 05 May 2011 03:38:31 GMT</lastBuildDate><pubDate>Thu, 05 May 2011 03:38:31 GMT</pubDate><ttl>60</ttl><item><title>ubuntu中tomcat更改80端口(tomcat修改port 为 80 后 无法访问)</title><link>http://www.cppblog.com/AutomateProgram/archive/2011/05/05/145725.html</link><dc:creator>漂漂</dc:creator><author>漂漂</author><pubDate>Thu, 05 May 2011 02:55:00 GMT</pubDate><guid>http://www.cppblog.com/AutomateProgram/archive/2011/05/05/145725.html</guid><wfw:comment>http://www.cppblog.com/AutomateProgram/comments/145725.html</wfw:comment><comments>http://www.cppblog.com/AutomateProgram/archive/2011/05/05/145725.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/AutomateProgram/comments/commentRss/145725.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/AutomateProgram/services/trackbacks/145725.html</trackback:ping><description><![CDATA[原文地址：<a  href="http://alanjiang.iteye.com/blog/737563">http://alanjiang.iteye.com/blog/737563</a><br><br><span class="Apple-style-span" style="border-collapse: separate; color: #000000; font-family: 'AR PL UKai CN'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; font-size: medium;"><span class="Apple-style-span" style="font-family: Arial,sans-serif,Helvetica,Tahoma; font-size: 12px; line-height: 18px; text-align: left;">
<p style="margin: 0px; padding: 0px;">最近新装了一台ubuntu服务器，版本为10.04，选择系统自带的LAMP应用</p>
<p style="margin: 0px; padding: 0px;">装好后通过<a  href="http://4088.cn:8080/" style="color: #108ac6; text-decoration: underline;">www.4088.cn:8080</a>可以正常访问，(4088.cn是我的手机域名)</p>
<p style="margin: 0px; padding: 0px;">但当更改/etc/tomcat6/server.xml中的</p>
<p style="margin: 0px; padding: 0px;">&lt;Connector port="80" protocol="HTTP/1.1"&nbsp; connectionTimeout="20000"&nbsp; URIEncoding="UTF-8" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; redirectPort="8443" /&gt;</p>
<p style="margin: 0px; padding: 0px;">port=8080更改为port=80后，保存从新启动，发现无法直接通过<a  href="http://4088.cn/" style="color: #108ac6; text-decoration: underline;">www.4088.cn</a>进行访问</p>
<p style="margin: 0px; padding: 0px;">通过命令netstat -ant检查服务器发现开启的端口中没有80端口</p>
<p style="margin: 0px; padding: 0px;">后来检查资料发现从ubuntu10.04起，默认是关闭1024一下的端口</p>
<p style="margin: 0px; padding: 0px;">需要手工打开，关于tomcat的打开，可以到编辑/etc/default/tomcat6中的最后一行AUTHBIND=yes来实现</p>
<p style="margin: 0px; padding: 0px;">默认是#AUTHBIND=no</p>
<p style="margin: 0px; padding: 0px;">具体操作步骤如下：</p>
<p style="margin: 0px; padding: 0px;">1、sudo vi /etc/tomcat6/server.xml，修改为port="80"</p>
<p style="margin: 0px; padding: 0px;">2、sudo vi /etc/default/tomcat6 ，修改为AUTHBIND=yes</p>
<p style="margin: 0px; padding: 0px;">3、sudo /etc/init.d/tomcat6 restart，进行重新启动</p>
<p style="margin: 0px; padding: 0px;">4、netstat -ant，查看80端口是否起来</p>
<p style="margin: 0px; padding: 0px;">5、手机可以正常访问<a  href="http://4088.cn/" style="color: #108ac6; text-decoration: underline;">www.4088.cn</a>了</p>
</span></span><br><img src ="http://www.cppblog.com/AutomateProgram/aggbug/145725.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/AutomateProgram/" target="_blank">漂漂</a> 2011-05-05 10:55 <a href="http://www.cppblog.com/AutomateProgram/archive/2011/05/05/145725.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在ubuntu10.04上面配置nutch-1.0 (ubuntu 配置 nutch)</title><link>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145657.html</link><dc:creator>漂漂</dc:creator><author>漂漂</author><pubDate>Wed, 04 May 2011 05:34:00 GMT</pubDate><guid>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145657.html</guid><wfw:comment>http://www.cppblog.com/AutomateProgram/comments/145657.html</wfw:comment><comments>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145657.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/AutomateProgram/comments/commentRss/145657.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/AutomateProgram/services/trackbacks/145657.html</trackback:ping><description><![CDATA[原文地址：http://my.chinaunix.net/space.php?uid=24488136&amp;do=blog&amp;id=64821<br><br>在书店去逛的时候，偶然看到了搜索专区的书，都是搜索引擎方面的，翻了下，感觉蛮有意思的，回来就baidu,google了下自己动手做搜索引擎，感觉开源的nutch-1.0蛮好，我就学习配置了下，遇到了一些问题，不过很快解决了。<img  src="http://www.cublog.cn/images/face/005.gif"><br><br>运行环境：<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px; background-color: #ffffff;"><code><span style="color: #000000;">Linux <span style="color: #0000cc;">*</span><span style="color: #0000cc;">*</span><span style="color: #0000cc;">-</span>desktop 2<span style="color: #0000cc;">.</span>6<span style="color: #0000cc;">.</span>32<span style="color: #0000cc;">-</span>25<span style="color: #0000cc;">-</span>generic <span style="color: #0000cc;">#</span>44<span style="color: #0000cc;">-</span>Ubuntu SMP Fri Sep 17 20<span style="color: #0000cc;">:</span>26<span style="color: #0000cc;">:</span>08 UTC 2010 i686 GNU<span style="color: #0000cc;">/</span>Linux&nbsp; <span style="color: #ff0102;">ubuntu 10.04</span><br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>1.安装JDK<br><br>因为ubuntu10.04自己自带了jdk(叫做openjdk)，所以我就直接用的是自带的jdk。可以直接去新立德软件包里面安装。安装完后在/usr/lib/jvm文件夹下面你就会发现有下面3个文件夹。当然你也可以直接去下载官方最新的jdk.<img  src="http://www.cublog.cn/images/face/007.gif"><br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">├── <span style="color: #0000ff;">default</span><span style="color: #0000cc;">-</span>java <span style="color: #0000cc;">-</span><span style="color: #0000cc;">&gt;</span> java<span style="color: #0000cc;">-</span>6<span style="color: #0000cc;">-</span>openjdk<br>
            ├── java<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>6<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">-</span>openjdk <span style="color: #0000cc;">-</span><span style="color: #0000cc;">&gt;</span> java<span style="color: #0000cc;">-</span>6<span style="color: #0000cc;">-</span>openjdk<br>
            └── java<span style="color: #0000cc;">-</span>6<span style="color: #0000cc;">-</span>openjdk<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>2.安装并且配置tomcat,在ubuntu10.04中，tomcat的版本是tomcat6,我还安装了管理软件tomcat6-admin<br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">apt<span style="color: #0000cc;">-</span>get install tomcat6 tomcat6<span style="color: #0000cc;">-</span>admin<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>安装好tomcat之后，输入/etc/init.d/tomcat6
start启动tomcat服务器。在浏览器中输入"http://localhost:8080"，如果显示&#8220;it
works&#8221;说明tomcat服务器正在运行。<br><br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><font size="6"><span style="font-weight: bold;">It works !</span></font> <br></p>
            <p style="line-height: 150%; margin: 5px;"><br></p>
            <p style="line-height: 150%; margin: 5px;">If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!&nbsp;</p>
            <p style="line-height: 150%; margin: 5px;"><br></p>
            <p style="line-height: 150%; margin: 5px;">
            This is the default Tomcat home page. It can be found on the local
            filesystem at: /var/lib/tomcat6/webapps/ROOT/index.html
            Tomcat6 veterans might be pleased to learn that this system instance of
            Tomcat is installed with CATALINA_HOME in /usr/share/tomcat6 and
            CATALINA_BASE in /var/lib/tomcat6, following the rules from
            /usr/share/doc/tomcat6-common/RUNNING.txt.gz.
            You might consider installing the following packages, if you haven't
            already done so:</p>
            <p style="line-height: 150%; margin: 5px;"><span style="font-weight: bold;">tomcat6-docs:</span>
            This package installs a web application that allows to browse the
            Tomcat 6 documentation locally. Once installed, you can access it by
            clicking here.</p>
            <p style="line-height: 150%; margin: 5px;">
            <span style="font-weight: bold;">tomcat6-examples:</span> This package
            installs a web application that allows to access the Tomcat 6 Servlet
            and JSP examples. Once installed, you can access it by clicking here.</p>
            <p style="line-height: 150%; margin: 5px;">
            <span style="font-weight: bold;">tomcat6-admin:</span> This package installs two web applications that can help managing this Tomcat instance. Once installed, you can access the <span style="color: #ff0102;">manager webapp</span> and the host-manager webapp.
            NOTE: For security reasons, using the manager webapp is restricted to users with role "manager". The <span style="color: #ff0102;">host-manager webapp </span>is restricted to users with role "admin". Users are defined in /etc/tomcat6/tomcat-users.xml.</p>
            </td>
        </tr>
    </tbody>
</table>
<br>需要配置用户才可以进入管理界面，修改/var/lib/tomcat6/conf/tomcat-users.xml<br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">出于安全考虑，把默认的用户tomcat删掉了，并添加了自己的用户，比如hinutch,添加密码，比如3838438<br></span></span></code></p>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">?</span>xml version<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">'1.0'</span> encoding<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">'utf-8'</span><span style="color: #0000cc;">?</span><span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span>tomcat<span style="color: #0000cc;">-</span>users<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>role rolename<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"manager"</span><span style="color: #ff00ff;">/</span><span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>role rolename<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"admin"</span><span style="color: #ff00ff;">/</span><span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>user username<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"hinutch"</span> password<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"3838438"</span> roles<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"admin,manager"</span><span style="color: #ff00ff;">/</span><span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>tomcat<span style="color: #0000cc;">-</span>users<span style="color: #0000cc;">&gt;</span><br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>这个时候你就可以进去管理界面了，如果不行的话，重启tomcat服务/etc/init.d/tomcat6 restart<br><br><span style="font-weight: bold; color: #660199;">管理界面如下：</span><br>
<table width="100%" border="0" cellspacing="4">
    <tbody>
        <tr>
            <td colspan="2">
            <a  href="http://my.chinaunix.net/link.php?url=http://www.apache.org%2F">
            <img  src="http://localhost:8080/manager/images/asf-logo.gif" alt="The apache software foundation" align="left" border="0">
            </a>
            <a  href="http://my.chinaunix.net/link.php?url=http://tomcat.apache.org%2F">
            <img  src="http://localhost:8080/manager/images/tomcat.gif" alt="The tomcat servlet/jsp container" align="right" border="0">
            </a>
            </td>
        </tr>
    </tbody>
</table>
<hr noshade="noshade" size="1">
<table width="100%" border="0" cellspacing="4">
    <tbody>
        <tr>
            <td class="page-title" nowrap="nowrap" align="left">
            <font size="+2">Tomcat Web Application Manager</font>
            </td>
        </tr>
    </tbody>
</table>
<br>
<table border="1" cellpadding="3" cellspacing="0">
    <tbody>
        <tr>
            <td class="row-left" width="10%"><small><strong>Message:</strong></small>&nbsp;</td>
            <td class="row-left">
            <pre>OK</pre>
            </td>
        </tr>
    </tbody>
</table>
<br>
<table border="1" cellpadding="3" cellspacing="0">
    <tbody>
        <tr>
            <td colspan="4" class="title">Manager</td>
        </tr>
        <tr>
            <td class="row-left"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Flist">List Applications</a></td>
            <td class="row-center"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fdocs%2Fhtml-manager-howto.html">HTML Manager Help</a></td>
            <td class="row-center"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fdocs%2Fmanager-howto.html">Manager Help</a></td>
            <td class="row-right"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fstatus">Server Status</a></td>
        </tr>
    </tbody>
</table>
<br>
<table border="1" cellpadding="3" cellspacing="0">
    <tbody>
        <tr>
            <td colspan="5" class="title">Applications</td>
        </tr>
        <tr>
            <td class="header-left"><small>Path</small></td>
            <td class="header-left"><small>Display Name</small></td>
            <td class="header-center"><small>Running</small></td>
            <td class="header-center"><small>Sessions</small></td>
            <td class="header-left"><small>Commands</small></td>
        </tr>
        <tr>
            <td class="row-left" rowspan="2" bgcolor="#ffffff"><small><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2F">/</a></small></td>
            <td class="row-left" rowspan="2" bgcolor="#ffffff"><small>&nbsp;</small></td>
            <td class="row-center" rowspan="2" bgcolor="#ffffff"><small>true</small></td>
            <td class="row-center" rowspan="2" bgcolor="#ffffff"><small><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fsessions%3Fpath%3D%2F" target="_blank">0</a></small></td>
            <td class="row-left" bgcolor="#ffffff">
            <small>
            &nbsp;Start&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fstop%3Fpath%3D%2F">Stop</a>&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Freload%3Fpath%3D%2F">Reload</a>&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fundeploy%3Fpath%3D%2F">Undeploy</a>&nbsp;
            </small>
            </td>
        </tr>
        <tr>
            <td class="row-left" bgcolor="#ffffff">
            <form method="POST" action="/manager/html/expire?path=/">
                <small>
                &nbsp;<input value="Expire sessions" type="submit">&nbsp;with idle &#8805;&nbsp;<input name="idle" size="5" value="30" type="text">&nbsp;minutes&nbsp;
                </small>
            </form>
            </td>
        </tr>
        <tr>
            <td class="row-left" rowspan="2" bgcolor="#c3f3c3"><small><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fhost%252Dmanager">/host-manager</a></small></td>
            <td class="row-left" rowspan="2" bgcolor="#c3f3c3"><small>Tomcat Manager Application</small></td>
            <td class="row-center" rowspan="2" bgcolor="#c3f3c3"><small>true</small></td>
            <td class="row-center" rowspan="2" bgcolor="#c3f3c3"><small><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fsessions%3Fpath%3D%2Fhost%252Dmanager" target="_blank">0</a></small></td>
            <td class="row-left" bgcolor="#c3f3c3">
            <small>
            &nbsp;Start&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fstop%3Fpath%3D%2Fhost%252Dmanager">Stop</a>&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Freload%3Fpath%3D%2Fhost%252Dmanager">Reload</a>&nbsp;
            &nbsp;<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fmanager%2Fhtml%2Fundeploy%3Fpath%3D%2Fhost%252Dmanager">Undeploy</a>&nbsp;
            </small>
            </td>
        </tr>
        <tr>
            <td class="row-left" bgcolor="#c3f3c3">
            <form method="POST" action="/manager/html/expire?path=/host%2Dmanager">
                <small>
                &nbsp;<input value="Expire sessions" type="submit">&nbsp;with idle &#8805;&nbsp;<input name="idle" size="5" value="30" type="text">&nbsp;minutes&nbsp;
                </small>
            </form>
            </td>
        </tr>
    </tbody>
</table>
<br>
<p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"></span></code>3.安装nutch1.0</p>
<p style="line-height: 150%; margin: 5px;">下载nutch-1.0.tar.gz，网址<a  href="http://my.chinaunix.net/link.php?url=http://www.apache.org%2Fdyn%2Fcloser.cgi%2Fnutch%2F" target="_blank">http://www.apache.org/dyn/closer.cgi/nutch/</a></p>
<pre><img  src="http://apache.freelamp.com/icons/compressed.gif" alt="[   ]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-bin.zip">apache-nutch-1.2-bin.zip</a>        25-Sep-2010 05:38  164M
<img  src="http://apache.freelamp.com/icons/text.gif" alt="[TXT]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-bin.zip.asc">apache-nutch-1.2-bin.zip.asc</a>    25-Sep-2010 05:37  203
<img  src="http://apache.freelamp.com/icons/compressed.gif" alt="[   ]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-src.tar.gz">apache-nutch-1.2-src.tar.gz</a>     25-Sep-2010 05:37   50M  GZIP compressed document
<img  src="http://apache.freelamp.com/icons/text.gif" alt="[TXT]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-src.tar.gz.asc">apache-nutch-1.2-src.tar.gz.asc</a> 25-Sep-2010 05:37  203   GZIP compressed document
<img  src="http://apache.freelamp.com/icons/compressed.gif" alt="[   ]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-src.zip">apache-nutch-1.2-src.zip</a>        25-Sep-2010 05:37   51M
<img  src="http://apache.freelamp.com/icons/text.gif" alt="[TXT]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fapache-nutch-1.2-src.zip.asc">apache-nutch-1.2-src.zip.asc</a>    25-Sep-2010 05:37  203
<img  src="http://apache.freelamp.com/icons/compressed.gif" alt="[   ]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fnutch-0.9.tar.gz">nutch-0.9.tar.gz</a>                05-Apr-2007 10:17   68M  GZIP compressed document
<img  src="http://apache.freelamp.com/icons/text.gif" alt="[TXT]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fnutch-0.9.tar.gz.asc">nutch-0.9.tar.gz.asc</a>            05-Apr-2007 10:17  186   GZIP compressed document
<img  src="http://apache.freelamp.com/icons/compressed.gif" alt="[   ]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fnutch-1.0.tar.gz">nutch-1.0.tar.gz</a>                28-Mar-2009 04:12   83M  GZIP compressed document
<img  src="http://apache.freelamp.com/icons/text.gif" alt="[TXT]"> <a  href="http://my.chinaunix.net/link.php?url=http://apache.freelamp.com%2F%2Fnutch%2Fnutch-1.0.tar.gz.asc">nutch-1.0.tar.gz.asc</a>            28-Mar-2009 04:12  197   GZIP compressed document<br><br>解压出来，我上面的是：<br></pre>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">├── bin<br>
            ├── build<span style="color: #0000cc;">.</span>xml<br>
            ├── CHANGES<span style="color: #0000cc;">.</span>txt<br>
            ├── conf<br>
            ├── crawled<br>
            ├── <span style="color: #0000ff;">default</span><span style="color: #0000cc;">.</span>properties<br>
            ├── docs<br>
            ├── KEYS<br>
            ├── lib<br>
            ├── LICENSE<span style="color: #0000cc;">.</span>txt<br>
            ├── logs<br>
            ├── NOTICE<span style="color: #0000cc;">.</span>txt<br>
            ├── nutch<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">.</span>jar<br>
            ├── nutch<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">.</span>job<br>
            ├── nutch<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">.</span>war<br>
            ├── plugins<br>
            ├── README<span style="color: #0000cc;">.</span>txt<br>
            ├── src<br>
            ├──<span style="color: #ff0102;"> url.txt（这个是自己建的）</span><br>
            └── webapps<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>首先在Nutch的解压根目录下新建一个文本文件，命名为&#8220;url.txt&#8221;（这个名字你可以随便取）。里面放的是你需要抓取信息的网址。<br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">我的解压根目录为/home/**/nutch-1.0,新建一个url.txt，里面输入：<br></span></code></p>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">http<span style="color: #0000cc;">:</span><span style="color: #ff9900;">//bbs.chinaunix.net/<br>
            </span><br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>其次更新配置文件crawl-urlfilter.txt，打开&#8220;conf/crawl-urlfilter.txt&#8221;，<br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">#</span> skip URLs with slash<span style="color: #0000cc;">-</span>delimited segment that repeats 3<span style="color: #0000cc;">+</span> <span style="color: #ff0000;">times</span><span style="color: #0000cc;">,</span> to <span style="color: #0000ff;">break</span> loops<br>
            <span style="color: #0000cc;">-</span><span style="color: #0000cc;">.</span><span style="color: #0000cc;">*</span><span style="color: #0000cc;">(</span><span style="color: #0000cc;">/</span><span style="color: #0000cc;">[</span><span style="color: #0000cc;">^</span><span style="color: #0000cc;">/</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">+</span><span style="color: #0000cc;">)</span><span style="color: #0000cc;">/</span><span style="color: #0000cc;">[</span><span style="color: #0000cc;">^</span><span style="color: #0000cc;">/</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">+</span><span style="color: #0000cc;">\</span>1<span style="color: #0000cc;">/</span><span style="color: #0000cc;">[</span><span style="color: #0000cc;">^</span><span style="color: #0000cc;">/</span><span style="color: #0000cc;">]</span><span style="color: #0000cc;">+</span><span style="color: #0000cc;">\</span>1<span style="color: #0000cc;">/</span><br>
            <br>
            <span style="color: #0000cc;">#</span> <span style="color: #ff0000;">accept</span> hosts in MY<span style="color: #0000cc;">.</span>DOMAIN<span style="color: #0000cc;">.</span>NAME<br>
            <span style="color: #0000cc;">+</span><span style="color: #0000cc;">^</span>http<span style="color: #0000cc;">:</span><span style="color: #ff9900;">//bbs.chinaunix.net/（<span style="color: #ff0102;">这个就是需要修改的，和url.txt里面内容一样</span>）<br>
            </span><br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>再打开nutch-site.xml文件，修改如下，<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">?</span>xml version<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"1.0"</span><span style="color: #0000cc;">?</span><span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">?</span>xml<span style="color: #0000cc;">-</span>stylesheet type<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"text/xsl"</span> href<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"configuration.xsl"</span><span style="color: #0000cc;">?</span><span style="color: #0000cc;">&gt;</span><br>
            <br>
            <span style="color: #0000cc;">&lt;</span>configuration<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>property<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>name<span style="color: #0000cc;">&gt;</span>http<span style="color: #0000cc;">.</span>agent<span style="color: #0000cc;">.</span>name<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>name<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>value<span style="color: #0000cc;">&gt;</span><span style="color: #ff0102;">my nutch agent</span><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>value<span style="color: #0000cc;">&gt;（<span style="color: #ff0102;">红色部分可以自己命名</span>）</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>property<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>property<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>name<span style="color: #0000cc;">&gt;</span>http<span style="color: #0000cc;">.</span>agent<span style="color: #0000cc;">.</span>version<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>name<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>value<span style="color: #0000cc;">&gt;</span>1<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>value<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>property<span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>configuration<span style="color: #0000cc;">&gt;</span><span style="color: #0000cc;"></span><span style="color: #0000cc;">~</span>                    </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>然后运行网络蜘蛛抓紧网页。在/home/**/nutch-1.0（即文件根目录）输入以下命令：<br>&nbsp;&nbsp; <br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #990133;">./bin/nutch crawl url.txt -dir crawled -depth 4 -topN 100 -threads 4</span><br>
            <span style="color: #0000cc;">-</span>dir <span style="color: #0000cc;">=</span> crawled  指明下载数据存放路径，该目录不存在时，会被自动创建<br>
            <span style="color: #0000cc;">-</span>depth <span style="color: #0000cc;">=</span> 4       下载深度为4<br>
            <span style="color: #0000cc;">-</span>topN <span style="color: #0000cc;">=</span> 100      下载符合条件的前100个页面<br>
            <span style="color: #0000cc;">-</span>threads <span style="color: #0000cc;">=</span> 4       启动的线程数目</span></code></p>
            </td>
        </tr>
    </tbody>
</table>
&nbsp;<br>蜘蛛运行时会输出大量数据，抓取结束之后，可以发现crawled目录被生成，里面有几个目录。
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">├── crawldb<br>
            ├── index<br>
            ├── indexes<br>
            ├── linkdb<br>
            └── segments<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>4.在tomcat中部署nutch项目<br><br> 将nutch根目录下的nutch-1.0.war文件放置到/var/lib/tomcat6/webapps文件夹下，然后再访问http://localhost:8080，tomcat便会将其解压。<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">root@**<span style="color: #0000cc;">-</span>desktop<span style="color: #0000cc;">:</span><span style="color: #0000cc;">/</span>var<span style="color: #0000cc;">/</span>lib<span style="color: #0000cc;">/</span>tomcat6<span style="color: #0000cc;">/</span>webapps<span style="color: #0000cc;">#</span> ls<br>
            nutch<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>0  nutch<span style="color: #0000cc;">-</span>1<span style="color: #0000cc;">.</span>0<span style="color: #0000cc;">.</span>war  ROOT<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
nutch-1.0文件夹下包含：<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">├── anchors<span style="color: #0000cc;">.</span>jsp<br>
            ├── ca<br>
            ├── cached<span style="color: #0000cc;">.</span>jsp<br>
            ├── cluster<span style="color: #0000cc;">.</span>jsp<br>
            ├── de<br>
            ├── en<br>
            ├── es<br>
            ├── explain<span style="color: #0000cc;">.</span>jsp<br>
            ├── fi<br>
            ├── fr<br>
            ├── hu<br>
            ├── img<br>
            ├── <span style="color: #ff0000;">include</span><br>
            ├── index<span style="color: #0000cc;">.</span>jsp<br>
            ├── it<br>
            ├── jp<br>
            ├── META<span style="color: #0000cc;">-</span>INF<br>
            ├── more<span style="color: #0000cc;">.</span>jsp<br>
            ├── ms<br>
            ├── nl<br>
            ├── pl<br>
            ├── pt<br>
            ├── refine<span style="color: #0000cc;">-</span>query<span style="color: #0000cc;">-</span>init<span style="color: #0000cc;">.</span>jsp<br>
            ├── refine<span style="color: #0000cc;">-</span>query<span style="color: #0000cc;">.</span>jsp<br>
            ├── <span style="color: #ff0000;">search</span><span style="color: #0000cc;">.</span>jsp<br>
            ├── sh<br>
            ├── sr<br>
            ├── sv<br>
            ├── text<span style="color: #0000cc;">.</span>jsp<br>
            ├── th<br>
            ├── <span style="color: #ff0102;">WEB-INF（要修改该文件夹下面的内容）</span><br>
            └── zh<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>修改此目录下的WEB-INF/classes/nutch-site.xml，修改如下：<br><br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">?</span>xml version<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"1.0"</span><span style="color: #0000cc;">?</span><span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">?</span>xml<span style="color: #0000cc;">-</span>stylesheet type<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"text/xsl"</span> href<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"nutch-conf.xsl"</span><span style="color: #0000cc;">?</span><span style="color: #0000cc;">&gt;</span><br>
            <br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">!</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span> Put site<span style="color: #0000cc;">-</span>specific property overrides in <span style="color: #0000ff;">this</span> <span style="color: #ff0000;">file</span><span style="color: #0000cc;">.</span> <span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">&gt;</span><br>
            <br>
            <span style="color: #0000cc;">&lt;</span>nutch<span style="color: #0000cc;">-</span>conf<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>property<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>name<span style="color: #0000cc;">&gt;</span>searcher<span style="color: #0000cc;">.</span>dir<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>name<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>value<span style="color: #0000cc;">&gt;</span><span style="color: #ff0102;">/home/**/nutch-1.0/crawled</span><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>value<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>property<span style="color: #0000cc;">&gt;</span><br>
            <span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>nutch<span style="color: #0000cc;">-</span>conf<span style="color: #0000cc;">&gt;</span><span style="color: #0000cc;"></span><span style="color: #0000cc;"></span><br>
            <span style="color: #0000cc;"></span>                </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
上面的value要改成蜘蛛的下载目录。<br><br>5.使用nutch搜索<br>&nbsp;<span style="color: #cc3333;"> </span><span style="font-weight: bold; color: #cc3333;">在浏览器中输入http://localhost:8080/nutch-1.0，出现下面的界面：</span><br>
<table width="635" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td rowspan="2" valign="bottom" width="140"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2F"><img  src="http://localhost:8080/nutch-1.0/img/reiter/logo_nutch.gif" border="0"></a><img  src="http://localhost:8080/nutch-1.0/img/reiter/spacer_666666.gif" height="1" width="140"></td>
        </tr>
        <tr>
            <td valign="bottom" width="495" align="right">
            <table width="495" border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td width="400" background="../img/reiter/_bg_reiter.gif">&nbsp;</td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_le1.gif" border="0"></td>
                        <td nowrap="nowrap" valign="bottom" background="../img/reiter/_bg_reiter_inactive.gif"><a  href="http://localhost:8080/nutch-1.0/zh/about.html" class="bodytext">简介</a></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_ri.gif" border="0"></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_le.gif" border="0"></td>
                        <td nowrap="nowrap" valign="bottom" background="../img/reiter/_bg_reiter_inactive.gif"><a  href="http://wiki.apache.org/nutch/FAQ" class="bodytext">常见问题</a></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_ri.gif" border="0"></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<table width="635" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr valign="top">
            <td width="140">
            <table width="100%" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>
                </tbody>
            </table>
            </td>
            <td width="20" background="../img/reiter/_spacer_cccccc.gif">&nbsp;</td>
            <td class="body" width="475">
            <table width="475" border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td class="title" height="125" valign="bottom" width="275"><br></td>
                        <td height="125" valign="bottom" width="200"><img  src="http://localhost:8080/nutch-1.0/img/reiter/robots.gif"></td>
                    </tr>
                </tbody>
            </table>
            <br class="br">
            <span class="bodytext">
            </span><span class="bodytext">
            </span><span class="bodytext">
            </span><span class="bodytext">
            <center>
            <form name="search" action="../search.jsp" method="get">
                <input name="query" size="44">&nbsp;<input value="搜索" type="submit">
                <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2Fhelp.html">帮助</a>
            </form>
            </center>
            </span><span class="bodytext">
            </span>
            <br class="br">
            <br class="br">
            </td>
        </tr>
    </tbody>
</table>
<table width="635" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td width="140">&nbsp;</td>
            <td width="20">&nbsp;</td>
            <td width="475" align="center">
            <span class="bodytext">
            <br>
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fca%2F">ca</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fde%2F">de</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fen%2F">en</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fes%2F">es</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Ffi%2F">fi</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Ffr%2F">fr</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fhu%2F">hu</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fit%2F">it</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fjp%2F">jp</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fms%2F">ms</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fnl%2F">nl</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fpl%2F">pl</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fpt%2F">pt</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsh%2F">sh</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsr%2F">sr</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsv%2F">sv</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fth%2F">th</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2F">zh</a>
            </span>
            </td>
        </tr>
        <tr>
        </tr>
    </tbody>
</table>
<span style="font-weight: bold; color: #990102;">然后在搜索框里面输入你要查找的东西，比如：linux</span><img  src="http://www.cublog.cn/images/face/004.gif" style="font-weight: bold; color: #990102;"><span style="font-weight: bold; color: #990102;">,会出现：</span><br style="color: #660102;">
<table width="635" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr style="color: #660102;">
            <td rowspan="2" valign="bottom" width="140"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2F"><img  src="http://localhost:8080/nutch-1.0/img/reiter/logo_nutch.gif" border="0"></a><img  src="http://localhost:8080/nutch-1.0/img/reiter/spacer_666666.gif" height="1" width="140"></td>
        </tr>
        <tr>
            <td valign="bottom" width="495" align="right">
            <table width="495" border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td width="400" background="../img/reiter/_bg_reiter.gif">&nbsp;</td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_le1.gif" border="0"></td>
                        <td nowrap="nowrap" valign="bottom" background="../img/reiter/_bg_reiter_inactive.gif"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2Fabout.html" class="bodytext">简介</a></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_ri.gif" border="0"></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_le.gif" border="0"></td>
                        <td nowrap="nowrap" valign="bottom" background="../img/reiter/_bg_reiter_inactive.gif"><a  href="http://my.chinaunix.net/link.php?url=http://wiki.apache.org%2Fnutch%2FFAQ" class="bodytext">常见问题</a></td>
                        <td height="28" valign="bottom" width="10"><img  src="http://localhost:8080/nutch-1.0/img/reiter/reiter_inactive_ri.gif" border="0"></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<form name="search" action="../search.jsp" method="get">
    <input name="query" size="44" value="linux">
    <input name="hitsPerPage" value="10" type="hidden">
    <input name="lang" value="zh" type="hidden">
    <input value="搜索" type="submit">
    <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2Fhelp.html">help</a>
</form>
第<strong>1-1</strong>项 (共有 1 项查询结果):
<br><br>
<strong><a  href="http://my.chinaunix.net/link.php?url=http://bbs.chinaunix.net%2F">论坛首页 - 中国最大的Linux/Unix技术社区 - IT人的网上社区 - bbs.ChinaUnix.net</a></strong>
<br><span class="ellipsis"> ... </span>Unix操作系统 &#8592; <span class="highlight">Linux</span>论坛 RSS订阅<span class="ellipsis"> ... </span>by CU管理员 <span class="highlight">Linux</span>时代首页 Linux<span class="ellipsis"> ... </span>
<br>
<span class="url">http://bbs.chinaunix.net/</span>
(<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fcached.jsp%3Fidx%3D0%26amp%3Bid%3D0">网页快照</a>)
(<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fexplain.jsp%3Fidx%3D0%26amp%3Bid%3D0%26amp%3Bquery%3Dlinux%26amp%3Blang%3D">评分详解</a>)
(<a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fanchors.jsp%3Fidx%3D0%26amp%3Bid%3D0">anchors</a>)
<br><br>
<table align="right" bgcolor="#3333ff">
    <tbody>
        <tr>
            <td bgcolor="#ff9900"><a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fopensearch%3Fquery%3Dlinux%26amp%3BhitsPerSite%3D2%26amp%3Blang%3D%26amp%3BhitsPerPage%3D10"><font color="#ffffff"><strong>RSS</strong>
            </font></a></td>
        </tr>
    </tbody>
</table>
<p>
<a  href="http://my.chinaunix.net/link.php?url=http://wiki.apache.org%2Fnutch%2FFAQ">
<img  src="http://localhost:8080/nutch-1.0/img/poweredbynutch_01.gif" border="0">
</a>
</p>
<table width="635" border="0" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td width="140">&nbsp;</td>
            <td width="20">&nbsp;</td>
            <td width="475" align="center">
            <span class="bodytext">
            <br>
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fca%2F">ca</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fde%2F">de</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fen%2F">en</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fes%2F">es</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Ffi%2F">fi</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Ffr%2F">fr</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fhu%2F">hu</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fit%2F">it</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fjp%2F">jp</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fms%2F">ms</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fnl%2F">nl</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fpl%2F">pl</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fpt%2F">pt</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsh%2F">sh</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsr%2F">sr</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fsv%2F">sv</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fth%2F">th</a> |
            <a  href="http://my.chinaunix.net/link.php?url=http://localhost%3A8080%2Fnutch-1.0%2Fzh%2F">zh</a>
            </span>
            </td>
        </tr>
        <tr>
        </tr>
    </tbody>
</table>
<span style="color: #990102; font-weight: bold;">整个过程就完成了。</span><img  src="http://www.cublog.cn/images/face/001.gif"><br><br>------------------------------------------------<br>|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: #ff0102;">过程中出现的问题</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>------------------------------------------------<br>1.说找不到JAVA_HOME<br>解决方案：修改/etc/environment文件，添加JAVA_HOME;<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;">PATH<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"</span><br>
            JAVA_HOME<span style="color: #0000cc;">=</span><span style="color: #ff00ff;">"/usr/lib/jvm/java-6-openjdk"</span><br>
            <span style="color: #0000cc;"></span>                                             </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>2.信息是抓取了，但是搜索不出来东西<br>解决方案：除了修改以上的东西外，有个文件还得注意下:/home/**/nutch-1.0/conf/nutch-default.xml,找到下面的部分，然后参照修改<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">!</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span> searcher properties <span style="color: #0000cc;">-</span><span style="color: #0000cc;">-</span><span style="color: #0000cc;">&gt;</span><br>
            <br>
            <span style="color: #0000cc;">&lt;</span>property<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>name<span style="color: #0000cc;">&gt;</span>searcher<span style="color: #0000cc;">.</span>dir<span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>name<span style="color: #0000cc;">&gt;</span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>value<span style="color: #0000cc;">&gt;</span><span style="color: #ff0102;">/home/**/nutch-1.0/crawled</span><span style="color: #0000cc;">&lt;</span><span style="color: #0000cc;">/</span>value<span style="color: #0000cc;">&gt;<span style="color: #ff0102;">（一定要是存抓取信息的路径）</span></span><br>
            &nbsp;&nbsp;<span style="color: #0000cc;">&lt;</span>description<span style="color: #0000cc;">&gt;</span></span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>有时候出不来结果，还得运行：<br>
<table style="border-collapse: collapse;" width="95%" bgcolor="#f1f1f1" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td>
            <p style="line-height: 150%; margin: 5px;"><code><span style="color: #000000;"><span style="color: #0000cc;">/</span>etc<span style="color: #0000cc;">/</span>init<span style="color: #0000cc;">.</span>d<span style="color: #0000cc;">/</span>tomcat6 restart<br>
            </span></code></p>
            </td>
        </tr>
    </tbody>
</table>
<br>呵呵，就这么多了！！！<img  src="http://www.cublog.cn/images/face/027.gif"><br><br><img src ="http://www.cppblog.com/AutomateProgram/aggbug/145657.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/AutomateProgram/" target="_blank">漂漂</a> 2011-05-04 13:34 <a href="http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145657.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>让Ubuntu用上网易的开源软件镜像</title><link>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145655.html</link><dc:creator>漂漂</dc:creator><author>漂漂</author><pubDate>Wed, 04 May 2011 05:28:00 GMT</pubDate><guid>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145655.html</guid><wfw:comment>http://www.cppblog.com/AutomateProgram/comments/145655.html</wfw:comment><comments>http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145655.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/AutomateProgram/comments/commentRss/145655.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/AutomateProgram/services/trackbacks/145655.html</trackback:ping><description><![CDATA[原文地址：http://www.softbunny.net/post/mirror_163_com_ubuntu_apt_deb.shtml<br><br>
<p>刚刚看到一篇<a  href="http://www.cnbeta.com/articles/76320.htm" target="_blank">＜隐藏在网易的开源软件镜象站点＞</a>，想到用网易的源来升级Ubuntu会不会速度快一点？</p>
<p>先是从&#8220;系统－系统管理－软件源－第三方软件&#8220;里一行一行地添加，但实在太麻烦了，还是从控制台下输入&#8221;sudo gedit /etc/apt/sources.list&#8220;直接编辑apt的Sources.list更快。在文件最后添加以下几行：</p>
<blockquote>
<div class="quote">deb http://mirrors.163.com/ubuntu/ intrepid main restricted universe multiverse<br>
deb http://mirrors.163.com/ubuntu/ intrepid-security main restricted universe multiverse<br>
deb http://mirrors.163.com/ubuntu/ intrepid-updates main restricted universe multiverse<br>
deb http://mirrors.163.com/ubuntu/ intrepid-proposed main restricted universe multiverse<br>
deb http://mirrors.163.com/ubuntu/ intrepid-backports main restricted universe multiverse<br>
deb-src http://mirrors.163.com/ubuntu/ intrepid main restricted universe multiverse<br>
deb-src http://mirrors.163.com/ubuntu/ intrepid-security main restricted universe multiverse<br>
deb-src http://mirrors.163.com/ubuntu/ intrepid-updates main restricted universe multiverse<br>
deb-src http://mirrors.163.com/ubuntu/ intrepid-proposed main restricted universe multiverse<br>
deb-src http://mirrors.163.com/ubuntu/ intrepid-backports main restricted universe multiverse</div>
</blockquote>
<p>这样一来就一次性地把所需的命令全加入了。记得保存退出。</p>
<p>试了一下，发现速度明显比原来要快了好多 <img  src="http://www.softbunny.net/wp-includes/images/smilies/icon_biggrin.gif" alt=":D" class="wp-smiley"> ，我在虚机里装的Ubuntu，用网易的源升级时速度基本上能保持在34K左右，远比以前的十几K要快得多。</p>
<p>另外，Felix分析，<a  href="http://www.ownlinux.cn/2009/02/05/ubuntu-wangyi-163-sourceslist/" target="_blank">163的源缺少部分软件包</a>，不过，应该已足够用的了。</p>
<br><br><img src ="http://www.cppblog.com/AutomateProgram/aggbug/145655.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/AutomateProgram/" target="_blank">漂漂</a> 2011-05-04 13:28 <a href="http://www.cppblog.com/AutomateProgram/archive/2011/05/04/145655.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu c++下连接mysql数据库和数据库的使用</title><link>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145557.html</link><dc:creator>漂漂</dc:creator><author>漂漂</author><pubDate>Tue, 03 May 2011 05:34:00 GMT</pubDate><guid>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145557.html</guid><wfw:comment>http://www.cppblog.com/AutomateProgram/comments/145557.html</wfw:comment><comments>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145557.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/AutomateProgram/comments/commentRss/145557.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/AutomateProgram/services/trackbacks/145557.html</trackback:ping><description><![CDATA[原文地址： <span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><a href="http://blog.sina.com.cn/s/blog_494e45fe0100k9p8.html" shape=rect><u><font color=#0000ff>http://blog.sina.com.cn/s/blog_494e45fe0100k9p8.html</font></u></a></span>&nbsp;&nbsp;<br><br><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">安装MySQL<br clear=none>代码:<br clear=none>sudo apt-get install mysql-server mysql-client</span>&nbsp;<br><br>这个时候ubuntu不会像windows那样会出现c api，要继续安装api<br><br>安<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">装开发包<br clear=none>代码:<br clear=none>sudo apt-get install libmysqlclient15-dev</span>&nbsp;<br><br><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">代码:<br clear=none>#include &lt;mysql.h&gt;</span>
<p><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">编译方法：<br clear=none>代码:<br clear=none>gcc $(mysql_config&nbsp;--cflags) xxx.c -o xxx $(mysql_config --libs)</span></p>
<br>
<div style="BORDER-BOTTOM: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid; PADDING-BOTTOM: 4px; BACKGROUND-COLOR: #eeeeee; PADDING-LEFT: 4px; WIDTH: 98%; PADDING-RIGHT: 5px; FONT-SIZE: 13px; WORD-BREAK: break-all; BORDER-TOP: #cccccc 1px solid; BORDER-RIGHT: #cccccc 1px solid; PADDING-TOP: 4px"><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"><span style="COLOR: #000000">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">mysql.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif">#include&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">stdio.h</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_45_743_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_743_Open_Text.style.display='none'; Codehighlighter1_45_743_Closed_Image.style.display='inline'; Codehighlighter1_45_743_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_45_743_Closed_Image onclick="this.style.display='none'; Codehighlighter1_45_743_Closed_Text.style.display='none'; Codehighlighter1_45_743_Open_Image.style.display='inline'; Codehighlighter1_45_743_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif">main()&nbsp;</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_45_743_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_45_743_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;MYSQL&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">conn;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;MYSQL_RES&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">res;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;MYSQL_ROW&nbsp;row;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">server&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">localhost</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">user&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">root</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">password&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">database&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">mysql</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;conn&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;mysql_init(NULL);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">mysql_real_connect(conn,&nbsp;server,<br><img id=Codehighlighter1_333_404_Open_Image onclick="this.style.display='none'; Codehighlighter1_333_404_Open_Text.style.display='none'; Codehighlighter1_333_404_Closed_Image.style.display='inline'; Codehighlighter1_333_404_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_333_404_Closed_Image onclick="this.style.display='none'; Codehighlighter1_333_404_Closed_Text.style.display='none'; Codehighlighter1_333_404_Open_Image.style.display='inline'; Codehighlighter1_333_404_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user,&nbsp;password,&nbsp;database,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,&nbsp;NULL,&nbsp;</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">))&nbsp;</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_333_404_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_333_404_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;mysql_error(conn));<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;<br><img id=Codehighlighter1_450_521_Open_Image onclick="this.style.display='none'; Codehighlighter1_450_521_Open_Text.style.display='none'; Codehighlighter1_450_521_Closed_Image.style.display='inline'; Codehighlighter1_450_521_Closed_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif"><img style="DISPLAY: none" id=Codehighlighter1_450_521_Closed_Image onclick="this.style.display='none'; Codehighlighter1_450_521_Closed_Text.style.display='none'; Codehighlighter1_450_521_Open_Image.style.display='inline'; Codehighlighter1_450_521_Open_Text.style.display='inline';" align=top src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(mysql_query(conn,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">show&nbsp;tables</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">))&nbsp;</span><span style="BORDER-BOTTOM: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BACKGROUND-COLOR: #ffffff; DISPLAY: none; BORDER-TOP: #808080 1px solid; BORDER-RIGHT: #808080 1px solid" id=Codehighlighter1_450_521_Closed_Text><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_450_521_Open_Text><span style="COLOR: #000000">{<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;mysql_error(conn));<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif">&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;res&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;mysql_use_result(conn);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">MySQL&nbsp;Tables&nbsp;in&nbsp;mysql&nbsp;database:\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">&nbsp;((row&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;mysql_fetch_row(res))&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;NULL)<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s&nbsp;\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,&nbsp;row[</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">]);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;mysql_free_result(res);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif">&nbsp;&nbsp;&nbsp;&nbsp;mysql_close(conn);<br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif">}</span></span><span style="COLOR: #000000"><br><img align=top src="http://www.cppblog.com/Images/OutliningIndicators/None.gif"></span></div>
<br>&nbsp;<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">会输出现有数据库和表内容。</span> <br><br>eclipse下要添加include路径，和链接库路径，<br>&nbsp;
<p><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">还需要添加对 -lmysqlclient -lm两个参数</span></p>
<p><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">&nbsp;项目-&gt;属性-&gt;C/C++Build -&gt; settings -&gt; gcc c linker-&gt; libraries&nbsp;</span></p>
<p><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">libraries(l) 中添加两个参数mysqlclient和m</span></p>
<br>不然还是出项找不到mysql_init()的错误。
<img src ="http://www.cppblog.com/AutomateProgram/aggbug/145557.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/AutomateProgram/" target="_blank">漂漂</a> 2011-05-03 13:34 <a href="http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145557.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu 安装Eclipse CDT IDE for C/C++</title><link>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145555.html</link><dc:creator>漂漂</dc:creator><author>漂漂</author><pubDate>Tue, 03 May 2011 05:24:00 GMT</pubDate><guid>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145555.html</guid><wfw:comment>http://www.cppblog.com/AutomateProgram/comments/145555.html</wfw:comment><comments>http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145555.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/AutomateProgram/comments/commentRss/145555.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/AutomateProgram/services/trackbacks/145555.html</trackback:ping><description><![CDATA[&nbsp;<br><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">首先到Eclipse官网http://www.eclipse.org/downloads/?osType=linux下载</span>&nbsp;<br><br><span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Tahoma; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px">然后打开终端，转到压缩包所在目录下，输入指令tar zvxf eclipse-cpp-helios-SR1-linux-gtk.tar.gz解压得到Eclipse文件夹，<br><br>转到该目录下执行./eclipse，就正常运行Eclipse了!</span> 
<img src ="http://www.cppblog.com/AutomateProgram/aggbug/145555.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/AutomateProgram/" target="_blank">漂漂</a> 2011-05-03 13:24 <a href="http://www.cppblog.com/AutomateProgram/archive/2011/05/03/145555.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>