分类目录归档:lanmp

lanmp

review board 安装使用小结

抽出了一些业余时间,折腾了几天,终于基本拿下了review board,安装配置完毕,并创建了第一个测试review code。这过程中,遇到了不少问题需要记录一下的:

1. easy_install安装相关库的时候,很经常是极其郁闷,国外的源基本被墙,所以这里记录了一些国内对应的源 http://pypi.douban.com/  豆瓣  http://pypi.hustunique.com/  华中理工大学 http://pypi.sdutlinux.org/  山东理工大学 http://pypi.mirrors.ustc.edu.cn/  中国科学技术大学,使用方法:easy_install -i 源 库;

2. 因为环境是使用apache+mod_wsgi,编译mod_wsgi模块的时候,请注意指定–with-apxs=这参数,尤其需要注意的是–with-python 这个参数,因为linux系统(centos)一般默认安装python2.4,我们使用py的时候,往往会重新安装为python2.7,因为需要指定你的python版本,免得带来不必要的麻烦;

3. python环境推荐使用python2.7;

4. 安装mysql-python库的时候,你有可能像我一样,安装没报任何的错误,结果import MySQLdb的时候却报错了,是尝试ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib  然后再ldconfig  有可能解决你的问题;

5. 下一步尝试使用post-review;

6. 缓存有空在改成memcached即可,现在使用的是file;

7. 图略。

学习diff 和 patch 使用方法

演练:

备注:

单个文件
diff –uN from-file to-file >to-file.patch
patch –p0 < to-file.patch
patch –RE –p0 < to-file.patch
多个文件
diff –uNr from-docu to-docu >to-docu.patch
patch –p1 < to-docu.patch
patch –R –p1 <to-docu.patch

配置Nginx与Lua的history

配置Nginx与Lua的history。

备注:安装Lua或者LuaJIT都是可以的。

import MySQLdb加载模块ImportError: libmysqlclient处理方法

今天为Python安装MySQLdb库,安装过程相当顺利。可惜测试的时候import MySQLdb加载模块ImportError: libmysqlclient_r.so.16。

于是google之,总结一下解决方法:

将mysql/lib下所有关于libmysqlclient的so文件软链接到/usr/lib下。

ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/lib
ldconfig

这样 import MySQLdb 的时候就不会出错了

cygwin安装java环境

首先windows上先安装java,过程略。

然后直接执行:

即可在cygwin使用java环境。

当然你也可以采用在~/.bashrc或者/etc/profile中配置该路径即可。

AWK单行脚本快速参考

 

mysql备份脚本

写脚本之前先试试

脚本

测试

搞定。

linux下虚拟机修改时间无效处理方法

cd /proc/sys/xen
echo 1 > independent_wallclock
[root@sh232-xen xen]# cat independent_wallclock
1
[root@sh232-xen xen]#
然后再用 date -s进行修改即可!
2. 如果linux时区出现错误 按照以下修改
[root@sh232-xen ~]# cp -r /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
进行硬件同步
hwclock -systohc 或 hwclock -w
然后再 date -s 即可!

symfony2 创建实体

As I figured it out, until now, Symfony2 hasn’t got a common schema.yml for all entities (an entity is a class/object that maps the correspondent table) as was in Symfony 1.4, but the database configurations are made separate for every entity. In these conditions creating a database starting from the existing entities is a much more laborious task than it was in Symfony 1.4, but not impossible.

There is, although, another solution to this problem, building the entities starting from an existing database. There is a good tutorial in Symfony2 cookbook, but I will also list here the commands needed to complete this task. All of these commands assume that I configured the parameter.ini correctly, so Symfony knows which is the database to use, and also that the bundle Main/MyBundle is initialized, in order to store the entities that will be created.

1. First Symfony needs to generate the metadata corresponding to the tables through the following command. This will create YAML files but it can also create XML files.

     php app/console doctrine:mapping:convert yml ./src/Main/MyBundle /Resources/config/doctrine/metadata/orm --from-database --force

2. Now Symfony can import the configurations from the metadata files

     php app/console doctrine:mapping:import MainMyBundle yml

3. The entities can be generated based on the configuration files

     php app/console doctrine:generate:entities MainMyBundle

That’s all!

But one needs to pay attention to the way he builds his database from the beginning.  For example the relations too must be specified when building the database otherwise Doctrine will not be able to detect them. In phpMyAdmin this is done in the following way:

  • go to the structure of the table that will contain the foreign key
  • create an index on the field that you want it to be a foreign key
  • go back to the structure of the table and click Relation View
  • on the field that we want to make a foreign key specify to which other key it is related

For example if you want to have two tables book and author, than the primary key will be in author table, since it is unique, but one author can write one or many books, and the foreign key will be the author_id field in book table.

- See more at: http://blog.aelius.fr/blog/2011/10/symfony2-generate-entities-starting-from-a-database/#sthash.ei56Buf8.dpuf

iptables常用命令

封锁端口

iptables -I INPUT -p tcp –dport 3690 -j DROP

开通某个IP端口
iptables -I INPUT -s ip地址 -p tcp –dport 3690 -j ACCEPT

iptables -I INPUT -s ip地址/地址段 -p tcp –dport 3690 -j ACCEPT

查看数据

iptables -L -n -v