django+nginx的部分配置

作者 : admin 于 2009年12月16日, 11:26:55
2009
12-16

nginx的配置,特别感谢爱词霸吕同学,发扬了开源共享的精神,大大缩短了我的调试成本。

  1. server {
  2.     listen 80;
  3.     server_name python.sunboyu.cn;
  4.     location / {
  5.           fastcgi_pass 127.0.0.1:8000;
  6.           fastcgi_buffers      16  128k;
  7.           fastcgi_ignore_client_abort  on;
  8.           fastcgi_read_timeout 60;
  9.  
  10.           fastcgi_param PATH_INFO $fastcgi_script_name;
  11.           fastcgi_param REQUEST_METHOD $request_method;
  12.           fastcgi_param QUERY_STRING $query_string;
  13.           fastcgi_param CONTENT_TYPE $content_type;
  14.           fastcgi_param CONTENT_LENGTH $content_length;
  15.           fastcgi_param SERVER_PROTOCOL  $server_protocol;
  16.           fastcgi_param SERVER_PORT      $server_port;
  17.           fastcgi_param SERVER_NAME  $server_name;
  18.  
  19.           fastcgi_pass_header Authorization;
  20.           fastcgi_intercept_errors off;
  21.  
  22.     }
  23. }

同时附上一个额外的文档,nginx变量跟cgi协议的对应关系。
注:在配置中,并不是所有的变量必须加上,而是根据环境选择其中应该有的变量,至于具体加哪些变量,得求助高人了。

  1. #    Fast CGI param reference
  2. #    fastcgi_param    SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  3. #    fastcgi_param    QUERY_STRING  $query_string;
  4. #    fastcgi_param    REQUEST_METHOD  $request_method;
  5. #    fastcgi_param    CONTENT_TYPE  $content_type;
  6. #    fastcgi_param    CONTENT_LENGTH  $content_length;
  7. #    fastcgi_param    GATEWAY_INTERFACE  CGI/1.1;
  8. #    fastcgi_param    SERVER_SOFTWARE  nginx;
  9. #    fastcgi_param    SCRIPT_NAME  $fastcgi_script_name;
  10. #    fastcgi_param    REQUEST_URI  $request_uri;
  11. #    fastcgi_param    DOCUMENT_URI  $document_uri;
  12. #    fastcgi_param    DOCUMENT_ROOT  $document_root;
  13. #    fastcgi_param    SERVER_PROTOCOL  $server_protocol;
  14. #    fastcgi_param    REMOTE_ADDR  $remote_addr;
  15. #    fastcgi_param    REMOTE_PORT  $remote_port;
  16. #    fastcgi_param    SERVER_ADDR  $server_addr;
  17. #    fastcgi_param    SERVER_PORT  $server_port;
  18. #    fastcgi_param    SERVER_NAME  $server_name;

apache自动生成目录文件列表配置

作者 : admin 于 2009年07月22日, 19:13:00
2009
07-22

由于种种原因,服务器给卖掉了,因此,我做的源码目录也就没了。这里把该目录的配置属性介绍一下:

  1. <directory /home/sunboyu/www_source.sunboyu.cn>
  2.         MaxConnPerIP 1
  3.         ReadmeName foot.html        #页面的头
  4.         HeaderName top.html          #页面的脚
  5.         IndexIgnore top.html foot.html    #列目录的时候,忽略这些文件
  6.         ServerSignature Off       #关闭服务器标志
  7.         IndexOptions FancyIndexing VersionSort FoldersFirst SuppressLastModified NameWidth=* Charset=UTF-8
  8.         Options FollowSymLinks
  9.         Options +Indexes
  10.         AllowOverride all
  11.         Order deny,allow
  12.         Allow from all
  13.  </directory>

FancyIndexing 打开列表功能

VersionSort 同一文件不同版本分类列出

FoldersFirst 文件夹优先

SuppressLastModified 禁止列出最后修改时间

NameWidth=* 文件名长度 *当然是全部显示

Charset=UTF-8 页面输出编码

AddIcon /other/icons/exe.gif .bin .exe 给exe bin扩展名添加exe.gif图标

ScanHTMLTitles 如果有html文件,则度html的title为描述

Pure-ftpd安装配置草稿-补充完全

作者 : admin 于 2008年12月18日, 09:47:45
2008
12-18
  1. cp /opt/mysql-5.0.22/lib/mysql/* /usr/lib          #解决编译依赖库问题
  2. ./configure --prefix=/opt/pure-ftpd \
  3. --with-mysql=/opt/mysql-5.0.22 \
  4. --with-rfc2640 \
  5. --with-language=simplified-chinese \
  6. --with-peruserlimits \
  7. --with-diraliases \
  8. --with-virtualchroot \
  9. --with-virtualhosts \
  10. --with-welcomemsg \
  11. --with-ftpwho \
  12. --with-quotas \
  13. --with-throttling \
  14. --with-cookie \
  15. --with-extauth \
  16. --with-puredb \
  17. --with-altlog \
  18. --with-sysquotas \
  19. --with-paranoidmsg \
  20. --with-ascii \
  21. --with-inetd
  22.  
  23. cp  $install_dir/pureftpd-mysql.conf /opt/pure-ftpd/
  24. cp  $install_dir/configuration-file/pure-config.pl pure-ftpd.conf /opt/pure-ftpd/

启动服务  /opt/pure-ftpd/pure-config.pl pure-ftpd.conf

这里补充完整:
安装完后,很多配置文件还在原来的安装包里,并没有部署到prefix目标文件夹下,需要手工复制过去,就是上边那两个,一个启动脚本,pure-config.pl 还有性能监控工具,统计工具等。
另外一个经常出现的问题:(为了重现,还得修改成错误的)
421 配置错误: 无效的SQL配置文件: /opt/pure-ftpd/etc/pureftpd-mysql.conf
这个问题网上很多问的,但解释不到位,这里详细解释一下:我们在编译的时候选择了好多参数,部分参数跟配置是对应的,只有编译相关模块,才能打开相关配置,否则是不行的,会报错,但这个软件报错不报错误行数,所以调试起来比较费劲,我是一个个配置行进行开关才发现这个问题的,比如,我开启了这行,MySQLGetRatioDL SELECT DLRatio FROM users WHERE User=”\L” 但我编译的时候未加 ratio这个参数,就报错了,所以在调试的时候一定要对照一下编译时候的参数。
mysql中,密码我用的encryt加密,调试记得打开防火墙,其他没什么需要注意的。

我的一个虚拟主机配置,支持suexec+fastcgi+php+perl

作者 : admin 于 2008年11月22日, 13:36:07
2008
11-22
  1. <virtualhost *:80>
  2.     SuexecUserGroup www www
  3.     ServerAdmin webmaster@dummy-host.example.com
  4.     DocumentRoot "/home/www/php"
  5.     ServerName 192.168.43.129
  6.     ServerAlias www.dummy-host.example.com
  7.     ErrorLog "logs/dummy-host.example.com-error_log"
  8.     CustomLog "logs/dummy-host.example.com-access_log" combined
  9.     <directory /home/www/php>
  10.         AddHandler fcgid-script .php
  11.         AddHandler perl-script .pl .cgi
  12.         PerlResponseHandler ModPerl::Registry
  13.         PerlOptions +ParseHeaders
  14.         PerlOptions +SetupEnv
  15.         FCGIWrapper /home/www/php-cgi .php
  16.         Options ExecCGI +FollowSymLinks SymLinksIfOwnerMatch
  17.         allow from all
  18.     </directory>
  19. </virtualhost>

老一套,要注意的是各种脚本的映射,容器的合理使用。

Nutch配置指南

作者 : admin 于 2008年09月22日, 17:56:36
2008
09-22

//fuck这个破鼠标,写了半天,还没报错,页面就被跳没了!!
重写:
首先,下载相关软件
tomcat http://apache.mirror.phpchina.com/tomcat/tomcat-4/v4.1.37/bin/apache-tomcat-4.1.37.tar.gz
nutch http://apache.mirror.phpchina.com/lucene/nutch/nutch-0.7.2.tar.gz
jdk的配置,看这篇文章 http://www.sunboyu.cn/2008/09/20/centos5%E4%B8%8B%E9%85%8D%E7%BD%AEjdk%E7%8E%AF%E5%A2%83.shtml
顺便写了个脚本

  1. # author:sunboyu@gmail.com
  2. # qq:176300676 msn:sunboyu@gmail.com
  3. # http://www.sunboyu.cn
  4.  
  5. #!/bin/sh
  6. export JAVA_HOME=/opt/jdk1.6.0
  7. export CLASSPATH=.:/opt/jdk1.6.0/lib/tools.jar:/opt/jdk1.6.0/lib/dt.jar:/opt/jdk1.6.0
  8. export PATH=$PATH:/opt/jdk1.6.0/bin
  9. export JRE_HOME=/opt/jdk1.6.0
  10.  
  11. export CATALINA_BASE=/opt/tomcat
  12. export CATALINA_HOME=/opt/tomcat
  13. export CATALINA_TMPDIR=/opt/tomcat/temp

把nutch目录下的nutch-0.7.2.war配置为tomcat下的默认站点
修改tomcat下webapps/ROOT/WEB-INF/classes/nutch-site.xml
增加以下配置

  1. <property>
  2.       <name>searcher.dir</name>
  3.       <value>/local/nutch/crawl</value>
  4.    </property>

启动tomcat!
运行以下nutch命令
bin/nutch crawl urls -dir /test -depth 5 -topN 1000 -threads 5
则可以在/test目录中创建抓取的索引。
然后在tomcat服务中测试下搜索效果!

CentOS5下配置JDK环境

作者 : admin 于 2008年09月20日, 15:25:07
2008
09-20

下载jdk安装包 http://www.java.net/download/jdk6/6u10/promoted/b32/binaries/jdk-6u10-rc2-bin-b32-linux-i586-12_sep_2008.bin

编辑/etc/profile

export JAVA_HOME=/opt/jdk1.6.0
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export JRE_HOME=$JAVA_HOME/jre

保存加载配置 : source /etc/profile

然后终端用echo $PATH 监测是否成功。

最后监测 java -version

如果回显出现

java version “1.6.0_10-rc2″
Java(TM) SE Runtime Environment (build 1.6.0_10-rc2-b32)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
则证明安装成功

SVN配置使用

作者 : admin 于 2008年08月09日, 16:16:18
2008
08-9

接这个 http://www.sunboyu.cn/2008/07/26/subversion-150-%E7%BC%96%E8%AF%91%E5%8F%82%E6%95%B0.shtml

安装完成后,可以建立仓库  svnadmin create /opt/$path

配置apache

<Location /svn>
DAV svn
SVNParentPath /opt/httpd-2.2.9/htdocs/repos
SVNListParentPath on
AuthzSVNAccessFile /opt/httpd-2.2.9/htdocs/repos/accessfile
Require valid-user
AuthType Basic
AuthName “Svn”
AuthUserFile /opt/httpd-2.2.9/htdocs/repos/passwordfile
</Location>

生成password的方法 htpasswd -s /$file username

这样就可以建立一个密码文件,在httpd中调用。在调试的时候,权限是大事

memcache安装与配置详解

作者 : admin 于 2008年05月19日, 10:44:18
2008
05-19
libevent-1.2.tar.gz
memcache-3.0.1.tgz
memcached-1.2.0.tar.gz

安装 libevent-1.2.tar.gz
./configure
make && make install

chmod 644 /usr/local/lib/libevent.a
PATH=”$PATH:/sbin” ldconfig -n /usr/local/lib
———————————————————————-
Libraries have been installed in:
/usr/local/lib
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 `LD_LIBRARY_PATH’ environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
- use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
test -z “/usr/local/include” || mkdir -p — . “/usr/local/include”
/usr/bin/install -c -m 644 ‘event.h’ ‘/usr/local/include/event.h’
/usr/bin/install -c -m 644 ‘evhttp.h’ ‘/usr/local/include/evhttp.h’
/usr/bin/install -c -m 644 ‘evdns.h’ ‘/usr/local/include/evdns.h’
test -z “/usr/local/man/man3″ || mkdir -p — . “/usr/local/man/man3″
/usr/bin/install -c -m 644 ‘./event.3′ ‘/usr/local/man/man3/event.3′
/usr/bin/install -c -m 644 ‘./evdns.3′ ‘/usr/local/man/man3/evdns.3′

安装 memcached-1.2.0.tar.gz
./configure
make && make install

Making install in doc
make[1]: Entering directory `/root/memcached-1.2.0/doc’
make[2]: Entering directory `/root/memcached-1.2.0/doc’
make[2]: Nothing to be done for `install-exec-am’.
/bin/sh ../mkinstalldirs /usr/local/man/man1
/usr/bin/install -c -m 644 ./memcached.1 /usr/local/man/man1/memcached.1
make[2]: Leaving directory `/root/memcached-1.2.0/doc’
make[1]: Leaving directory `/root/memcached-1.2.0/doc’
make[1]: Entering directory `/root/memcached-1.2.0′
make[2]: Entering directory `/root/memcached-1.2.0′
/bin/sh ./mkinstalldirs /usr/local/bin
/usr/bin/install -c memcached /usr/local/bin/memcached
/usr/bin/install -c memcached-debug /usr/local/bin/memcached-debug

启动 -d守护进程 -m内存分配 -u 用户 -l监听地址 -p 端口 -P pid文件
memcached -d -m 100 -u root -l 127.0.0.1 -p 8000 -P /tmp/mem.pid

安装 memcache-3.0.1.tgz
phpize
./configure
make && make install

gcc -shared .libs/memcache.o .libs/memcache_pool.o .libs/memcache_queue.o .libs/memcache_ascii_protocol.o .libs/memcache_binary_protocol.o .libs/memcache_standard_hash.o .libs/memcache_consistent_hash.o .libs/memcache_session.o -Wl,-soname -Wl,memcache.so -o .libs/memcache.so
creating memcache.la
(cd .libs && rm -f memcache.la && ln -s ../memcache.la memcache.la)
/bin/sh /root/memcache-3.0.1/libtool –mode=install cp ./memcache.la /root/memcache-3.0.1/modules
cp ./.libs/memcache.so /root/memcache-3.0.1/modules/memcache.so
cp ./.libs/memcache.lai /root/memcache-3.0.1/modules/memcache.la
PATH=”$PATH:/sbin” ldconfig -n /root/memcache-3.0.1/modules
———————————————————————-
Libraries have been installed in:
/root/memcache-3.0.1/modules
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 `LD_LIBRARY_PATH’ environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
- use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf’
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
Build complete.
Don’t forget to run ‘make test’.
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/

php.ini extent 加载 memcache.so
重启使其生效即可