Archive for August, 2010

apache no warning

Friday, August 20th, 2010
最近开发环境apache用的多了点,就在刚刚配置完mod_wsgi的支持后用
apachectl -t 检查发现一堆waning
[Fri Aug 20 16:27:55 2010] [warn] module wsgi_module is already loaded, skipping
[Fri Aug 20 16:27:55 2010] [warn] module wsgi_module is already loaded, skipping
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost commsen:80 has no VirtualHosts
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost test_modwsgi:80 has no VirtualHosts
[Fri Aug 20 16:27:55 2010] [warn] NameVirtualHost ubimeeting:80 has no VirtualHosts
提示很明显了,虽然不影响使用,不过我这种对系统有洁癖的人显然受不了. 这两个提示都是因为配置项重复导致的.重新整理下配置文件的结构就好了.
  1. 删掉单个虚拟主机配置文件里的loadmodule 和namevirtualhost.
  2. 将loadmodule和namevirtualhost的设置写到httpd.conf里.
zhangdi:users$ apachectl -t
Syntax OK

mac OSX10.6安装Apache2+mod_wsgi

Friday, August 20th, 2010

系统环境: macbook pro 374

python2.6是用macports管理的,Apache2是系统自带的.

查看了一下macports里的mod_wsgi,版本是3.2,比google code上的低了点,而且依赖关系有apache2和python2.6.

我这业余时间偶尔还要做些php开发,不想用macports管理apache和php,包太多平时更新ports很烦,所以这里不打算用macports里的mod_wsgi.

google了一些安装资料, 看到configure 时的两个参数 apxs和python. 看了下系统环境,下载源码包开始编译.

zhangdi:mod_wsgi-3.3$ ./configure –with-apxs=/usr/sbin/apxs –with-python=/opt/local/bin/python

两个参数一个指定apxs的位置,我这里是/usr/sbin下, python是2.6版的macports安装的

configure完成,make 时有几个warning,没什么重要的. make install 完成.

zhangdi:mod_wsgi-3.3$ sudo make install
Password:
/usr/sbin/apxs -i -S LIBEXECDIR=/usr/libexec/apache2 -n ‘mod_wsgi’ mod_wsgi.la
/usr/share/httpd/build/instdso.sh SH_LIBTOOL=’/usr/share/apr-1/build-1/libtool’ mod_wsgi.la /usr/libexec/apache2
/usr/share/apr-1/build-1/libtool –mode=install cp mod_wsgi.la /usr/libexec/apache2/
cp .libs/mod_wsgi.so /usr/libexec/apache2/mod_wsgi.so
cp .libs/mod_wsgi.lai /usr/libexec/apache2/mod_wsgi.la
cp .libs/mod_wsgi.a /usr/libexec/apache2/mod_wsgi.a
chmod 644 /usr/libexec/apache2/mod_wsgi.a
ranlib /usr/libexec/apache2/mod_wsgi.a
———————————————————————-
Libraries have been installed in:
/usr/libexec/apache2
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH’ environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
chmod 755 /usr/libexec/apache2/mod_wsgi.so

zhangdi:mod_wsgi-3.3$ sudo make installPassword:/usr/sbin/apxs -i -S LIBEXECDIR=/usr/libexec/apache2 -n ‘mod_wsgi’ mod_wsgi.la/usr/share/httpd/build/instdso.sh SH_LIBTOOL=’/usr/share/apr-1/build-1/libtool’ mod_wsgi.la /usr/libexec/apache2/usr/share/apr-1/build-1/libtool –mode=install cp mod_wsgi.la /usr/libexec/apache2/cp .libs/mod_wsgi.so /usr/libexec/apache2/mod_wsgi.socp .libs/mod_wsgi.lai /usr/libexec/apache2/mod_wsgi.lacp .libs/mod_wsgi.a /usr/libexec/apache2/mod_wsgi.achmod 644 /usr/libexec/apache2/mod_wsgi.aranlib /usr/libexec/apache2/mod_wsgi.a———————————————————————-Libraries have been installed in:   /usr/libexec/apache2
If you ever happen to want to link against installed librariesin a given directory, LIBDIR, you must either use libtool, andspecify the full pathname of the library, or use the `-LLIBDIR’flag during linking and do at least one of the following:   – add LIBDIR to the `DYLD_LIBRARY_PATH’ environment variable     during execution
See any operating system documentation about shared libraries formore information, such as the ld(1) and ld.so(8) manual pages.———————————————————————-chmod 755 /usr/libexec/apache2/mod_wsgi.so

ssh使用多个私钥

Wednesday, August 18th, 2010

公司代码库的git和几个主机用的密钥不同,在连不同的主机时需要使用不同的密钥,翻了下资料,找到如下的配置方式。

From my .ssh/config:

Host myshortname realname.example.com
Hostname realname.example.com
IdentityFile ~/.ssh/realname_rsa # private key for realname

Host myother realname2.example.org
Hostname realname2.example.org
IdentityFile ~/.ssh/realname2_rsa

设置syslogd接收无线AP日志

Thursday, August 12th, 2010

commsen的无线AP,日志服务器用的FreeBSD

AP设备本身存储量小,而且web管理页面查看日志并不怎么方便,于是将日志发送到服务上处理。

登录无线AP的web管理界面,设置很方便,添个ip就行了,重启设备。

freebsd这里设置syslogd_flags=”" 重启syslogd服务。

看了下syslogd的配置,默认大部分都写到/var/log/message里了,tail查看,等了一会,发现没记录。

写了个python脚本向freebsd发送条文本消息,发现可以正常显示。ssh到设备上ping了一下freebsd,也是通的。

无奈开了tcpdump抓包。看到类似.syslog: SYSLOG daemon.info, length: 82的数据传送。

重新配置syslogd,加入daemon.info /var/log/ap.log,重启syslogd,等了一下发现ap.log没有被创建。touch之。

日志顺利出现。这样积攒一批就可以作分析用了。

MacPort:安装配置mysql5

Thursday, August 12th, 2010
摘抄记录一下,原文在这里

localhost:mysql5 zhangdi$ port search mysql5
mysql5 @5.1.48 (databases)
Multithreaded SQL database server

localhost:mysql5 zhangdi$ port search mysql5mysql5 @5.1.48 (databases)    Multithreaded SQL database server
sudo port install mysql5 +server

sudo /opt/local/lib/mysql5/bin/mysql_install_db –user=mysql Password:

sudo /opt/local/share/mysql5/mysql/mysql.server start

mysqladmin5 -u root -p ping Enter password:  mysqld is alive

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

…set the mysqld_safe socket path in a new MySQL configuration file. Create /opt/local/etc/mysql5/my.cnf, add the following to it, save, the try again.

[mysqld_safe] socket = /tmp/mysql.sock

NOTE: If you’ve installed MacPort’s PHP 5 you will probably need to tell PHP where the MySQL socket is. Edit your php.ini file located at /opt/local/etc/php.ini.

mysql.default_socket = /tmp/mysql.sock

Set Basic MySQL Security

Finally, set the root mysql password to secure your server.

mysqladmin5 -u root password

Moving MySQL data from other installations

If, like me, you want to move data from a previous MySQL 5 install (i.e. /usr/local/mysql/data), be sure to stop MySQL first. You’ll want to overwrite the mysql database you created after installation when copying over data files and indices. Ensure that everything copied to /opt/local/var/db/mysql5/ remains owned by mysql. Refer to the MySQL documentation if you’re upgrading from MySQL 4 to 5.

Now get busy querying.