Category Archives: apache

xdebug调试php,断点不起作用

在xp上装了eclipse和VMware, 在VMware上装了redhat, 在redhat上装了apache,php,xdebug,在php.ini里配置xdebug如下:

zend_extension=/usr/lib/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_host=xx.xx.xx.xx
xdebug.remote_port=9000
xdebug.remote_mode=req

然后在eclipse里设置断点,发现断点不起作用,直接所有的代码一次性运行完了,到xdebug官网仔细看了下配置的说明, 原来xdebug.remote_host并不是apache所在服务器的IP, 而是远程调试机的IP, 我的情况,也就是xp的ip, 而不是VMware上redhat的IP,可原来我却把xx.xx.xx.xx配成了redhat的IP, 修改xx.xx.xx.xx为xp的IP,重启apache, 一试,果然单步调试成功了。

install_driver(Oracle) failed: Can’t load `…/DBD/Oracle/Oracle.so’ for module DBD::Oracle

Description

This section is from the "Practical mod_perl " book, by Stas Bekman and Eric Cholet . Also available from Amazon: Practical mod_perl

Here’s an example of the full error report that you might see:

install_driver(Oracle) failed: Can't load
'/usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/Oracle/Oracle.so'
for module DBD::Oracle:
libclntsh.so.8.0: cannot open shared object file:
No such file or directory at
/usr/lib/perl5/5.6.1/i386-linux/DynaLoader.pm line 169.
at (eval 27) line 3
Perhaps a required shared
library or dll isn't installed where expected at
/usr/local/apache/perl/tmp.pl line 11

On BSD-style filesystems, LD_LIBRARY_PATH is not searched for setuid programs. If Apache is a setuid executable, you might receive this error. Therefore, the first solution is to explicitly load the library from the system-wide ldconfig configuration file:

panic# echo $ORACLE_HOME/lib >> /etc/ld.so.conf
panic# ldconfig
(使用该方法我的问题就解决了)

Another solution to this problem is to modify the Makefile file (which is created when you run perl Makefile.PL ) as follows:

  1. Search for the line LD_RUN_PATH=

  2. Replace it with LD_RUN_PATH=my_oracle_home/lib

where my_oracle_home is, of course, the home path to your Oracle installation. In particular, the file libclntsh.so.8.0 should exist in the lib subdirectory.

Then just type make install , and all should go well.

Note that setting LD_RUN_PATH has the effect of hardcoding the path to my_oracle_home/lib in the file Oracle.so , which is generated by DBD::Oracle . This is an efficiency mechanism, so that at runtime it doesn’t have to search through LD_LIBRARY_PATH or the default directories used by ld.

For more information, see the ld manpage and the essay on LD_LIBRARY_PATH at http://www.visi.com/~barr/ldpath.html .

配置apache让用户登录

安装配置svn时得到了启发,当用户访问某页面时,如果要让用户输入用户名和密码,可以配置如下:

<Location /XXX>
  AuthType Basic
  AuthName "AUTH NAME"
  AuthUserFile /etc/auth-file
  Require valid-user
</Location>

auth-file可以通过htpasswd生成, 也可以通过这个命令增加用户:

htpasswd -cm /etc/svn-auth-file gene

htpasswd -m /etc/svn-auth-file pgj

我的svn在httpd.conf里的配置如下:

<Location /svn>
  DAV svn
  SVNPath /var/svn
  AuthType Basic
  AuthName "Subversion repository"
  AuthUserFile /etc/svn-auth-file
  Require valid-user
</Location>

perl写cgi之helloworld

用perl写cgi和c/c++写cgi差不多,请参照我的上一篇文章c/c++写cgi之helloworld

这里只说明了怎么用perl写一个cgi的helloworld程序

创建新文件hello.pl, 内容如下:

#!/usr/bin/perl

print "Content-type: text/html\r\n\r\n";
print "Hello World!\n";

用命令chmod 777 hello.pl使hello.pl可执行

copy hello.pl到 cgi-bin目录下

在浏览器里打http://localhost/cgi-bin/hello.pl就可以看到结果了

另外,我发现并不需要在httpd.conf 的 AddHandler cgi-script .cgi后面加 .pl也是可以的。

c/c++写cgi之helloworld

最近比较闲,所以又回头来学习下c/c++, 但看来看去也没什么好学的,没什么项目,光学一门语言确实没什么好看的,那就来用c/c++写个cgi来玩玩吧,之前没做过cgi,所以这样就既可了解cgi又可复习c/c++了。

先来个c/c++的cgi hello world吧,本人是在apache下运行的啊

新建文件hello.c

#include <stdio.h>
main() {
    printf("Content-type:text/html\n\n");
    printf("Hello,World!");
}

用命令$gcc –o hello hello.c 生成 hello

然后查看apache配置文件httpd.conf, 设置为:[默认的差不多就是这样]

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride All
    Options ExecCGI
    Order allow,deny
    Allow from all
</Directory>

然后把生成的hello复制到 /var/www/cgi-bin/下,如果修改了配置的话,就先重起apache, 这时输入http://localhost/cgi-bin/hello,就应该可以看到结果了