﻿<?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>PHP博客-四季无望-随笔分类-Learning PHP</title><link>http://www.phpweblog.net/runpin/category/296.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 02 Mar 2008 00:08:00 GMT</lastBuildDate><pubDate>Sun, 02 Mar 2008 00:08:00 GMT</pubDate><ttl>60</ttl><item><title>在Ubuntu 7.10上搭建LAMP和ralis2.0.2开发环境</title><link>http://www.phpweblog.net/runpin/archive/2008/03/01/2865.html</link><dc:creator>四季无望</dc:creator><author>四季无望</author><pubDate>Sat, 01 Mar 2008 11:27:00 GMT</pubDate><guid>http://www.phpweblog.net/runpin/archive/2008/03/01/2865.html</guid><wfw:comment>http://www.phpweblog.net/runpin/comments/2865.html</wfw:comment><comments>http://www.phpweblog.net/runpin/archive/2008/03/01/2865.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.phpweblog.net/runpin/comments/commentRss/2865.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/runpin/services/trackbacks/2865.html</trackback:ping><description><![CDATA[在ubuntu 7.10上安装LAMP很简单，这里只是做一个记录，以备重装系统时需要。<br /><br /><b>第一步：配置网络</b><br />因为ubuntu默认安装是通过DHCP进行的，IP地址是动态的，但服务器需要一个静态IP地址，所以这里需要修改。当然，如果安装LAMP的目的只是为了在自己机器上玩玩儿，可以忽略这一步：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo vi </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">network</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">interfaces</span></div><br />修改interfaces之前，需要用ifconfig命令查看一下自己机器现在的IP地址，netmask应该都是255.255.255.0，我的路由器上的network是192.168.18.0，所以broadcast就是192.168.18.255，gateway就是192.168.18.1。除了IP地址，其他参数都可以在路由器的配置文件中看到。这样，interfaces的配置就修改为：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> This file describes the network interfaces available on your system<br /># and how to activate them. For more information, see interfaces(5).<br /><br /># The loopback network interface</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">auto lo<br />iface lo inet loopback<br /><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> The primary network interface</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">auto eth0<br />iface eth0 inet static<br />        address </span><span style="color: rgb(128, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">18.100</span><span style="color: rgb(0, 0, 0);"><br />        netmask </span><span style="color: rgb(128, 0, 0);">255.255</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">255.0</span><span style="color: rgb(0, 0, 0);"><br />        network </span><span style="color: rgb(128, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">18.0</span><span style="color: rgb(0, 0, 0);"><br />        broadcast </span><span style="color: rgb(128, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">18.255</span><span style="color: rgb(0, 0, 0);"><br />        gateway </span><span style="color: rgb(128, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">18.1</span></div><br />接着，重新启动网络：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo /</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">init</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">d</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">networking restart</span></div><br />最后，要修改主机名，把域名作为主机名，通过域名就可以访问你的主机了，比如我的就是www.maomao.com，呵呵：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo vi </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">hosts</span></div><br />把内容修改为：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(128, 0, 0);">127.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">0.1</span><span style="color: rgb(0, 0, 0);">       localhost</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">localdomain   localhost<br /></span><span style="color: rgb(128, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">18.100</span><span style="color: rgb(0, 0, 0);">   www</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com<br /><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> The following lines are desirable for IPv6 capable hosts</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">     ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">localhost ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">loopback<br />fe00</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">localnet<br />ff00</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mcastprefix<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allnodes<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allrouters<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(128, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allhosts</span></div><br />现在，执行：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo echo www</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com </span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">hostname<br /></span><span style="color: rgb(0, 0, 0);">sudo /</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">init</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">d</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">hostname</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">sh start</span></div><br />这样，主机名就修改好了，查看一下结果：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo hostname<br />sudo hostname </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">f</span></div><br />上面这两条命令得到的结果应该都是www.maomao.com，否则看看那一步有问题。<br /><br /><br /><b>第二步，安装一些开发必备的软件：<br /><br /></b><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install binutils cpp fetchmail flex gcc libarchive</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">zip</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">perl libc6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev libcompress</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">zlib</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">perl <br />libdb4</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev libpcre3 libpopt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev lynx m4 make ncftp nmap openssl perl perl</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">modules unzip zip zlib1g</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev <br />autoconf automake1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(128, 0, 0);">9</span><span style="color: rgb(0, 0, 0);"> libtool bison autotools</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev g</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);"> build</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">essential</span></div><br />再把Quota安装好，主要用来监视磁盘使用状况的，这是可选择的：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install quota</span></div><br />编辑<span class="system">/etc/fstab配置，主要是添加</span><span class="system">usrquota,grpquota到/（mount）点上去：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> /etc/fstab: static file system information.<br />#<br /># &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">proc            </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">proc           proc    defaults        </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">       </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> /dev/sda1</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">UUID</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">9fc157ff</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">975c</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">4f20</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">9fef</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">6a70085abdbd </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">               ext3    defaults</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">errors</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">remount</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ro</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">usrquota</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);"><br />grpquota </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">       </span><span style="color: rgb(128, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> /dev/sda5</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">UUID</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">48fb7dd8</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">f099</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">4d63</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ac1b</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">30e886ac7436 none            swap    sw              </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">       </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">dev</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">scd0       </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">media</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">cdrom0   udf</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">iso9660 user</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">noauto</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">exec</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">       </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">dev</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">fd0        </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">media</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">floppy0  auto    rw</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">user</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 0);">noauto</span><span style="color: rgb(0, 0, 0);">,</span><span style="color: rgb(0, 0, 255);">exec</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">       </span><span style="color: rgb(128, 0, 0);">0</span></div><br />接着就是启动Quota：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo touch </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">quota</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">user </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">quota</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">group<br /></span><span style="color: rgb(0, 0, 255);">sudo chmod</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(128, 0, 0);">600</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">quota</span><span style="color: rgb(0, 0, 0);">.*</span><span style="color: rgb(0, 0, 0);"><br />sudo mount </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">o remount </span><span style="color: rgb(0, 0, 0);">/</span></div><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo quotacheck </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">avugm<br />sudo quotaon </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">avug</span></div><br /><b><br />第三步，安装MySQL<br /><br /></b><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">server mysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">client libmysqlclient15</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev</span></div><br />结束的时候会要求你输入root密码，注意这里不是ubuntu的root密码，是MySQL的root密码，随便了，但是它只会要你输入一次，所以不要搞错了，免得以后又要修改：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">New password </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);"> the MySQL </span><span style="color: rgb(0, 0, 0); font-weight: bold;">"</span><span style="color: rgb(0, 0, 0); font-weight: bold;">root</span><span style="color: rgb(0, 0, 0); font-weight: bold;">"</span><span style="color: rgb(0, 0, 0);"> user</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">&lt;--</span><span style="color: rgb(0, 0, 0);"> 我的MySQL密码</span></div><br />然后是修改MySQL的配置文件，让它监视所有端口，而不只是localhost的，这一步是可选的，如果只是玩玩儿的话：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo vi </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 255);">my</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">cnf</span></div><br />找到</span><span class="system">bind-address           = 127.0.0.1，把它注释掉：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);"><img src="http://www.phpweblog.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);">]<br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> Instead of skip-networking the default is now to listen only on<br /># localhost which is more compatible and is not less secure.<br />#bind-address           = 127.0.0.1<br />#</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);"><img src="http://www.phpweblog.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);">]</span></div><br />重启MySQL：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo /</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">init</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">d</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">mysql restart</span></div><br />看看它是否生效了：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo netstat </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tap </span><span style="color: rgb(0, 0, 0);">|</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">grep</span><span style="color: rgb(0, 0, 0);"> mysql</span></div><br />输出应该类似如下：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(128, 0, 128);">@www</span><span style="color: rgb(0, 0, 0);">:~</span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> netstat -tap | grep mysql</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">tcp        </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(128, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">*:</span><span style="color: rgb(0, 0, 0);">mysql                 </span><span style="color: rgb(0, 0, 0);">*:*</span><span style="color: rgb(0, 0, 0);">                     </span><span style="color: rgb(0, 0, 255);">LISTEN</span><span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(128, 0, 0);">5286</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">mysqld<br />maomao</span><span style="color: rgb(128, 0, 128);">@www</span><span style="color: rgb(0, 0, 0);">:~</span><span style="color: rgb(0, 128, 0);">#</span></div><br /><b>第四步：安装Apache2和PHP5<br /><br /></b><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install apache2 apache2</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">doc apache2</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mpm</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">prefork apache2</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">utils libexpat1 ssl</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">cert</span></div><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install libapache2</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mod</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">php5 php5 php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">common php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">curl php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">gd php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">idn php</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">pear <br />php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">imagick php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">imap</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"> php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mcrypt php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">memcache php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mhash php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ming php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mysql php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ps php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">pspell <br />php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">recode php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">snmp php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">sqlite php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">tidy php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">xmlrpc php5</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">xsl</span></div><br />这一步会询问</span><span class="system">Continue installing libc-client without Maildir support?，点击forward就可以了。<br /><br />然后要编辑</span><span class="system">/etc/apache2/mods-available/dir.conf文件，把修改一下index的默认类型：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">IfModule mod_dir</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">c</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /><br />      </span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">DirectoryIndex index.html index.cgi index.pl index.php index.xhtml</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">      DirectoryIndex </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">html </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">htm </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">shtml </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">cgi </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">php </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">php3 </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">pl </span><span style="color: rgb(0, 0, 255);">index</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">xhtml<br /><br /></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">IfModule</span><span style="color: rgb(0, 0, 0);">&gt;</span></div><br />现在，启动一些Apache2的模块，很有用的：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo a2enmod ssl<br />sudo a2enmod rewrite<br />sudo a2enmod suexec<br />sudo a2enmod include</span></div><br />最后要重启Apache2：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sduo /</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">init</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">d</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache2 force</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">reload</span></div><br /><b>第五步：建立一个Apache2的虚拟HOST：</b><br /><br />这个不用说了，用处大了，即使你是玩玩儿。这样至少不用把所有PHP文件放到/var/www下面才能使用，你可以放到自己家目录下或者任何方便维护的地方。<br /><br />我们要在/etc/apache2/sites-available下新建一个文件，比如这里是maomao.com.conf，内容如下：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">VirtualHost www</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />ServerAdmin info</span><span style="color: rgb(128, 0, 128);">@localhost</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">我们这里要使用www.maomao.com和local.maomao.com这两个域名</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">ServerAlias local</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com<br />DocumentRoot </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">home</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">public_html<br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">if using awstats</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">ScriptAlias </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">awstats</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">lib</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">cgi</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">指定log文件的位置</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">CustomLog </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">var</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 255);">log</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache2</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">access</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 255);">log</span><span style="color: rgb(0, 0, 0);"> combined<br /></span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">VirtualHost</span><span style="color: rgb(0, 0, 0);">&gt;</span></div><br />然后，</span>切换到/etc/apache2/sites-enabled/目录下，在这里建立一个链接：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache2</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">sites</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">available</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">conf maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">conf</span></div><br />再到/etc/hosts里添加local.maomao.com：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">127.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">0.1</span><span style="color: rgb(0, 0, 0);">    localhost</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">localdomain    localhost<br /></span><span style="color: rgb(0, 0, 0);">127.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">1.1</span><span style="color: rgb(0, 0, 0);">    ubuntu</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">localhost    ubuntu<br /></span><span style="color: rgb(0, 0, 0);">192.168</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">18.6</span><span style="color: rgb(0, 0, 0);"> www</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com local</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">com<br /><br /></span><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);"> The following lines are desirable for IPv6 capable hosts</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">     ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">localhost ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">loopback<br />fe00</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">localnet<br />ff00</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">mcastprefix<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allnodes<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allrouters<br />ff02</span><span style="color: rgb(0, 0, 0);">::</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);"> ip6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">allhosts</span></div><br />OK，重启Apache2：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo /</span><span style="color: rgb(0, 0, 0);">etc</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">init</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">d</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">apache2 reload</span></div><br />在<span class="system"><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">home</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">maomao</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">public_html下建立一个phpinfo.php文件，内容为：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">&lt;?</span><span style="color: rgb(0, 0, 0);">php<br /></span><span style="color: rgb(0, 128, 128);">phpinfo</span><span style="color: rgb(0, 0, 0);">();<br /></span><span style="color: rgb(0, 0, 0);">?&gt;</span></div><br />然后，打开firefox，输入：http://local.maomao.com/phpinfo.php，看看是否正常工作。<br /><br />至此，LAMP就搞定了。下面是配置rails的开发环境。<br /><br /><b>第六步：建立rails开发环境</b><br /><br />现在的rails的版本是2.0.2，使用SQLite作为默认数据库，而且似乎不启动数据库就搞不定一个基本的HelloWorld，改动实在太。。。，唉，接着来：<br /><br />基本步骤是安装Ruby、SQLite、gem、rails和mongrel：<br /><br /><b>安装Ruby</b>：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install </span><code>ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby</code><span style="color: rgb(0, 0, 0);"></span></div><br />然后建立链接：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">ruby1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">ruby<br />sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">ri1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">ri<br />sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">rdoc1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">rdoc<br />sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">irb1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">local</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">irb</span></div><br />查看是否正常安装：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">ruby </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">v</span></div><br /><b>安装</b></span></span><b>rubygems</b>：<br /><br />可以用apt安装，但是版本是0.9.4的，还要升级，很麻烦，不如直接下载安装：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">mkdir</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">~/</span><span style="color: rgb(0, 0, 0);">sources<br />cd </span><span style="color: rgb(0, 0, 0);">~/</span><span style="color: rgb(0, 0, 0);">sources<br /></span><span style="color: rgb(0, 0, 0);"><img src="http://www.phpweblog.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);"><br />wget http</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br />tar xzvf rubygems</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">tgz<br />cd  rubygems</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);"><br /><br />sudo ruby setup</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">rb<br /></span><span style="color: rgb(0, 0, 0);"><img src="http://www.phpweblog.net/images/dot.gif" /></span><span style="color: rgb(0, 0, 0);"><br />sudo ln </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">s </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">gem1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">usr</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">bin</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">gem</span></div><br />看看版本：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">gem </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">v</span></div><br />无论什么时候，要升级，输入：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem update<br />sudo gem update </span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 128, 128);">system</span></div><br /><b>安装SQLite：<br /></b><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install sqlite3 libsqlite3</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);"> libsqlite3</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev</span></div><br /><b>安装MySQL的ruby支持：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo apt</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">get install  libmysql</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ruby1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span></div><br /><b>安装rake：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem install rake</span></div><br /><b>安装rails：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem install rails </span><span style="color: rgb(0, 0, 0);">--</span><span style="color: rgb(0, 0, 0);">source http</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">gems.rubyonrails.org/</span></div><br /><b>安装</b><span><b>mongrel：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem install mongrel</span></div><br /><b>让rails可以访问SQLite：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem install sqlite3</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ruby</span></div><br /><b>让rails可以访问MySQL：</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo gem install mysql</span></div><br /><b>安装imagemagick:</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo aptitude install imagemagick librmagick</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ruby1</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">8</span><span style="color: rgb(0, 0, 0);"> librmagick</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">ruby</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">doc libfreetype6</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">dev xml</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">core</span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);"></span></div><br />检查一下是否正确：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">irb<br />#irb(main):</span><span style="color: rgb(0, 0, 0);">001</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />require </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">RMagick</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br />#</span><span style="color: rgb(0, 0, 0);">=&gt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);"><br />#irb(main):</span><span style="color: rgb(0, 0, 0);">002</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />require </span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">mysql</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br />#</span><span style="color: rgb(0, 0, 0);">=&gt;</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);"><br />#irb(main):</span><span style="color: rgb(0, 0, 0);">003</span><span style="color: rgb(0, 0, 0);">:</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />exit</span></div><br /><b>最后，安装</b></span><b>postfix和subversion<br /><br /></b><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">sudo aptitude install postfix subversion</span></div><br />OK，目前足够了，下面就是建立一个简单的测试app，看看一切是否正常：<br /><br />首先，家目录下建立一个新目录rails，在这个目录里打开控制台，输入：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">rails </span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">d mysql demo</span></div><br />这里，目的是建立一个名为demo的应用程序，但是rails 2.0.2默认的数据库是SQLite，所以要加-d mysql参数，如果使用的是SQLite，则无需这么做。<br /><br />然后，进入demo目录，输入：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">ruby script</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">generate controller App</span></div><br />打开app/controllers/app_controller.rb文件，内容为：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> AppController </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> ApplicationController<br />end</span></div><br />修改成：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> AppController </span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);"> ApplicationController<br />    def greeting<br />    end<br />end</span></div><br />接着，在app/views/app中新建一个文件greeting.rhtml，内容是：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">Ruby on Rails</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">title</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">head</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">h1</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">maomao，你吃了没有！</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">h1</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">body</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">html</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br />启动phpmyadmin建立一个新的数据库，名字是demo，用户名是maomao，密码maomao，然后修改demo/config目录下的database.yml，只需修改development部分就可以了：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">development:<br />    adapter: mysql<br />    encoding: utf8<br />    database: demo<br />    username: maomao<br />    password: maomao<br />    socket: /var/run/mysqld/mysqld.sock</span></div><br />最后，在demo目录下启动mongrel服务器：<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">ruby script/server</span></div><br />在firefox中输入地址：http://localhost:3000/app/greeting,如果看见“maomao，你吃了没有!”，那就搞定了。<br /><br /><img src ="http://www.phpweblog.net/runpin/aggbug/2865.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/runpin/" target="_blank">四季无望</a> 2008-03-01 19:27 <a href="http://www.phpweblog.net/runpin/archive/2008/03/01/2865.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在xampp中安装GeSHi</title><link>http://www.phpweblog.net/runpin/archive/2007/09/21/1989.html</link><dc:creator>四季无望</dc:creator><author>四季无望</author><pubDate>Fri, 21 Sep 2007 02:42:00 GMT</pubDate><guid>http://www.phpweblog.net/runpin/archive/2007/09/21/1989.html</guid><wfw:comment>http://www.phpweblog.net/runpin/comments/1989.html</wfw:comment><comments>http://www.phpweblog.net/runpin/archive/2007/09/21/1989.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.phpweblog.net/runpin/comments/commentRss/1989.html</wfw:commentRss><trackback:ping>http://www.phpweblog.net/runpin/services/trackbacks/1989.html</trackback:ping><description><![CDATA[
		<h2>一、简介</h2>
		<p>
				<tt>GeSHi</tt>是什么东西？简单说，就是一个软件，用来加亮网页中的源代码。名称据说跟中国的“夏至”有关系，没有具体研究过。不过这个名字刚好和汉语拼音中的“格式”同音。它的英文全名是"<tt>Generic Syntax Highlighter</tt>"，也就是“通用语法加亮器”。具体细节可以到<a title="GeSHi" href="http://qbnz.com/highlighter/" target="_blank">GeSHi</a>网站上研究。</p>
		<p>很多博客和维基都集成了<tt>GeSHi</tt>，比如<tt>wordpress</tt>、<tt>dokuwiki</tt>等。不过呢，如果自己有一个网站，写了很多源码想给人看，如何让这些源码美观一些，就像在<tt>vim</tt>等编辑器中显示的那么漂亮呢。下满是我安装的一些经验：</p>
		<h2>二、安装</h2>
		<p>我用<tt>xampp</tt>建立在本本上建立了一个<tt>Apache</tt>、<tt>MySQL</tt>和<tt>PHP</tt>的开发环境。在<tt>C</tt>盘根目录上有一个文件夹是<tt>xampp</tt>。文档根目录在<tt>C:\xampp\htdocs</tt>，<tt>http://localhost/</tt>就是从这里开始。</p>
		<p>下载<tt>GeSHi</tt>，解压到<tt>C:\xampp\php\includes</tt>。<tt>GeSHi</tt>的文档说可以放到别处，但实际很麻烦。<tt>GeSHi</tt>本身就是<tt>PHP</tt>的一个类，使用<tt>include</tt>调用，所以不如直接加到<tt>PHP</tt>的<tt>include</tt>路径中去。如果没有<tt>includes</tt>文件夹，自己建立一个，然后把解压后的文件放到里面。注意，<tt>includes</tt>里应该有一个文件叫<tt>geshi.php</tt>，还有三个文件夹<tt>contrib</tt>、<tt>docs</tt>和<tt>geshi</tt>。</p>
		<p>接下来，修改<tt>php.ini</tt>文件，这个文件在<tt>C:\xampp\apache\bin</tt>中，打开后，在447行上可以看见：</p>
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #000000">include_path </span>
				<span style="COLOR: #000000">=</span> <span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.;C:\xampp\php\pear\</span><span style="COLOR: #000000">"</span></div>
		<br />修改为：<br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">include_path </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.;C:\xampp\php\pear\;C:\xampp\php\includes\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span></div><p>这其实就是把<tt>GeSHi</tt>所在的路径加到<tt>php.ini</tt>文件里。安装到此就完成。</p><h2>三、使用</h2><p>这里有段用<tt>vim</tt>写的<tt>C++</tt>代码：</p><img height="284" alt="cpp.png" src="http://www.phpweblog.net/images/phpweblog_net/runpin/cpp.png" width="740" border="0" /><p>要把彩色代码在网页上显示的话，可以直接用<tt>vim</tt>转换成<tt>HTML</tt>格式复制到网页上。但这里是要用<tt>GeSHi</tt>来实现，所以呢，使用下面的方法：</p><p>在<tt>htdocs</tt>文件夹里新建一个<tt>PHP</tt>文件，<tt>highlighter.php</tt>。内容如下（这段代码改编自<tt>GeSHi</tt>的说明文档）：</p><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><span style="COLOR: #000000">&lt;?</span><span style="COLOR: #000000">php<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 包含GeSHi库</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">include_once</span><span style="COLOR: #000000">(</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">geshi.php</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 定义需要加亮的源代码<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />// 定义需要何种语言来加亮</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #800080">$source</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">#include &lt;iostream&gt;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />using namespace std;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />int main()<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />{<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    cout &lt;&lt; "这是很简单的C++代码！" &lt;&lt; endl;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />    return 0;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" />}</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #800080">$language</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">cpp</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">;<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 建立一个GeSHi的对象</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #800080">$geshi</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">=&amp;</span><span style="COLOR: #000000"> </span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000"> GeSHi(</span><span style="COLOR: #800080">$source</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">  </span><span style="COLOR: #800080">$language</span><span style="COLOR: #000000">);<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 输出加亮后的结果</span><span style="COLOR: #008000"><br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #0000ff">echo</span><span style="COLOR: #000000"> </span><span style="COLOR: #800080">$geshi</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">parse_code();<br /><img src="http://www.phpweblog.net/images/OutliningIndicators/None.gif" align="top" /></span><span style="COLOR: #000000">?&gt;</span></div><p>在浏览器中输入：<tt>http://localhost/hello_cpp.php</tt>，就会看到彩色工整的源代码了。下面是在<tt>editplus</tt>中的效果：</p><img height="383" alt="high.png" src="http://www.phpweblog.net/images/phpweblog_net/runpin/high.png" width="751" border="0" /><h2>说明：</h2><p>上面那段代码执行的时候有些迟滞，这和<tt>GeSHi</tt>以及<tt>include_once()</tt>函数有关，如果你的网页上有很多需要加亮的代码，感觉会更明显。</p><p>那段代码中的<tt>$source</tt>变量后跟随的内容就是需要加亮的代码。</p><img src ="http://www.phpweblog.net/runpin/aggbug/1989.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.phpweblog.net/runpin/" target="_blank">四季无望</a> 2007-09-21 10:42 <a href="http://www.phpweblog.net/runpin/archive/2007/09/21/1989.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>