Apache VirtualHost 配置

OS: ubuntu 12.04 Apache: 2.2.22

Configure file: /etc/apache2/sites-available/default

NameVirtualHost [IP Address]

<VirtualHost [IP Address]>
        ServerName www.asite.com
        ServerAdmin [email protected]

        DocumentRoot /var/www/asite

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /var/www/asite>
                #Options Indexes FollowSymLinks MultiViews
                Options -Indexes
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


<VirtualHost [IP Address]>
        ServerName www.bsite.com
        ServerAdmin [email protected]

        DocumentRoot /var/www/bsite

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /var/www/bsite>
                #Options Indexes FollowSymLinks MultiViews
                Options -Indexes 
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

配置ibus使支持skype

编辑配置文件/etc/X11/xinit/xinput.d/default

XIM=ibus                           
XIM_PROGRAM=/usr/bin/ibus-daemon
XIM_ARGS="--xim"                   
XIM_PROGRAM_XTRA=                  
XIM_PROGRAM_SETS_ITSELF_AS_DAEMON=
                                 
GTK_IM_MODULE=ibus                 
QT_IM_MODULE=ibus                  
                                                                    
DEPENDS="ibus, ibus-gtk, ibu-qt4"

在VIM中获取SU权限保存文件

有时候用VIM编辑一个系统文件的时候会忘了使用su权限,咔咔咔一阵忙碌,满意后一保存发现自己没有写权限,当时整个人几乎就是崩溃的了。如果这时候你热血上脑,放弃编辑重新来过,那真是亏大了,也说明你对万能的VIM的实力认识还远远不够^_^ 看看VIM是怎么拯救你的吧:

:w !sudo tee %

YEAR,就是这么简单。

简单说明一下这条命令:

  • :

  • vim的命令模式提示符

  • w

  • vim的保存命令

  • !

  • 在vim中执行外部命令

  • sudo tee

  • 使用su权限执行tee命令,这条是关键。tee是linux命令: read from standard input and write to standard output and files

  • %

  • vim中的一个只读寄存器,总保存着当前文件路径

PHP 简单分页

<table border="1" cellpadding="20" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#999999">
   <tr align="center" bgcolor="#666666">
        <td width="50">Id</td>
        <td width="221">Name</td>
        <td width="329">Age</td>
   </tr>

<?php 
    $conn = mysql_connect("localhost", "root", "") or die(mysql_error());
    mysql_select_db("testDB", $conn) or die(mysql_error());

    $page_num = isset($_GET['page_num']) ? intval($_GET['page_num']) : 1; 

    $page_size = 5;   // show 5 records per page

    $query = "select count(*) as total from persons order by id";
    $result = mysql_query($query);
    $total_records = mysql_result($result, 0, "total");

    $page_count = ceil($total_records / $page_size);
    $offset = ($page_num - 1) * $page_size;
 
    //实现分页的关键代码,注意必须要排序。
    $query = "select * from persons order by id limit $offset, $page_size";
    $result = mysql_query($query);
    
    while($row = mysql_fetch_object($result)) {
?>
    <tr bgcolor="#FFFFFF">
        <td><?php echo $row->id?></td>
        <td><?php echo $row->name?></td>
        <td><?php echo $row->age?></td>
    </tr>

<?php
    }
?>
</table>

<table border="0" cellpadding="5">
    <tr>
        <td width="100" align="center">
        Current: <?php echo $page_num;?>
        </td>

        <td width="50" align="center">
<?php
    if($page_num != 1) {
        echo "<a href=splitpages.php?page_num=1>First</a>";
?>
        </td>
        <td width="50" align="center">
<?php
        echo "<a href=splitpages.php?page_num=" . ($page_num - 1) . ">Prev</a>";
    }
?>

        </td>
        <td width="50" align="center">
<?php
    if($page_num < $page_count) {
        echo "<a href=splitpages.php?page_num=" . ($page_num + 1) . ">Next</a>";
?>
        </td>
        <td width="50" align="center">
<?php
        echo "<a href=splitpages.php?page_num=" . $page_count . ">Last</a>";
    }
?>
        </td>
    <tr>
</table>

Wordpress 地址和站点地址

mysql> describe wp_options;
+--------------+---------------------+------+-----+---------+----------------+
| Field        | Type                | Null | Key | Default | Extra          |
+--------------+---------------------+------+-----+---------+----------------+
| option_id    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
| option_name  | varchar(64)         | NO   | UNI |         |                |
| option_value | longtext            | NO   |     | NULL    |                |
| autoload     | varchar(20)         | NO   |     | yes     |                |
+--------------+---------------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

mysql> select * from wp_options where option_name=siteurl;
ERROR 1054 (42S22): Unknown column 'siteurl' in 'where clause'
mysql> select * from wp_options where option_name="siteurl";
+-----------+-------------+-------------------+----------+
| option_id | option_name | option_value      | autoload |
+-----------+-------------+-------------------+----------+
|         1 | siteurl     | http://vgeez.com/ | yes      |
+-----------+-------------+-------------------+----------+
1 row in set (0.00 sec)

mysql> select * from wp_options where option_name="home";
+-----------+-------------+------------------+----------+
| option_id | option_name | option_value     | autoload |
+-----------+-------------+------------------+----------+
|        36 | home        | http://vgeez.com | yes      |
+-----------+-------------+------------------+----------+
1 row in set (0.00 sec)