Tag Archive for 'apache'

用Apache ab模拟用户登录后投注测试

1
 ab -c 50 -n 3000 -C PHPSESSID=we21f3a362ea79f82076c9c79b8109  -p tmp.txt  -T application/x-www-form-urlencoded http://localhost/jczq/projectgg/index

tmp.txt格式

1
codes=146|3/147|3/141|3/148|3/145|3/143|3&totalmoney=2&zhushu=1&beishu=1&playid=spf&pass_type=6_1

基于Nginx, lighttpd/apache上的OpenX高性能集群配置

本文英文原文地址:http://www.sherin.co.in/openxcluster121/

编者注:本文非常详细的描述了OpenX集群的配置方法,对于想通过OpenX做大规模服务的应用来说应该有比较大的帮助。原文是英文的,为了保证意思的表达就不翻译成中文了。 Continue reading ‘基于Nginx, lighttpd/apache上的OpenX高性能集群配置’

CACHE CONTROL WITH HTACCESS

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Cache Control with .htaccess EXPIRES BY TYPE
# from http://forum.powweb.com/showthread.php?t=62786
 
### turn on the Expires engine
ExpiresActive On
 
### expires after a month in the client's cache
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType application/pdf A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/plain A2592000
 
### expires after 4.8 hours
ExpiresByType text/css A17200
 
# Please note that the "A" before the numbers above stands for Access.
# This means that the stopwatch starts when a client accesses the file.
# You can also use "M" for modified.
 
# TIME CHEAT SHEET
#      300   5 MIN
#      600  10 MIN
#      900  15 MIN
#     1800  30 MIN
#     2700  45 MIN
#
#     3600   1 HR
#     7200   2 HR
#    10800   3 HR
#    14400   4 HR
#    18000   5 HR
#    36000  10 HR
#    39600  11 HR
#    43200  12 HR
#    46800  13 HR
#    50400  14 HR
#    54000  15 HR
#    86400  24 HR
#
#    86400   1 DAY
#   172800   2 DAY
#   259200   3 DAY
#   345600   4 DAY
#   432000   5 DAY
#   518400   6 DAY
#   604800   7 DAY
#
#   604800   1 WEEK
#  1209600   2 WEEK
#  1814400   3 WEEK
#  2419200   4 WEEK
#
#  2419200   1 MONTH (FEBRUARY)
#  2505600   1 MONTH (FEBRUARY LEAP YEAR)
#  2592000   1 MONTH (APRIL, JUNE, SEPTEMBER, NOVEMBER)
#  2678400   1 MONTH (JANUARY, MARCH, MAY, JULY, AUGUST, OCTOBER, DECEMBER)
# 31536000  12 MONTH
1
2
3
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>

永久转向


Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) http://fred.oracle1.com/$1 [R=301,L]

Windows 上 Apache Webdav 问题

配置好了webdav,可以删除,可以覆盖,不能上传、建新目录。再这里找到的答案,原来是由于 mod_rewrite 引起的。如果你的目录下有 .htaccess 规则,在dav的location下加上 RewriteEngine off 来屏蔽掉。

A good win32 apache module binary download site

I found a very good win32 apache module binary download site, English site. You can download many binary module there. such as:

  • mod_perl
  • mod_fcgid
  • mod_macro

and this site is very cool for apache users! ;)

Apache 2.2.3 PHP 5.2.0 Mysql 4.1 Install

以 apache handler 和 fastcgi 两种方式安装 PHP 5.2.0, 并使用 –with-mysql 和 –with-mysqli 两种方式连接 Mysql 数据库

  1. 配置 PHP 安装
    1
    './configure' '--codefix=/opt/php5' '--with-apxs2=/opt/bin/apxs' '--enable-fastcgi' '--with-mysql=/usr/local/mysql' '--enable-calendar' '--enable-force-cgi-redirect' '--with-configure-file-path=/opt/php5/cgi' '--enable-trans-sid' '--with-gd' '--with-xml' '--with-ttf=/usr' '--with-freetype-dir=/usr' '--enable-exif' '--with-dom-xslt=/usr' '--with-jpeg-dir=/usr/local/jpeg6b' '--with-png-dir=/usr' '--with-zlib-dir=/usr' '--enable-ftp' '--with-curl=/usr' '--enable-mbstring' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-openssl=/usr' '--with-gettext' '--enable-sockets' '--enable-memory-limit' '--with-xmlrpc' '--enable-debug=no' '--enable-track-vars' '--with-iconv' '--enable-sqlite-utf8' '--with-pgsql=/opt/postgresql'
  2. 这里我还安装了 Postgresql 所以使用了 ‘–with-pgsql=/opt/postgresql’ ,不过奇怪的是 如果我使用
    1
    --with-pdo-mysql --with-pdo-pgsql

    就会出现配置安装的错误。

  3. 同时使用 mysql 和 mysqli 在 make 的时候可能会出现很多警告,在 MAKEFILE 文件中找到以 EXTRA_LIBS 开始的行,删除第二个 -lmysqlclient_r

使用rewrite实现永久重定向

blogit.3322.org在DreamHost上不能使用,怎么办?使用301永久重定向吧,找个可以使用rewrite的空间,把blogit.3322.org指向那里(保持fred.oracle1.comblogit.3322.org相同的目录结构),在根目录下.htaccess写入下面内容,这样如果有人从搜索引擎比如Google访问

1
<a href="http://blogit.3322.org/weblog/2006/11/10/dreamhost-now/">http://blogit.3322.org/weblog/2006/11/10/dreamhost-now/</a>

那就会自动重定向到

1
http://fred.oracle1.com/weblog/2006/11/10/dreamhost-now/
1
2
3
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*) http://fred.oracle1.com/$1 [R=301,L]
相关资料

301 redirect: 301代表永久性转移(Permanently Moved),301重定向是网页更改地址后对搜索引擎友好的最好方法,只要不是暂时搬移的情况,都建议使用301来做转址。

302 redirect: 302代表暂时性转移(Temporarily Moved ),在前些年,不少Black Hat SEO曾广泛应用这项技术作弊,目前,各大主要搜索引擎均加强了打击力度,象Google前些年对Business.com以及近来对BMW德国网站的惩罚。即使网站客观上不是spam,也很容易被搜寻引擎容易误判为spam而遭到惩罚。

meta fresh: 这在2000年前比较流行,不过现在已很少见。其具体是通过网页中的meta指令,在特定时间后重定向到新的网页,如果延迟的时间太短(约5秒之內),会被判断为spam。

Apache 2.2 Vhost configure

Build Vhost in “extra/httpd-vhosts.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<VirtualHost localhost:80>
    NameVirtualhost localhost
    ServerAdmin root@localhost
    DocumentRoot "/opt/httpd/htdocs"
</VirtualHost>

<VirtualHost sqladmin.localhost:80>
#   NameVirtualhost sqladmin.localhost
    ServerAdmin [email protected]
    DocumentRoot "/opt/www/sqladmin"
    ServerPath "/opt/www/sqladmin"
    ServerName sqladmin.localhost
#   ServerAlias sqladmin.localhost
    <Directory />
    Options Indexes FollowSymLinks MultiViews
    IndexOptions FancyIndexing
    AllowOverride None
    DirectoryIndex index.php
    Order Deny,allow
    Allow from all
    </Directory>
    ErrorLog logs/sqladmin.localhost-error
</VirtualHost>
#
<VirtualHost php.localhost:80>
#   NameVirtualhost php.localhost
    ServerAdmin [email protected]
    DocumentRoot /opt/www/php
    ServerPath /opt/www/php
    <Directory />
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    DirectoryIndex /phpinfo.php
    Order Deny,allow
    Allow from all
    </Directory>
    ServerName php.localhost
    ErrorLog logs/php-error_log
    CustomLog logs/php-access_log common
</VirtualHost>

Let test the config file!

1
2
3
4
5
6
7
8
fred@localhost:php$ sudo /opt/httpd/bin/httpd -S
VirtualHost configuration:
127.0.0.1:80           is a NameVirtualHost
         default server localhost (/opt/httpd/conf/extra/httpd-vhosts.conf:29)
         port 80 namevhost localhost (/opt/httpd/conf/extra/httpd-vhosts.conf:29)
         port 80 namevhost sqladmin.localhost (/opt/httpd/conf/extra/httpd-vhosts.conf:35)
         port 80 namevhost php.localhost (/opt/httpd/conf/extra/httpd-vhosts.conf:53)
Syntax OK

Perl script on cgiwrap

If I use some script like this

1
2
#!/usr/bin/perl
print "Hello World!";

It will give me error :

1
[Wed Aug 16 08:57:50 2006] [error] [client 222.209.97.197] malformed header from script. Bad header=Hello World...: /www/cgiwrap/cgi/cgiwrap

And I must do like this:

1
2
3
4
#!/usr/bin/perl
use CGI qw(:standard);
print header('Welcome to my home page!');
print start_html(), "Linux and PHP", end_html();