Re: unsuscribe

2011-07-14 Thread Feng He
for the users who want to unsubscribe from this list please send an
empty email to modperl-unsubscr...@perl.apache.org instead of sending
to the list itself.


2011/7/15 RGKärcher 
>
> unsuscribe


Apache::DBI

2011-08-02 Thread Feng He
Hi,

I just want to develop a modperl application.
It's a handler, the database is Mysql.
Shall I use Apache::DBI, or DBI is just fine ?

Thank u.
Regards.


Re: Apache::DBI

2011-08-02 Thread Feng He
Hi,

Thank you all for the info.

I have finished writting the handler this morning, and have enabled
Apache::DBI in httpd.conf.
My handler is for this url:
http://bizstatus.game.yy.com/upload/

It accept client's uploaded data and write the data to database.
The strange stuff is, when I run more than one process for test, the
items number in database in not correct.

for example:

ab -n 100 -c 1 http://bizstatus.game.yy.com/upload/?arguments

This insert 100 items into database, the select result is correct.

But this one:

ab -n 100 -c 2 http://bizstatus.game.yy.com/upload/?arguments

or:

ab -n 100 -c 3 http://bizstatus.game.yy.com/upload/?arguments


When the client number is larger than one, the items number in
database is not correct.
it's always larger than 100, for example, 101, 102, 103 etc.

So, what's wrong with my program?

The handler looks as:

package ABC;
use strict;
use Apache2::RequestIO ();
use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::RequestUtil ();
use Apache2::Request ();
use DBI;


use Apache2::Const -compile => qw(OK NOT_FOUND);

sub handler {

my $r = shift;
my $q = Apache2::Request->new($r);
my $ip = $r->connection->remote_ip;

my $v1 = $q->param('arg1');
my $v2 = $q->param('arg2');


my $db = 'mydb';
my $host = '127.0.0.1';
my $port = 3306;
my $user = '***';
my $passwd = '***';
my $dbh = DBI->connect("dbi:mysql:database=$db;host=$host;port=$port",
$user, $passwd)
   or die $DBI::errstr;

my $str = "insert into mytable (v1,v2,check_time)
   values(?,?,now())";

my $sth = $dbh->prepare($str);
$sth->execute($v1,$v2) or die $dbh->errstr;
$sth->finish;

$r->content_type('text/plain');
$r->print('OK');

return Apache2::Const::OK;
}

1;



Thank you!


A question about the dumplicated named global variables

2012-11-06 Thread Feng He

Hello,

Sorry I now have a queston about this case.

I have two PM for config options:

package Config1;
use strict;
require Exporter;

our @ISA = qw(Exporter);
our $example_var;
our @EXPORT = qw($example_var);

$example_var =1;

1;


package Config2;
use strict;
require Exporter;

our @ISA = qw(Exporter);
our $example_var;
our @EXPORT = qw($example_var);

$example_var =2;

1;


In the startup.pl I use both:

use Config1;
use Config2;

Now in the handler one the code is:

package Myhand1;
use Apache2::RequestRec ();
...
use Config1;

our $example_var;

sub handler {

my $r = shift;
handle_with($example_var);
}

1;


in the handler two the code is:

package Myhand2;
use Apache2::RequestRec ();
...
use Config2;

our $example_var;

sub handler {

my $r = shift;
handle_with($example_var);
}

1;


Finally my question is, since the global variable $example_var is 
defined in both packages Config1 and Config2, and exported by both them.
When I use Config1.pm in handler Myhand1, and use Config2.pm in handler 
Myhand2, will this get conflict? Will the two values of $example_var 
happen to override each other? Why this happens or not happpens?


Thanks in advance.

Regards.


Re: A question about the dumplicated named global variables

2012-11-08 Thread Feng He
Hello,

Nobody knows this item? thanks.

07.11.2012, 12:01, "Feng He" :
> Hello,
>
> Sorry I now have a queston about this case.
>
> I have two PM for config options:
>
> package Config1;
> use strict;
> require Exporter;
>
> our @ISA = qw(Exporter);
> our $example_var;
> our @EXPORT = qw($example_var);
>
> $example_var =1;
>
> 1;
>
> package Config2;
> use strict;
> require Exporter;
>
> our @ISA = qw(Exporter);
> our $example_var;
> our @EXPORT = qw($example_var);
>
> $example_var =2;
>
> 1;
>
> In the startup.pl I use both:
>
> use Config1;
> use Config2;
>
> Now in the handler one the code is:
>
> package Myhand1;
> use Apache2::RequestRec ();
> ...
> use Config1;
>
> our $example_var;
>
> sub handler {
>
>  my $r = shift;
>  handle_with($example_var);
> }
>
> 1;
>
> in the handler two the code is:
>
> package Myhand2;
> use Apache2::RequestRec ();
> ...
> use Config2;
>
> our $example_var;
>
> sub handler {
>
>  my $r = shift;
>  handle_with($example_var);
> }
>
> 1;
>
> Finally my question is, since the global variable $example_var is
> defined in both packages Config1 and Config2, and exported by both them.
> When I use Config1.pm in handler Myhand1, and use Config2.pm in handler
> Myhand2, will this get conflict? Will the two values of $example_var
> happen to override each other? Why this happens or not happpens?
>
> Thanks in advance.
>
> Regards.


Re: A question about the dumplicated named global variables

2012-11-09 Thread Feng He

>
> BTW, to avoid confusion I'd prevent the import() function from being
> called in startup.pl by either
>
>   use Config1 ();
>   use Config2 ();
>
> or
>
>   BEGIN {
> require Config1;
> require Config2;
>   }
>
> Torsten

Thanks Torsten.
So if I don't use them in the startup.pl, then no conflict will happen?

Regards.


A question for security

2012-12-14 Thread Feng He
Hi,

Though this is nothing about modperl but a security question about the 
development environment.
I use bitbucket.org's private git hosting for my project development.
I just git clone the repo dir from the remote orginal.
And I will use directly this dir as app directory ( my handlers, registry 
scripts in here).
Does this have any security items? 

Thanks.


alias command in modperl environment

2012-12-19 Thread Feng He

Hello,


ServerAdmin x...@yyy.com
ServerName example.com

PerlModule Apache::DBI
PerlPostConfigRequire /path/to/startup.pl


SetHandler modperl
PerlResponseHandler Handler1



SetHandler modperl
PerlResponseHandler Handler2


Alias /zzz/ "/var/www/zzz/"

Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/cdn.access.log combined




I put some static files under /var/www/zzz/.
When accessing these static files, I got 403 error.
Can't alias command work for this case?

Thanks.


Re: alias command in modperl environment

2012-12-19 Thread Feng He

于 2012-12-19 16:47, Jie Gao 写道:

What's the error message in your errlog.log?


it simply said access reject.


Re: alias command in modperl environment

2012-12-19 Thread Feng He

Thanks a lot.


于 2012-12-19 23:02, Andy Colson 写道:

On 12/19/2012 2:40 AM, Feng He wrote:

Hello,


 ServerAdmin x...@yyy.com
 ServerName example.com

 PerlModule Apache::DBI
 PerlPostConfigRequire /path/to/startup.pl

 
 SetHandler modperl
 PerlResponseHandler Handler1
 

 
 SetHandler modperl
 PerlResponseHandler Handler2
 

 Alias /zzz/ "/var/www/zzz/"
 
 Options FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 

 ErrorLog /var/log/apache2/error.log
 LogLevel warn
 CustomLog /var/log/apache2/cdn.access.log combined




I put some static files under /var/www/zzz/.
When accessing these static files, I got 403 error.
Can't alias command work for this case?

Thanks.


Here is an apache config I use that works:

PerlSwitches -I "/pub/www/world"
PerlModule World


 PerlSetupEnv Off
 SetHandler modperl
 PerlResponseHandler World
 Order allow,deny
 Allow from all



 SetHandler default-handler
 Allow from all



 SetHandler default-handler
 Allow from all


Alias /world/css /pub/www/world/css
Alias /world/js /pub/www/world/js


-Andy




the MP gets good performance

2013-01-03 Thread Feng He
Hi,

I am running an application with MP2, it's running with two webservers
(with DNS round-robin) and a DB server (mysql). The OS is ubuntu Linux,
Apache's server version: Apache/2.2.14. Apache handles the requests
directly, there is no proxy in front.

Last day one of the server got unique accessing IP 632331, another got
unique IP 635232, so the application handles total IP 1267563 last day
(and almost every day).

All the requests are dynamic, 60% is writing to DB, 40% is reading from
DB. Eash webserver has about 500 long connections opened to mysql with
Apache::DBI. Both webservers and DB server have light load. For example,
the stat for one of the webservers:


# pstree
init─┬─apache2───518*[apache2]


# uptime
 22:32:58 up 69 days, 23:26,  2 users,  load average: 0.08, 0.08, 0.08


# free -m
 total   used   free sharedbuffers cached
Mem: 16073   7752   8321  0268   5077
-/+ buffers/cache:   2406  13666
Swap: 3813  0   3813


To post this I may want to say that MP just gets good performance. I
once wrote the application with other language, not as good as this.

Thanks.