So Tired !_! 逆水行舟, 不进则退!

29May/12

How do I setup dual monitors in XFCE?

Posted by Nick Xu

First, open up monitor config - it's in Start > Settings > Settings Manger, then open the Display item.

Make sure both your displays are on. enter image description here

Then, open a terminal and run this:

xrandr

The output will look something like this:

Screen 0: minimum 320 x 200, current 2464 x 900, maximum 4096 x 4096 LVDS1 connected 1024x600+1440+0 (normal left inverted right x axis y axis) 220mm x 129mm 1024x600 60.0*+ 65.0
800x600 60.3 56.2
640x480 59.9
VGA1 connected 1440x900+0+0 (normal left inverted right x axis y axis) 408mm x 255mm 1440x900 59.9*+ 75.0
1280x1024 75.0 60.0
1280x960 60.0
1280x800 74.9 59.8
1152x864 75.0
1024x768 75.1 70.1 60.0
832x624 74.6
800x600 72.2 75.0 60.3 56.2
640x480 72.8 75.0 66.7 60.0
720x400 70.1

Then, run the following, changing VGA1 and LVDS1 to match the appropriate display:

xrandr --output VGA1 --left-of LVDS1

Note that you can move change --left-of to --right-of.

Now, it should work, but you've still got one problem.

It will disappear after you logout. So, you need to add it to your login items.

Head over to Start > Settings > Settings Manger, then open "Session and Startup", add the above command to your login items, and you're good to go!

enter image description here

Filed under: Linux No Comments
28May/12

给PHP加速,eAccelerator配置和使用指南

Posted by Nick Xu

Trackback URL: http://www.toplee.com/blog/wp-trackback.php?p=100

前一段时间完成了服务器从FreeBSD4.10到6.1的升级,同时把PHP也升级到了最新的PHP5.1.4,Apache也升级到了最新的Apache2.2,为了更好的提高系统的性能,考虑对PHP再进行一些优化,前两年接触过MMCache和eAccelerator,尤其对eAccelerator非常喜欢,这次优化也选择了它,下面整理一些文档和大家分享。

 

目录:
一、eAccelerator介绍
1、背景
2、原理
二、安装和配置
1、支持平台
2、系统要求
3、安装
4、php.ini文件配置
5、验证安装
三、使用eAccelerator开发PHP代码
1、API文档和接口说明
2、开发范例
四、附录和参考资料

一、eAccelerator介绍

1、背景
eAccelerator 是一个免费开源的PHP加速、优化、编译和动态缓存的项目,它可以通过缓存PHP代码编译后的结果来提高PHP脚本的性能,使得一向很复杂和离我们很远的PHP脚本编译问题完全得到解决。通过使用eAccelerator,可以优化你的PHP代码执行速度,降低服务器负载,可以提高PHP应用执行速度最高达10倍。

eAccelerator 项目诞生于2004年,当时它是作为 Turck MMCache 项目的一个分支提出并投入开发的。 Turck MMCache 由 Dmitry Stogov 开发,是个非常优秀的PHP内存缓存加速系统,如今仍然有很大部分 eAccelerator 的代码应用到该项目中,目前该项目有很长时间没有更新了,对于最新的PHP5.x的支持还未推出。

2、原理
eAccelerator 通过把经过编译后的PHP代码缓存到共享内存中,并在用户访问的时候直接调用从而起到高效的加速作用。它的效率非常高,从创建共享内存到查找编译后的代码都在非常短的时间内完成,对于不能缓存到共享内存中的文件和代码,eAccelerator还可以把他们缓存到系统磁盘上。

eAccelerator 同样还支持PHP代码的编译和解释执行,你可以通过encoder.php脚本来对php代码进行编译达到保护代码的目的,经过编译后的代码必须运行在安装了eAccelerator的环境下。eAccelerator编译后的代码不能被反编译,它不象其他一些编译工具那样可以进行反编译,这将使得代码更加安全和高效。

二、eAccelerator安装配置

1、支持平台
由于aAccelerator提供了大部分基于共享内存的API,所以在*nix的平台上将得到更好的支持,虽然也发布了基于windows平台的binary版本,但我在这里就只提供基于*nix平台的配置和说明,目前可以支持的平台包括Linux, FreeBSD, OpenBSD, Mac OS X, Solaris, AIX en HP-UX。

2、系统要求
php4 or php5
autoconf
automake
libtool
m4
eAccelerator 只支持使用 mod_php 或者 fastcgi mode 安装的PHP

3、安装
先去eAccelerator官方下载最新版的源码包:http://sourceforge.net/projects/eaccelerator/files/eaccelerator/

#tar -zxvf ./eaccelerator-0.9.5-beta2.tar.bz2
#cd eaccelerator-0.9.5-beta2
#export PHP_PREFIX="/usr/local" (把PHP安装目录导入到环境变量,FreeBSD默认是/usr/local)
#$PHP_PREFIX/bin/phpize
#./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
#make
#make install

4、ini文件配置
安装完成,下面开始配置php.ini文件,eAccelerator提供了两种配置和调用方式,分别如下。

安装为 Zend extension 模式:

zend_extension="/usr/local/lib/php/20050922/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

如果你使用了thread safe模式安装的PHP,你必须使用 “zend_extension_ts” 替换第一行的 “zend_extension”.

安装为 PHP extension 模式:(这是大部分采用的方式)

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.log_file = "/var/log/httpd/eaccelerator_log"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

有关php.ini文件的详细配置说明,请参照源码目录的README文档或者访问官方文档:ini setting

完成安装配置后,我们最后要创建缓存目录

#mkdir /tmp/eaccelerator
#chmod 777 /tmp/eaccelerator

5、验证安装结果
通过浏览器访问您的phpinfo()页面或者运行 php -i 得到php配置信息,里面如果看到类似下面的信息就表示安装成功了。

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

我的机器上同时还安装了Zend Optimizer3.0.1,所以看到的信息如下:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies
with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies

如果你打开了eAccelerator的debug选项,可以从日志中看到类似下面的信息

#tail /var/log/httpd/eAccelerator_log
EACCELERATOR hit: "/var/www/toplee.com/blog/index.php"
EACCELERATOR hit: "/var/www/toplee.com/blog/wp-blog-header.php"
EACCELERATOR hit: "/var/www/toplee.com/blog/wp-config.php"
EACCELERATOR hit: "/var/www/toplee.com/blog/wp-settings.php"
EACCELERATOR hit: "/var/www/toplee.com/blog/wp-content/plugins/wp-cache/wp-cache-phase1.php"
...

以上信息表示文件都得到了缓存和命中。

至此,我们就完成了全部的安装和配置,好好享受eAccelerator带给你的惊喜吧,根据Michael的测试,效果的确相当的好。

三、在PHP中可以使用eAccelerator的API开发

1、API和文档说明:

eAccelerator提供了便捷便捷而又稳定的本机缓存实现方式,由于大部分代码实现基于共享内存,所以只能在*nix平台中使用,Windows平台Michael就暂时不知道何时有这方面的支持了。
eAccelerator提供如下的API接口和文件:(下述文件均在源码包的doc/php/目录下)

文件列表:

cache.php
dasm.php
encoder.php
info.php
loader.php
session.php
shared_memory.php

接口列表:

array eaccelerator_cached_scripts ()
void eaccelerator_cache_output (string $key, string $eval_code, [int $ttl = 0])
void eaccelerator_cache_page (string $key, [int $ttl = 0])
void eaccelerator_cache_result (string $key, string $code, [int $ttl = 0])
void eaccelerator_caching (boolean $flag)
void eaccelerator_clean ()
void eaccelerator_clear ()
array eaccelerator_dasm_file (mixed $filename)
mixed eaccelerator_encode (mixed $src, [mixed $prefix = ''], [string $pre_content = ''], [string $post_content = ''])
void eaccelerator_gc ()
mixed eaccelerator_get (string $key)
array eaccelerator_info ()
array eaccelerator_list_keys ()
void eaccelerator_load ()
boolean eaccelerator_lock (string $key)
void eaccelerator_optimizer (boolean $flag)
void eaccelerator_purge ()
boolean eaccelerator_put (string $key, mixed $value, [int $ttl = 0])
array eaccelerator_removed_scripts ()
boolean eaccelerator_rm (string $key)
void eaccelerator_rm_page (string $key)
boolean eaccelerator_set_session_handlers ()
boolean eaccelerator_unlock (string $key)

有关上述文档详细说明请参考官方文档:API Documents

下面有部分网友翻译后的接口说明:

eaccelerator_put($key, $value, $ttl=0)
将 $value 以 $key 为键名存进缓存(php4下支持对像类型,看源码好像zend2里不支持了),$ttl 是这个缓存的生命周期,单位是秒,省略该参数或指定为 0 表示不限时,直到服务器重启清空为止。eaccelerator_get($key)
根据 $key 从缓存中返回相应的 eaccelerator_put() 存进去的数据,如果这项缓存已经过期或不存在那么返回值是 NULL

eaccelerator_rm($key)
根据 $key 移除缓存

eaccelerator_gc()
移除清理所有已过期的 key

eaccelerator_lock($key)
为 $key 加上锁定操作,以保证多进程多线程操作时数据的同步。需要调用 eaccelerator_unlock($key) 来释放这个锁或等待程序请求结束时自动释放这个锁。
例如:
<?php
eaccelerator_lock("count");
eaccelerator_put("count",eaccelerator_get("count")+1));
?>

eaccelerator_unlock($key)
根据 $key 释放锁

eaccelerator_cache_output($key, $eval_code, $ttl=0)
将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclerator_put)
例如:
<?php eaccelerator_cache_output('test', 'echo time(); phpinfo();',30); ?>

eaccelerator_cache_result($key, $eval_code, $ttl=0)
将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output
例如:
<?php eaccelerator_cache_result('test', ' time() . "Hello";', 30); ?>

eaccelerator_cache_page($key, $ttl=0)
将当前整页缓存 $ttl 秒。
例如:
<?php
eaccelerator_cache_page($_SERVER['PHP_SELF'].'?GET='.serialize($_GET),30);
echo time();
phpinfo();
?>

eaccelerator_rm_page($key)
删除由  eaccelerator_cache_page() 执行的缓存,参数也是 $key

2、PHP代码中使用eAccelerator加速

下面有一个测试的代码,你可以测试一下eAccelerator强大的威力:(该代码在 cli 模式下可能无效)

<?php
class test_cache {
var $pro = 'hello';function test_cache() {
echo "Object Created!<br>\n";
}
function func() {
echo ', the world!';
}
function now($t) {
echo date('Y-m-d H:i:s', $t);
}
}

$tt = eaccelerator_get("test_tt");
if (!$tt)
{
$tt = new test_cache;
eaccelerator_put("test_tt", $tt);
echo "no cached!<br>\n";
}
else {
echo "cached<br>\n";
}

echo $tt->pro;
$tt->func();
$tt->now(time() + 86400);
?>

另外,据说在著名的vBulletin 3.60Beta版里面已经集成了对eAccelerator的支持,下面是一段来自vBulletin里面的代码

// #############################################################################
// eAccelerator/**
* Class for fetching and initializing the vBulletin datastore from eAccelerator
*
* @package    vBulletin
* @version    $Revision: 0.1 $
* @date        $Date: 2005/06/12 13:14:18 $
*/
class vB_Datastore_eAccelerator extends vB_Datastore
{
/**
* Fetches the contents of the datastore from eAccelerator
*
* @param    array    Array of items to fetch from the datastore
*
* @return    void
*/
function fetch($itemarray)
{
if (!function_exists('eaccelerator_get'))
{
trigger_error("eAccelerator not installed", E_USER_ERROR);
}

foreach ($this->defaultitems AS $item)
{
$this->do_fetch($item);
}

if (is_array($itemarray))
{
foreach ($itemarray AS $item)
{
$this->do_fetch($item);
}
}

$this->check_options();

// set the version number variable
$this->registry->versionnumber =& $this->registry->options['templateversion'];
}

/**
* Fetches the data from shared memory and detects errors
*
* @param    string    title of the datastore item
*
* @return    void
*/
function do_fetch($title)
{
$data = eaccelerator_get($title);
if ($data === null)
{ // appears its not there, lets grab the data, lock the shared memory and put it in
$data = '';
$dataitem = $this->dbobject->query_first("
SELECT title, data FROM " . TABLE_PREFIX . "datastore
WHERE title = '" . $this->dbobject->escape_string($title) ."'
");
if (!empty($dataitem['title']))
{
$data =& $dataitem['data'];
$this->build($dataitem['title'], $dataitem['data']);
}
}
$this->register($title, $data);
}

/**
* Updates the appropriate cache file
*
* @param    string    title of the datastore item
*
* @return    void
*/
function build($title, $data)
{
if (!function_exists('eaccelerator_put'))
{
trigger_error("eAccelerator not installed", E_USER_ERROR);
}
eaccelerator_lock($title);
eaccelerator_put($title, $data);
eaccelerator_unlock($title);
}
}

四、附录和参考资料
eAccelerator 官方网站 :http://eaccelerator.net
Websites using eAccelerator ?

    • http://www.advfn.com/ (2006/03/03) Advanced Financial Network, serves over 7 million page hits per day.
    • http://www.domaincity.co.uk/ (2005/01/29) Andrew Hutchings – Linux Guru – Just a quick message to say we are now using eaccelerator as a replacement for mmcache on 2 of our 3 node round robin clusters, 2.5million hits per day. We will be doubling this in the next few week, as well as implementing new clusters.
    • http://www.ets-online.de/ (2005/02/07) Denny Reeh – System Developer – The e/t/s didactic media provides an elearning server (Distance Learning System) written in PHP. We are hosting the systems for our customers mainly by ourself. So we have 5 live-servers (freebsd, apache2, php4, eaccelerator) with 5.5 million hits per month. First without eAccelerator we should have installed more servers for good performance and secondly we improve the customer convenience by quartering the medium response time of a script.
    • http://www.gorgoyle.com/ (2005/08/03) Gorgoyle.com is Yet Another Debian Personal Server with just a few lost Internet wanderers passing by, powered by a glorious Celeron 433 that needed some fresh air… With eAccelerator the result is quite impressive: users say the server speed is now 10000% higher (no joke!) So thank you all and keep up the good work!!! Server: eAccelerator 0.9.5 beta 1 Apache/2.0.55 (Debian) mod_python/3.1.3 Python/2.3.5 PHP/4.4.2-1 mod_ssl/2.0.55 OpenSSL/0.9.8a mod_perl/2.0.2
    • http://www.mafia-inc.de/ (2005/05/24) The Mafia-Incorporated is a succesfull Browser game with around 2.500.000 page impressions each day and over 5000 users. Server: PHP Version 4.3.10-9, eAccelerator 0.9.2a, Debian , Apache 2.0.53
    • http://www.mondespersistants.com/ (2005/01/07) An other game oriented french website with 6 000 000 pageloads monthly. http://guildes.mondespersistants.com is a full PHP5 oo development. Theses websites are running under freebsd / apache 1.3 / php 5.0.3 / eaccelerator 0.9.2
    • http://www.moviemaze.de/ (2005/12/09) Markus Ostertag – Movie Maze is a large german online-magazine with trailer, wallpaper, reviews, news and much more. Currently we use three servers (Suse & Debian with Apache 2, PHP4) with eAccelerator and provide more than 3TB data to ~1 Mio. users each month.
    • http://www.rtvslo.si (2005/01/04) The Slovenian National RTV Station and its news/misc portal with forums. Over 3500 users and more than 37000 forum messages in a year. Two round-robin servers for the masses, and an administrator server. 6 000 000 pageloads monthly.
    • http://www.shroomery.org/ (2006/03/28) A site about mushrooms and mycology, serving 20,000,000 pages per month. Web and database server are identical dual 64-bit Xeons with 4GB and SCSI RAID5 running Gentoo. eAccelerator help keep our page generation time under .1 second!
    • http://www.sourceforge.net/ (2005/04/25) SourceForge.net is the world’s largest Open Source software development web site, hosting more than 100,000 projects and over 1,000,000 registered users with a centralized resource for managing projects, issues, communications, and code. SourceForge.net has the largest repository of Open Source code and applications available on the Internet, and hosts more Open Source development products than any other site or network worldwide. SourceForge.net provides a wide variety of services to projects we host, and to the Open Source community. eAccelerator is used on the webserver cluster for their frontpage.

Companies offering hosting with eAccelerator enabled ?

  • http://lylix.net/ (2006/04/29) Offering webhosting w/ Apache/2.0.55, PHP 5.0.5, and eAccelerator 0.9.5 beta1 on Gentoo Linux servers. Also a provider of quality Virtual Private Server (VPS) hosting, including 32 and 64-bit platforms. Most VPS images have a pre-installed LAMP environment w/ eAccelerator installed and configured.
  • http://www.ulyssis.org A student organisation which provides shell and internet services for students at very cheap prices.
24May/12

How to configure Eclipse + XDebug + Firefox

Posted by Nick Xu

This "howto" is based on the following model:
-Ubuntu v 10.04
-Eclipse v 3.5.2
-Local LAMP server

Requirements:
-LAMP already installed
-Eclipse already installed

Server configuration:
-Open a terminal
-run: sudo apt-get install php5-xdebug
-run: sudo nano /etc/php5/conf.d/xdebug.ini
-Don't delete the content of this file, just go to the end of the file add 2 blank lines and paste the next configuration:

xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"

-save changes
-run: sudo service apache2 restart

Eclipse configuration:
-Open eclipse
-On the eclipse main menu go to: Help--> Install New Software...
-open the dropDownList "work with"
-select "--All Available Sites--"
-On the filter text field put: php
-Check out: "Programming Languages"
-Check out: "Web, XML, and Java EE Development"
-Follow the wizard instruction until finish
-On the eclipse main menu go to: Window--> Preferences
-Navigate on the tree menu to: PHP--> Debug
-open the dropDownList "work with"
-On "PHP Debugger" select "XDebug"
-Leave alone "Server" and "PHP Executables"
-Save changes and close the window
-On the eclipse main menu go to: Run--> Debug configurations...
-Do a double click over "PHP Web Page" just to add a new setting
-On the DropDowList "Server Debugger" select "XDebug"
-On the file section browse and select the "index.php" of your project or whatever file you need to start your application
-Uncheck "Break at Fist Line"
-Apply changes and close the window
-On the eclipse main menu go to: Window--> Web Browser--> Default System Web Browser

Testing xdebug
-Open a project with source code that already is hosted in your LAMP server
-Place a "break point" at some point of you script
-Press "F11" to start the debugger
-Your code should stop at the break point
-Now move the mouse over variables so watch its values

That is all i hope you enjoy this HowTo 

19May/12

960格子系统

Posted by Nick Xu

Download - CSS, sketch paper, and templates for: Acorn, Fireworks, Flash, InDesign, GIMP, Inkscape, Illustrator, OmniGraffle, Photoshop, QuarkXPress, Visio, Exp Design. Repository at GitHub.

http://960.gs/

 

 

Tagged as: , No Comments
19May/12

Eclipse HTML Editor Plugin

Posted by Nick Xu

Eclipse HTML Editor Plugin

Eclipse HTML Editor is an Eclipse plugin for HTML/JSP/XML Editing. It works on Eclipse 3.0 (or higher), JDT and GEF. It has following features.

  • HTML/JSP/XML/CSS/DTD/JavaScript Hilighting
  • HTML/JSP Preview
  • JSP/XML Validation
  • Contents Assist (HTML Tags/Attributes, XML based on DTD and JSP taglib and more)
  • Wizards for creating HTML/JSP/XML files
  • Outline View
  • Editor Preferences
  • Editor Folding
  • Web Browser (It works as an Eclipse's editor)
  • Image Viewer
  • Tag Palette
  • CSS code completion and outline
  • DTD code completion, outline and validation
  • JavaScript code completion, outline and validation

Screen Shot

Download & Installation

Download from here. Put the downloaded JAR file into ECLIPSE_HOME/plugins or ECLIPSE_HOME/dropins.

EclipseHTMLEditor requires GEF (GEF is optinal. If GEF isn't installed, the Palette view would be unavailable). You can install it using Eclipse Update Manager.

Note: SWT Browser widget (HTMLEditor uses it for preview HTML and JSP) requires Mozilla in the Linux. See details at The SWT FAQ. Also you can disable preview in the preference dialog. Choose [Window]->[Preferences]->[Amateras] and check [Disable Preview]. Then you would be able to use HTMLEditor without Mozilla.

 

官方网址:http://amateras.sourceforge.jp/cgi-bin/fswiki_en/wiki.cgi?page=EclipseHTMLEditor

7May/12

解决SSH登录过慢的问题

Posted by Nick Xu

一般使用SSH慢的问题都是SSH反解主机名所致,按照下面的两个步骤,可以解决这个问题:

一、

1, 在server上/etc/hosts文件中把你本机的ip和hostname加入
2, 在server上/etc/ssh/sshd_config文件中修改或加入UseDNS=no

先用以上配置测试,如果还不可以再往下看。

3, 注释掉server上/etc/resolv.conf中所有行
4, 修改server上/etc/nsswitch.conf中hosts为hosts: files
5, reboot server使配置生效

二、

如果还不行,则在client登录时,使用-v选项,可以看到具体的错问题的地方,

在server上/etc/ssh/sshd_config文件中修改GSSAPIAuthentication no.

/etc/init.d/sshd restart重启sshd进程使配置生效

Filed under: Linux No Comments
4May/12

DD-WRT Printer Sharing 路由器打印机共享设置

Posted by Nick Xu

DD-WRT allows for clientless printer sharing making it easy to install printers directly into the router without the need for a seperate computer. You must have installed USB support (usb_storage, sd_mod etc. can be left out if no need for external storage).

Some of the information below is outdated. I made a guide for how to get USB printing working on the Asus WL-520gU. It should also apply to other routers with USB. http://wl520gu.googlepages.com/

The following must be done via telnet or SSH:

Contents

[hide]

Printer driver

Install printer driver:

 ipkg -force-depends install kmod-usb-printer

Edit /jffs/etc/config/usb.startup and add

 insmod /jffs/lib/modules/2.4.30/printer.o

Connect printers and reboot your router

See if any printers have been found:

 dmesg | grep usb

It should show something like this (I have 2 printers connected)

 <6>printer.c: usblp0: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid 0x04F9 pid 0x000D
 <6>printer.c: usblp1: USB Bidirectional printer dev 6 if 0 alt 0 proto 2 vid 0x04A9 pid 0x108C

usblp0 means that the found printer is accessible at /dev/usb/lp0 etc.

Note: The 'USB Support' link above refers to installing several modules. On my WRT350N, I had to install these additional modules (usb-uhci.o and usb-ohci.o) to get my router to detect that my printer was plugged in.

comments from wmd1942:

I found the command "insmod /jffs/lib/modules/2.4.30/printer.o" is unnecessary if you have Core USB Support, USB 2.0 Support and USB Printer Support enabled in the 'Services' section of the router web page.

 

Notes For v24 Stable

The new v24 stable (i.e. not the release candidate versions) contains support for printer sharing and usb support in the web UI. I just got my printer server working and I figured I'd share my experience and maybe save somebody and hour or two.

Here's what I had to do to get my LaserJet 3020 to work with DDWRT on an Asus WL-500g Premium with the "DD-WRT v24 (05/24/08) mega - build 9526" version of the firmware:

1. Enable "JFFS2 Support" on the Administration tab.

(Note from another user: I had to enable "Clean JFFS2" as well, and reboot. After reboot, I ran "ipkg update", then installed the package mentioned in the first step of the "Printer Driver" section above.)

2. Enable SSH on the Services tab

3. Enable "Core USB Support", "USB 1.1 Support (UHCI)", "USB 1.1 Support (OHCI)", "USB 2.0 Support", "USB Printer Support" on the Services tab (all items under "USB Support" except for "USB Storage Support"). Note that the router did not recognize my printer if I left the USB 1.1 drivers unselected. This even though the printer supports USB 2.0.

4. Connect your printer to the router

5. Reboot your router

6. Log in with SSH to your router. And check if your printer was recognized:

 root@my-ddwrt-router:/jffs/etc/default# ls -la /dev/usb/
 drwxr-xr-x    1 root     root            0 Jan  1  1970 .
 drwxr-xr-x    1 root     root            0 Jan  1  1970 ..
 crw-rw----    1 root     root     180,   0 Jan  1  1970 lp0

if there is nothing in /dev/usb/ you need to change something, probably involving installing some other driver for your printer.

7. Look at the following files:

  /jffs/etc/default/p910nd
  /jffs/etc/init.d/p910nd

To do so, type: vi /jffs/etc/default/p910nd. vi is a text editor. You start in "command mode". Press 'a' to switch to editing mode, where you can edit the file. Press 'Esc' to get to command mode. Press :w[enter] to write (save) and :q[enter] to quit without saving, or :wq[enter] to save and quit.

At least on my version of v24, the third line in the startup script had the following line:

  DEFAULT=/etc/default/p910nd

this was invalid on my router (people more familiar with the router, please correct me here or explain the intricacies involved) and I had to edit this file and change the line to say:

  DEFAULT=/jffs/etc/default/p910nd

there are two commands that you can run to check if the server is running:

  root@my-ddwrt-router:/jffs/etc/init.d# netstat -an
  Active Internet connections (servers and established)
  Proto Recv-Q Send-Q Local Address           Foreign Address         State
  tcp        0      0 0.0.0.0:9100            0.0.0.0:*               LISTEN
  tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
  root@ddwrt-se-office:/jffs/etc/init.d# ps | grep p9100d
  561 root        680 S   p9100d -b -f /dev/usb/lp0 0

If you see a 91xx port listening in netstat and you see the p9100d running in ps, your server is probably up and running properly. Check that the server is not running yet. If not, test starting the the server by issuing:

  /jffs/etc/init.d/p910nd

For v24_TNG (sp2) versions, the command should be:

  /jffs/etc/init.d/p910nd start

and check that it came up. You should be able to print now (see bottom of this page for instructions on how to set up your workstation for IP printing via ddwrt).

8. Add the above command to the Administration->Commands edit box and click "Save Startup". This makes sure that the printer server comes up the next time you reboot your router.

Hope that helps. --Mbjarland 07:33, 27 June 2008 (CEST)

Note: On my DD-WRT v24-sp2 (10/10/09) mini-usb-ftp the command: '/jffs/etc/init.d/p910nd start' works on the ssh shell, but not on the Administration->Commands edit box

This commands works on the Administration->Commands edit box:

/jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0

 

Print server

Now Install printserver daemon:

 ipkg install p910nd

Edit /jffs/etc/config/usb.startup and add

 #brother laser
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0
 #canon inkjet
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1

(correct the above to match your setup)

Eliminating the -b flag may resolve failure to print for some printers.

NOTE from another user: I needed go without the -b flag on my Canon MX310 printer for it to work.

-b means bidirectional, -f specifices device name, and the last number can be 0,1 or 2, making the print server listen at port 9100, 9101 and 9102 respectively.

Reboot your router

Now, you router works as a print server over TCP/IP

Note: You may have to remove the '-b' option for p910nd. I couldn't print with that option included.

comments from wmd1942:

In order to load the printer server in startup, the execution permission has to be added to this "usb.startup" file:

root@DD-WRT:chmod +x /jffs/etc/config/usb.startup

After reboot, use command:

ps | grep p910

The screen should be something like:

root@DD-WRT:~# ps | grep p910 306 root 356 S /jffs/usr/sbin/p9100d -f /dev/usb/lp0 0 n

NOTE:

Multifunction printers which have fax machines attached to them may also be made to work. Ie: A CANON MF4150 with VendorID=0x04A9 and ProductID=0x26A3 will have lp0 and lp1 available. Running two instances of p9100 on different ports (9100 and 9101) and creating the respective port in windows will allow fax functions to work in conjunction with print functions as long as proper drivers are used to access the proper port. Most printers have print functions listed as lp0 and fax functions list as lp1.

EXAMPLE:

 #canon printer
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp0 0
 #canon fax
 /jffs/usr/sbin/p910nd -b -f /dev/usb/lp1 1

Workstation setup

Ubuntu Linux

  • Go to System, Administration, Printing.
  • Click New Printer
  • Choose AppSocket/HP JetDirect
  • Hostname: IP address of the wireless printer (normally 192.168.1.1)
  • Port: 9100 for first printer, 9101 for second printer, etc
  • Click Forward and go on with the printer wizard to select brand, model and settings as you would do for a local printer

Windows XP

  • Find your printer in Control Panel - Printers etc. and open the properties page for it.
  • Select the Ports tab.
  • Click Add Port and choose Standard TCP/IP printer port and click New Port
  • Enter you router's IP address (normally 192.168.1.1) and click Next
  • Set Device type to custom and click settings.
  • Make sure RAW is selected and specify the necessary port number (normally 9100, 9101 for second printer, etc) and click OK
  • Click Next and Finish and Close
  • Make sure the newly created port is selected for your printer and click OK

Mac OS X 10.5 (Leopard)

  • Open System Preferences
  • Open Print & Fax
  • Click the + button below the list of installed printers
  • Select the toolbar button called 'IP'
  • Set protocol to: HP Jetdirect - Socket
  • Enter the address of your router followed by : and the port - ie. normally 192.168.1.1:9100
  • Leave 'Queue' blank
  • Set a friendly name for your printer (whatever you like)
  • And a friendly location (again, up to you)
  • Print Using: choose 'Select a driver to use'
  • A list will pop up of all installed printer drivers - choose the one that works for you (see Note below)
  • Add your printer

Note (Mac only): the driver must be compatible with the CUPS printing system, which is one of the two printing systems included in OS X. Certain printers e.g. Canon Pixma series and Epson Inkjet include OSX drivers which do not use CUPS. You may find compatible printer drivers from Gutenprint (free) orPrintFab ($). OS X Leopard appears to include certain Gutenprint drivers, but the quality may vary and it may be worth checking their website for updated versions, or try PrintFab.

 

Printing from WAN

If you want to be able to print from the WAN side of your router do the following:

In the web interface go to Administration - Commands and hit the "Command shell" field and type in

 /usr/sbin/iptables -I INPUT 1 -p tcp --dport 9100:9102 -j logaccept

And click Save Firewall

Your router reboots and you can now print from WAN side

NOTE: This is not recommended if your WAN is directly accessible from internet, but useful at private subnets of companies, colleges etc.

 

Installing on Asus WL500G Deluxe, with DD-WRT v24-sp2

Install dd-wrt.v24_usb_generic.bin firmware
Enable JFFS, and clear JFFS
Enable SSH
reboot router
Enable All USB options - set mount point to /opt
Since ipkg update seems broken, 
Download http://downloads.openwrt.org/backports/rc5/p910nd_0.7-2_mipsel.ipk to a USB stick formatted with FAT32
Insert USB into router and reboot router
SSH to router
cd /opt
ipkg -d root install p910nd_0.7-2_mipsel.ipk

p910nd is now installled and you have the configuration files in /jffs/etc/ and you can continue at the guide above.

 

Notes for K26

With the new kernel 2.6 the kernel doesn't create the device file /dev/usb/lp0 anymore. You have to do that manually once. Just issue

mknod -m 660 /dev/usb/lp0 c 180 0

once and everything is going to work. This should probably be done before starting the p910nd server.

Note from another user: I had to add this mknod command to /jffs/etc/config/usb.startup.

4May/12

为mysql添加root远程登录权限

Posted by Nick Xu

默认情况下,MySQL允许本地登录,需要修改/etc/mysql/my.cnf文件:
注释这一行:
bind-address=127.0.0.1 ==> #bind-address=127.0.0.1
对于需要远程登录的用户执行如下命令:
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "yourpasswd" WITH GRANT OPTION;
mysql> flush privileges;

 

 

Filed under: Linux, 数据库 No Comments
1May/12

wine qq 2012 for linux Ubuntu 兼容64位

Posted by Nick Xu

http://www.longene.org/forum/viewtopic.php?f=6&t=4700

http://www.longene.org/download/wine-qq2012-for-linux_20120302_ByLongeneTeam.deb

在64位系统上安装ia32-libs后(Ubuntu执行:sudo apt-get install ia32-libs),
安装上面的32位包可以正常运行起来

Filed under: Linux No Comments
   
site
site