Sep
14
2007
1

Install PDO, PDO_SQLITE, PDO_DBLIB, PDO_MYSQL

Recently I’m using PRADO framework for some web application development. It comes to deploy to the server side.
The server is running Debian 3.1r3

  • apt-get install php5-dev php5-mysql php5-sybase php5-sqlite libmysqlclient-dev freetds-dev
  • apt-get install make
  • pecl install PDO
  • pecl install PDO_SQLITE
  • pecl install PDO_MYSQL
  • pecl install PDO_DBLIB

At the last step, it report:
pear/PDO_DBLIB requires PHP extension “pdo” (version >= 1.0)
No valid packages found
install failed

Here’s the solution:

  • pecl download PDO_DBLIB
  • tar zxvf PDO_DBLIB-1.0.tgz
  • pecl build
  • After the build finished, it’ll try to install to /var/tmp, on my system, the files was gone after the make. so I have to build it again
  • cd PDO_DBLIB-1.0
  • ./configure
  • make
  • After the make finished, the module is locate at ./PDO_DBLIB-1.0/modules/pdo_dblib.so, copy it to /usr/lib/php5/20060613+lfs or any location that extension files should be
  • add extension=pdo_dblib.so
  • happy coding now!
Written by hkai in: Linux Debian, Linux General, PHP |
Jul
20
2007
0

Too many open files

Today I encounter a serious error in my production server running Debian 3.1 with Apache 1.3, PHP 4.3
Warning: Unknown(/web_sites/doc_root/public_html/index.php): failed to
create stream: Too many open files in Unknown on line 0

The reason is linux limit the max number of opening files to 1024, and my server is hosting more than 500 virtual hosting now, and each of them opened 2 logs. So in total when the hosting is over 512 domains, it’ll reach the limit.
Run this command to see the limit:

linuxvm1:~# ulimit -n
1024

The solution: (I know you like this)
open /usr/sbin/apachectl (or apache2ctl )
add a line to it: ulimit -n 65536
restart apache:
apachectl restart

The problem should been fixed.
If you execute /etc/init.d/apache to restart, it may not work because Debian 3.1 is not using apachectl in /etc/init.d/apache
I’m not sure how to add the ulimit to it yet.

Written by hkai in: Apache, Linux General, PHP |
Jun
30
2007
0

subversion: useful commands

  1. create a repository
    • svnadmin create repos_name
    • svnadmin create –fs-type fsfs repose_name
  2. dump a repository
    • svnadmin dump repos_name > dumpfile
    • svnadmin dump repos_name –revision 100:120 –incremental > dumpfile_100_120
  3. load a dump file into a repository
    • svnadmin load repos_name < dumpfile
  4. check the latest revision of a repository
    • svnlook youngest repos_name
  5. view the info of a repository
    • svn info repos_name
  6. relocate a repository
    • svn switch https://new_url
Written by hkai in: Linux General |
May
30
2007
0

mount ISO file

mount -o loop -t iso9660 file.iso /mnt/test

Written by hkai in: Linux General |
May
15
2007
0

using find with files and directories

 find . -maxdepth 1 -mindepth 1 -type f -name ‘20*.jpg’ -print -exec mv “{}” temp \;
this will move all files under current directory which name like 20*.jpg to temp,

Written by hkai in: Linux General |
May
11
2007
0

using find to remove lots of old directory

move those old directories (old than 50 days) to tmp

find /var/www/htdocs -maxdepth 1 -type d -ctime +50 -exec mv "{}" ../tmp \; -print

remove those directories

find /var/www/tmp/ -maxdepth 1 -mindepth 1 -type d -print -exec rm -rf "{}" \;

Written by hkai in: Linux General |
Feb
17
2007
1

using find to move lots of files

find . -type f -print -exec mv “{}” ../new_dir \;

this command will move all files in current directory to ../new_dir and also show the file names.

when there’s too many files in a directory, mv command will return error message, that’s the solution.

Written by hkai in: Linux General |
Nov
16
2006
0

comparing debian and gentoo (for system admin only)

I need to install subversion on 2 machines running debian and gentoo.

on debian: aptitude install subversion

finished in 5 seconds

on gentoo: emerge subversion

after compiling 5 packages in 15 min, it got subversion installed.

what’s the reason for the 15min? I tried to look the doc to get a binary package, and it seems need another one hour to install/configure, which also seems not official support by default. So, why bother ?

I don’t suggest any system admin use gentoo, it will bring you troublesome more than advantages. However, if you are cutting edge system admin and no customer will complain when system breaks, you are on your own. Good luck! I’ll remove my gentoo within 2 monthes and switch to debian forever.

Written by hkai in: Linux Debian, Linux Fedora, Linux General |
Nov
10
2006
0

copy files with find and tar

use tar to copy files

tar cf - . | (cd /target && tar xfp -)

use file to copy files

find . -type f -exec cp -vu “{}” /target \;

Written by hkai in: Linux General |
Nov
09
2006
0

using find to move/delete files

find . -type f -print -exec mv “{}” ../new_dir \;

this command will move all files in current directory to ../new_dir and also show the file names.

when there’s too many files in a directory, mv command will return error message, that’s the solution.

find . -type f -print -exec rm “{}” \;

remove all files in current directory including sub directory.

Written by hkai in: Linux General |

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes