⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 续sql.txt

📁 LINUX下的安装声卡等操作和技巧介绍
💻 TXT
字号:
作者:studyboy
email: studyboy@21cn.com
日期:2001-7-24 11:11:12
三)添加FastCGI模块: 
#mv mod_fastcgi_2.2.4 apache_1.3.12/src/modules/fastcgi 

(四)编译安装Apache 
#cd apache_1.3.12 
配置编译参数 
#./configure --prefix=/usr/local/apache \ 
> --activate-module=src/modules/php4/libphp4.a \ 
> --activate-module=src/modules/fastcgi/libfastcgi.a 
编译Apache 
#make 
安装Apache 
#make install 

(五)关闭原有系统自带的Apache 
#/etc/rc.d/init.d/httpd stop 

(六)配置Apache自身参数: 
1.编辑/usr/local/apache/conf/httpd.conf文件,修改以下参数: 
ServerName host.mydomain.name 
DocumentRoot "/home/httpd/html" 
<Directory "/home/httpd/html"> 
Options Indexes FollowSymLinks MultiViews Includes 
AllowOverride None 
Order allow,deny 
Allow from all 
</Directory> 
ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/" 
<Directory "/home/httpd/cgi-bin"> 
AllowOverride None 
Options None 
Order allow,deny 
Allow from all 
</Directory> 
DirectoryIndex index.html index.phtml index.php index.htm index.shtml index.fcgi 
2.修改自启动链接 
#cd /etc/rc.d/init.d 
#ln -fs /usr/local/apache/bin/apachectl httpd 

(七)配置PHP4.0参数: 
1.修改/usr/local/apache/conf/httpd.conf文件,修改以下参数: 
增加一行: 
AddType application/x-httpd-php .php .phtml .php3 
2.修改/usr/local/apache/bin/apachectl脚本,使启动支持中文ORACLE环境: 
在文件中66行("start)")下面加入几行: 
export ORACLE_HOME=/opt/oracle8i/u01 
export ORACLE_BASE=/opt/oracle8i 
export ORACLE_SID=ORCL 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib 
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data 
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280" 
3.修改/usr/local/apache/conf/srm.conf以在CGI程序中使用环境变量: 
PassEnv ORACLE_HOME 
PassEnv ORACLE_BASE 
PassEnv LD_LIBRARY_PATH 
PassEnv NLS_LANG 
PassEnv ORACLE_SID 
PassEnv PATH 

(八)配置FastCGI执行环境: 
1.修改/usr/local/apache/conf/httpd.conf文件,修改以下参数: 
增加几行: 
############ FastCGI Configures Begin ########################## 
AddHandler fastcgi-script .fcg .fcgi .fpl 
<Location /fcgi> 
SetHandler fastcgi-script 
Order deny,allow 
Allow from all 
Options ExecCGI Indexes Includes 
</Location> 
############### FastCGI Configure End ########################### 
2.创建fcgi的执行目录 
#mkdir /home/httpd/html/fcgi 
3.安装FCGI的Perl运行模块: 
#tar zxvf FCGI-0.53.tar.gz 
#cd FCGI-0.53 
#perl Makefile.PL 
#make 
#make install 

六.启运并测试 
1.启动Apache服务器: 
#/etc/rc.d/init.d/httpd start 
2.编写PHP测试程序: 
第一个测试程序:/home/httpd/html/t1.php 
内容: 
<? phpinfo() ?> 
第二个测试PHP与Oracle连接的PHP程序(表已经建好): 
<? 
$conn=OCIlogon("username","password","dblink"); 
$stmt=ociparse($conn,"insert into testtable (name,id) values ('中文测试',15)"); 
ociexecute($stmt); 
$stmt=ociparse($conn,"select name from testtab where id=15"); 
ocidefinebyname($stmt,"NAME",&$nick); 
ociexecute($stmt); 
ocifetch($stmt); 
echo "my name is $nick"; 
?> 
查看是否为中文输出 
第三个测试PHP与MySQL连接的PHP程序(表已经建好): 
<? 
$conn=mysql_connect("host","username","password"); 
mysql_query("insert into testtable (name,id) values ('中文测试',15)"); 
$result=mysql_query("select name from testtab where id=15"); 
$query_data=mysql_fetch_row($result); 
$nick=$query_data[0]; 
echo "my name is $nick"; 
?> 
3. 编写FastCGI的测试代码: /home/httpd/html/fcgi/test.fcgi 
#!/usr/bin/perl 
use FCGI; 
use DBI; 
$dbname="oracle"; 
$user="user"; 
$passwd="password"; 
$dbh=""; 

while(FCGI::accept()>=0) { 
&parse_form(); 
$id=$FORM{'id'}; 
$para=$FORM{'para'}; 
print "Content-type: text/html\n\n"; 
print "<html><body>\n"; 
if (!$dbh){ 
print "no oracle, need to connect
\n"; 
$dbh = DBI->connect("dbi:Oracle:$dbname",$user,$passwd); 
}else{ 
print "OK, oracle aleady connected
\n"; 
} 
$sth=$dbh->prepare("select name from testtable where id=15"); 
$sth->execute; 
@recs=$sth->fetchrow_array; 
$sth->finish; 
print "参数id=".$id." and my name is @recs[0] 
\n"; 
print "参数para=".$para."
\n</html>"; 
} 
####传入参数处理部分####### 
sub parse_form { 
my($buffer); 
my($pairs); 
my(@pairs); 
my($name); 
my($value); 
my $meth = $ENV{'REQUEST_METHOD'}; 

if ($meth eq 'GET' || $meth eq 'HEAD') { 
$buffer = $ENV{'QUERY_STRING'}; 
} 
elsif ($meth eq 'POST') { 
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 
} 
undef %FORM; 
@pairs = split(/&/, $buffer); 
foreach $pair (@pairs) { 
($name, $value) = split(/=/, $pair); 
$value =~ tr/+/ /; 
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
$value =~ s/<!--(.|\n)*-->//g; 

if ($allow_html != 1) { 
$value =~ s/<([^>]|\n)*>//g; 
} 
$FORM{$name} = $value; 
} 
} 
测试看看FastCGI是否正常执行了 


- 张宏 (maczh@sina.com) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -