该节将指导你在 Unix 系统上一般配置和安装 PHP。在安装之前,确定研究了任何与你平台或 web 服务器相关的章节。

预备知识和软件


基本 Unix 技术(如果编译,能够操作 "make" 和一个 C 编译器)

一个 ANSI C 编译器 (如果编译)

flex (用于编译)

bison (用于编译)

一个 web 服务器

任何模块特异组件(例如 gd、 pdf 库,等等)


有几种在 Unix 平台上安装 PHP 的方法,使用编译和配置的过程 ,或者通过大量的预打包的方式。本文主要关注编译和配置 PHP 的过程。

初始 PHP 安装和配置过程是使用 configure 脚本的命令行选项来控制的。本文概要了大部分通用选项,但是还有许多其它选项来玩耍。查 完整的配置选项 来得到一个详尽的选项列表。有几种安装 PHP 的方法。


作为 Apache 1.x 模块 或 Apache 2.x 模块。

作为 Caudium 的 Pike 模块

同 AOLServer, NSAPI, phttpd, Pi3Web, Roxen, thttpd 或 Zeus 一起使用

作为 CGI 命令行


Apache 模块快速参考
PHP 能够使用大量不同的方法编译,但是最常用的方式是作为 Apache 的模块。下面是一个快速安装楷观。

例子 3-2. PHP 4 快速安装指导( Apache 模块版本)

1.  gunzip apache_1.3.x.tar.gz
2.  tar xvf apache_1.3.x.tar
3.  gunzip php-x.x.x.tar.gz
4.  tar xvf php-x.x.x.tar
5.  cd apache_1.3.x
6.  ./configure --prefix=/www
7.  cd ../php-x.x.x
8.  ./configure --with-mysql --with-apache=../apache_1.3.x --enable-ftp
9.  make
10. make install
11. cd ../apache_1.3.x
12. ./configure --activate-module=src/modules/php4/libphp4.a
13. make
14. make install
15. cd ../php-x.x.x
16. cp php.ini-dist /usr/local/lib/php.ini
17. 编辑你的 httpd.conf 或 srm.conf 文件增加:
     AddType application/x-httpd-php .php

18. 使用你的正常过程来重新启动 Apache
服务器。(你必须停止和重新启动服务器,不仅仅是使用
HUP 或 USR1 信号来使服务器重载。)



建立
当 PHP 被配置,你准备建立 CGI 执行文件,命令 make 将完成这个。 如果它失败了,你不能找出原因,
Unix/Solaris 安装
本节包含了在 Solaris 系统上安装 PHP 的说明和提示。

需要的软件
默认安装的 Solaris 系统经常缺少 C 语言编译器和其相关工具。部分工具必须使用该工具的 GNU 版本,原因请阅读 FAQ。 下面是需要的软件:


gcc (推荐,其它 C 语言编译器也可以工作)

make

flex

bison

m4

autoconf

automake

perl

gzip

tar

GNU sed

此外,你还需要安装(可能编译)在你配置时定义的所有额外软件,比如说 Oracle 或 MySQL。

使用包
你可以使用 pkgadd 来安装大部分你需要的软件来简化 Solaris 安装过程。
使用二进制包安装
使用二进制包安装 PHP 到 OpenBSD 系统上是被推荐的同时也是最简单的方法。PHP 核心包已经从其他模块中分离出来了并且每个模块可以被独立的安装/卸载而不影响其他模块。所有这些安装 PHP 需要的文件你可以在 OpenBSD 光盘或者在 FTP 站点上找到。

你需要安装的 PHP 核心包的文件是 php4-core-4.3.3.tgz,它包含了基本的引擎(包括 gettext 和 iconv)。其次,你可能还需要安装一些模块包,如:php4-mysql-4.3.3.tgz 或 php4-imap-4.3.3.tgz。你需要使用命令 phpxs 去激活它,并且在通过修改 php.ini 文件来屏蔽他们。

例子 3-1. 在 OpenBSD 系统下的软件包的安装示例

# pkg_add php4-core-4.3.3.tgz
# /usr/local/sbin/phpxs -s
# cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
 (add in mysql)
# pkg_add php4-mysql-4.3.3.tgz
# /usr/local/sbin/phpxs -a mysql
 (add in imap)
# pkg_add php4-imap-4.3.3.tgz
# /usr/local/sbin/phpxs -a imap
 (remove mysql as a test)
# pkg_delete php4-mysql-4.3.3
# /usr/local/sbin/phpxs -r mysql
 (install the PEAR libraries)
# pkg_add php4-pear-4.3.3.tgz



阅读packages(7) 的用户手册,可以得到更多的在 OpenBSD 系统下有关二进制软件包(binary packages)的信息.

使用软件包
你同样可以使用 软件包目录(ports tree)来编译 PHP 的源代码。然而,这样的安装方式仅仅是建议对 OpenBSD 非常熟悉的高级用户去做。PHP4 的软件包被分别分为了两个子目录:core 和 extensions。其中 extensions 目录产生了所有 PHP 所支持的子模块。如果你不希望创建并且使用这些模块中的某些模块,请使用 FLAVOR no_* 参数。例如,如果你希望跳过编译 imap 模块,设置 FLAVOR 为 no_imap 即可。

常见问题

默认安装的 Apache 运行于 chroot(2) jail,将限制 PHP 脚本只能访问 /var/www 下面的文件。你需要建立 /var/www/tmp 目录来存放 PHP session 文件,或使用其它的 session 后端。此外,数据库套接字需要被放入 jail 或者侦听 localhost 接口。如果使用网络函数,某些 /etc 下面的文件例如 /etc/resolv.conf 和 /etc/services 需要被移动到 /var/www/etc 中去。OpenBSD PEAR 包会自动安装到正确的 chroot 目录中,因此不需要作特殊改动。有关 OpenBSD Apache 的更多信息见 OpenBSD FAQ。

对应于 gd 扩展的 OpenBSD 3.4 包需要预先安装 XFree86。如果你不想用那些需要 X11 的字体特性,则安装 php4-gd-4.3.3-no_x11.tgz 包来替代之。

早期发布版本
早期的 OpenBSD 系统使用 FLAVORS 系统把 PHP 链接为静态形式。自从使用这种方法编译就造成了问题即:很难制作二进制软件包。你仍然可以使用早期 stable ports trees,但这种方式已经不被 OpenBSD 小组所支持。如果你对此有任何建议和意见,软件包当前的维护人是 Anil Madhavapeddy(avsm at openbsd dot org)。
This section contains notes and hints specific to installing PHP on Mac OS X Server.

Using Packages
There are a few pre-packaged and pre-compiled versions of PHP for Mac OS X. This can help in setting up a standard configuration, but if you need to have a different set of features (such as a secure server, or a different database driver), you may need to build PHP and/or your web server yourself. If you are unfamiliar with building and compiling your own software, it's worth checking whether somebody has already built a packaged version of PHP with the features you need.

Compiling for OS X server
There are two slightly different versions of Mac OS X, client and server. The following is for OS X Server.

Mac OS X server install.


Get the latest distributions of Apache and PHP.

Untar them, and run the configure program on Apache like so. ./configure --exec-prefix=/usr \
--localstatedir=/var \
--mandir=/usr/share/man \
--libexecdir=/System/Library/Apache/Modules \
--iconsdir=/System/Library/Apache/Icons \
--includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
--enable-shared=max \
--enable-module=most \
--target=apache



If you want the compiler to do some optimization., you may also want to add this line: setenv OPTIM=-O2



Next, go to the PHP 4 source directory and configure it. ./configure --prefix=/usr \
   --sysconfdir=/etc \
   --localstatedir=/var \
   --mandir=/usr/share/man \
   --with-xml \
   --with-apache=/src/apache_1.3.12

If you have any other additions (MySQL, GD, etc.), be sure to add them here. For the --with-apache string, put in the path to your apache source directory, for example /src/apache_1.3.12.

Type make and make install. This will add a directory to your Apache source directory under src/modules/php4.

Now, reconfigure Apache to build in PHP 4. ./configure --exec-prefix=/usr \
--localstatedir=/var \
--mandir=/usr/share/man \
--libexecdir=/System/Library/Apache/Modules \
--iconsdir=/System/Library/Apache/Icons \
--includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
--enable-shared=max \
--enable-module=most \
--target=apache \
--activate-module=src/modules/php4/libphp4.a

You may get a message telling you that libmodphp4.a is out of date. If so, go to the src/modules/php4 directory inside your apache source directory and run this command: ranlib libmodphp4.a. Then go back to the root of the apache source directory and run the above configure command again. That'll bring the link table up to date. Run make and make install again.

Copy and rename the php.ini-dist file to your bin directory from your PHP 4 source directory: cp php.ini-dist /usr/local/bin/php.ini or (if your don't have a local directory) cp php.ini-dist /usr/bin/php.ini.


Compiling for MacOS X client
Those tips are graciously provided by Marc Liyanage.

The PHP module for the Apache web server included in Mac OS X. This version includes support for the MySQL and PostgreSQL databases.

NOTE: Be careful when you do this, you could screw up your Apache web server!

Do this to install:


Open a terminal window.

Type wget http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz, wait for the download to finish.

Type gunzip libphp4.so.gz.

Type sudo apxs -i -a -n php4 libphp4.so

Now type sudo open -a TextEdit /etc/httpd/httpd.conf. TextEdit will open with the web server configuration file. Locate these two lines towards the end of the file: (Use the Find command) #AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

Remove the two hash marks (#), then save the file and quit TextEdit.

Finally, type sudo apachectl graceful to restart the web server.


PHP should now be up and running. You can test it by dropping a file into your Sites folder which is called test.php. Into that file, write this line: .

Now open up 127.0.0.1/~your_username/test.php in your web browser. You should see a status table with information about the PHP module.
本节包含了在 Linux 发行版上安装 PHP 的说明和提示。

使用包
许多 Linux 发行版有某种类型的包安装系统,比如说 RPM。 这能够建立一个标准的配置,但当你需要一些不同特性(比如说安全服务器、不同的数据库驱动)时,你就需要安装 PHP 和 Web 服务器。如果你不熟悉怎样安装和编译你自己的软件,那么你可以去寻找,看是否有人已经制作了一个含有你所需要的 PHP 特性的包。
Tags: ,
本章节的内容和提示仅限于将 PHP 安装到 HP-UX 系统上。(此文章是由 paul_mckay at clearwater-it dot co dot 编写的)。

注: 本文涉及的技巧适用于 PHP 4.0.4 and Apache 1.3.9.


安装 PHP 你需要一个 gzip,你可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd-10.20.depot.Z,下载后解压缩,并且使用 swinstall 安装。

安装 PHP 你需要 gcc,你可以从如下地址得到该软件的二进制版本的发行包 http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd-10.20.depot.gz,解压缩这个文件,使用 swinstall 安装 gcc。

安装 PHP 你需要 GNU binutils,你可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2.9.1-sd-10.20.depot.gz,解压缩这个文件,使用 swinstall 安装 binutils。

安装 PHP 你需要 bison,你可以从如下地址得到该软件的二进制版本的发行包 http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd-10.20.depot.gz,安装方式同上。

安装 PHP 你需要 flex,你需要从 http://www.gnu.org 的镜像站点下载一个该软件的源代码。它被放置于一个 非 gnu 目录的 ftp 服务器上。下载这个文件,并且使用 gunzip 解压缩,然后执行 tar -xvf。进入新创建的 flex 目录并运行 ./configure,再执行 make 以及 make install。

如果这里出现了错误,很可能是由于 gcc 等工具不在路径中,应将其添加到环境变量 PATH 中。

下载 PHP 和 apache 的源代码。

下载后对他们分别执行 gunzip 和 tar -xvf。在开始编译他们之前我们需要修改一些文件。

首先 configure 文件需要被修改,因为它似乎忘记自己是在 hpux 系统下了,有更好的方法解决此问题,但最省事的是在配置脚本的第 47286 行加入 lt_target=hpux10.20。

其次是修改 Apache GuessOS 文件。在文件 apache_1.3.9/src/helpers 的第 89 行,将参数 echo "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0 替换为 echo "hp${HPUXMACH}-hp-hpux${HPUXVER}"; exit 0。

你不能把 PHP 作为共享对象方式安装到 HP-UX 因此你必须把他编译成为一个静态方式,参照 Apache 站点的指导就可以完成。

这样就完成了 PHP 和 Apache 的 安装编译,然而你的 Apache 将仍然不能启动,你必须为 Apache 配置一个新的用户名,例如 www 或 apache。然后修改你的 apache 配置文件 conf/httpd.conf 的 252 和 253 行,由原来的

code]
User nobody
Group nogroup
 [/code]

替换为类似如下的内容

User www
Group sys


这是因为在 hp-ux 系统下, apache 不能作为 nobody 用户运行。按照上面的方式配置 Apache 和 PHP 就应该可以正常工作了。
Tags: ,
做一流星,然后定义为影片剪辑,属性内实例名定义为fallingstar.上面加:
onClipEvent(load){
var angle=60;//流星的角度
var radian=angle*Math.PI/180;//转换为弧度
this._rotation=angle;//设置流星的角度
this._x=Math.random()*Stage.width;
this._y=0;//流星运动的起点坐标,x随机,y为0,让流星位于主场景之上
time=100;//运动时间控制
v=random(6)+2;//速度为一个随机值
a =0.09;//y方向的加速度,可以使效果更加逼真
vx=Math.cos(radian)*v;
vy=Math.sin(radian)*v;//x,y方向的速度
}
onClipEvent(enterFrame){
vy+=a;//y方向的速度加上加速度,这样水平方向是匀速运动,垂直方向是加速运动
_x+=vx;
_y+=vy;//设置流星的坐标
_alpha=_xscale=_yscale=time;//流星的缩放比例,用时间来控制
time-=2;//时间不断递减
if(_x<0||_x>Stage.width||_y<0||_y>Stage.height){
this.removeMovieClip();//如果流星超出范围删除
}
}

主场景上加入:

var n=0;
onEnterFrame=function(){
fallingstar.duplicateMovieClip("fallingstar"+n++,n);
}

精妙SQL语句 不指定

admin , 2006/04/01 12:44 , 代码片段,演示也有 , Comments(0) , Reads(3886) , Via Original
详细的请看原贴 ^_^

说明:复制表(只复制结构,源表名:a 新表名:b)

SQL: select * into b from a where 1<>1

说明:拷贝表(拷贝数据,源表名:a 目标表名:b)

SQL: insert into b(a, b, c) select d,e,f from b;

说明:显示文章、提交人和最后回复时间

SQL: select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b

说明:外连接查询(表名1:a 表名2:b)

SQL: select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c

说明:日程安排提前五分钟提醒

SQL: select * from 日程安排 where datediff('minute',f开始时间,getdate())>5

说明:两张关联表,删除主表中已经在副表中没有的信息

SQL:

delete from info where not exists ( select * from infobz where info.infid=infobz.infid )

说明:--

SQL:

SELECT A.NUM, A.NAME, B.UPD_DATE, B.PREV_UPD_DATE

FROM TABLE1,

(SELECT X.NUM, X.UPD_DATE, Y.UPD_DATE PREV_UPD_DATE

FROM (SELECT NUM, UPD_DATE, INBOUND_QTY, STOCK_ONHAND

FROM TABLE2

WHERE TO_CHAR(UPD_DATE,'YYYY/MM') = TO_CHAR(SYSDATE, 'YYYY/MM')) X,

(SELECT NUM, UPD_DATE, STOCK_ONHAND

FROM TABLE2

WHERE TO_CHAR(UPD_DATE,'YYYY/MM') =

TO_CHAR(TO_DATE(TO_CHAR(SYSDATE, 'YYYY/MM') ¦¦ '/01','YYYY/MM/DD') - 1, 'YYYY/MM') ) Y,

WHERE X.NUM = Y.NUM (+)

AND X.INBOUND_QTY + NVL(Y.STOCK_ONHAND,0) <> X.STOCK_ONHAND ) B

WHERE A.NUM = B.NUM

说明:--

SQL:

select * from studentinfo where not exists(select * from student where studentinfo.id=student.id) and 系名称='"&strdepartmentname&"' and 专业名称='"&strprofessionname&"' order by 性别,生源地,高考总成绩

说明:

从数据库中去一年的各单位电话费统计(电话费定额贺电化肥清单两个表来源)

SQL:

SELECT a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy') AS telyear,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '01', a.factration)) AS JAN,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '02', a.factration)) AS FRI,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '03', a.factration)) AS MAR,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '04', a.factration)) AS APR,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '05', a.factration)) AS MAY,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '06', a.factration)) AS JUE,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '07', a.factration)) AS JUL,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '08', a.factration)) AS AGU,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '09', a.factration)) AS SEP,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '10', a.factration)) AS OCT,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '11', a.factration)) AS NOV,

SUM(decode(TO_CHAR(a.telfeedate, 'mm'), '12', a.factration)) AS DEC

FROM (SELECT a.userper, a.tel, a.standfee, b.telfeedate, b.factration

FROM TELFEESTAND a, TELFEE b

WHERE a.tel = b.telfax) a

GROUP BY a.userper, a.tel, a.standfee, TO_CHAR(a.telfeedate, 'yyyy')

说明:四表联查问题:

SQL:select * from a left inner join b on a.a=b.b right inner join c on a.a=c.c inner join d on a.a=d.d where .....

说明:得到表中最小的未使用的ID号

SQL:

SELECT (CASE WHEN EXISTS(SELECT * FROM Handle b WHERE b.HandleID = 1) THEN MIN(HandleID) + 1 ELSE 1 END) as HandleID

FROM Handle

WHERE NOT HandleID IN (SELECT a.HandleID - 1 FROM Handle a)
初学ASP,程序是能勉强写出来了,但若每进行一次网站页面的改版,所有的源程序都将进行一次移植手术。为此所耗费的人力精力不计其数,甚至一不小心得不偿失、前功尽弃。

所以,梦想着那么大段的程序代码变成几个简单的字符代替,这样只要设计好页面把该功能插入就OK了。其实这也简单,只需将实现该功能的程序代码做成子程序,然后主页调用就可以了。

很多时候,在博客中国,你会选择到很多的模板,甚至有可能自己来设计;或者采用猪飞飞BLOG的各大站长都将其站点改得不近相同……这些,我们都归功于ASP采用模板的功能。

那下面偶就借花献佛,将模板拿来分析,以馈各位朋友。

首先,模板需要在线修改,则应采用数据库保存模板代码

所谓的模板,就是设计完工的标准的HTML代码,其中需要由程序实现的功能部分将采用特殊字符串代替。然,这些特殊字符串需要在显示的时候被编译为对应的功能。

2,假设第一模板内容代码

将下列代码拷贝到m_html字段中


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>testmb</title>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="5"
cellspacing="2">
 <tr align="right" bgcolor="#CCCCCC">
   <td height="20" colspan="2">$cntop$</td>
 </tr>
 <tr valign="top">
   <td width="25%" bgcolor="#e5e5e5">$cnleft$</td>
   <td width="74%" bgcolor="#f3f3f3">$cnright$</td>
 </tr>
</table>
</body>
</html>

注意$cntop$、$cnleft$、$cnright$,它们将要实现某些具体的程序功能

3,建立数据库连接文件conn.asp

<%
set conn= Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("testmb.mdb")
conn.Open connstr
%>

4,建立特殊字符串转换所需要的库文件lib.asp

该文件的主要作用是将实现某些功能的ASP程序做成字程序,以方便调用。

<%
dim topcode
sub cntop()
   topcode="现在时间是:"
   topcode=topcode&now()
end sub

dim leftcode,i
sub cnleft()
   for i = 1 to 5
   leftcode=leftcode&"<p>cnbruce.com"
   next
end sub

dim rightcode
sub cnright()
   for i = 1 to 9
   rightcode=rightcode&"<hr color="&i&i&i&i&i&i&">"
   next
end sub
%>

5,最后,调用数据库中的模板代码,将特殊字符串转换。

<!--#include file="conn.asp" -->
<!--#include file="lib.asp" -->
<%
sql="select * from moban where m_id=1"
set rs=Server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
mb_code=rs("m_html")
rs.close
set rs=nothing

cntop()
mb_code=replace(mb_code,"$cntop$",topcode)
cnleft()
mb_code=replace(mb_code,"$cnleft$",leftcode)
cnright()
mb_code=replace(mb_code,"$cnright$",rightcode)

response.write mb_code
%>


该页主要作用是将模板代码进行显示,并将其中的特殊代码转变为相对应子程序功能。

至此,ASP的模板功能基本完成,剩下的就是:建立具备编辑模板功能的程序页面,将库文件改变为自己所需要程序功能……

P哈P的用处 不指定

admin , 2006/04/01 11:17 , 代码片段,演示也有 , Comments(0) , Reads(4074) , Via Original
自打我学会了PHP之后,我腰不酸了,腿不痛,走起路来也有精神了、
您认准了,外国人生产的,效果啊!真的不错!
Pages: 39/40 First page Previous page 34 35 36 37 38 39 40 Next page Final page [ View by Articles | List ]