日期:2013-08-07  浏览次数:20576 次

PHP安装(UNIX)

现在安装PHP语言。你下载了最新的beta版,但是你可能必须下载非beta版本。记住beta版本需要GNU make。

你仍然假定是root,如果不是,su回到root。

PHP要求你已经预先配置好的Apache,以便它能知道所需的东西在哪儿。在以后你安装Apache服务器时,你将会回到这里。改变到你有源代码的目录。

# cd /tmp/DOWNLOAD

# gunzip -c apache_1.3.x.tar.gz | tar xf -

# cd apache_1.3.x

# ./configure

# cd ..

好的,现在你可以开始PHP的安装。提取源代码文件并进入其目录。如果你下载了版本3,在数字和命令上有一个改变,不大的改变。

# gunzip -c php-4.0.x.tar.gz | tar xf -

# cd php-4.0.x

如果你正在编译代码,configure将永远是你的朋友。:-) 因此,configure有很多选项。使用configure --help确定你想要增加哪些。我只是需要MySQL和LDAP,并且当然Apache。

# ./configure --with-mysql=/usr/local/mysql

--with-xml

--with-apache=../apache_1.3.x

--enable-track-vars

--with-ldap

make并安装二进制代码。

# make

# make install

拷贝ini文件到lib目录。

# cp php.ini-dist /usr/local/lib/php.ini

你可以编辑PHP文件来设置PHP选项,如你可以通过在你的php.ini文件中插入下列行,增加php的max_execution_time。

max_execution_time = 60;

注意:php3用户将使用php3.ini,而php4用户将使用php.ini文件。

Apache 与 Mod_SSL

该配置并安装mod_ssl和Apache了。对此,你将需要有rsaref-2.0文件。在http://ftpsearch.lycos.com/上搜索“rsaref20.tar.Z”。如果你不喜欢Lycos,你可以选择其他搜索引擎来搜索文件。当然只有你在美国才需要这个文件。(管它呢,你也可从别处下载,首先在http://ftpsearch.ntnu.no/查找“rsaref20.tar.Z”,好多啊!。)

创建rasref目录,你将在该目录提取文件。注意。这假定你下载了一个临时目录,而你就在此目录。

# mkdir rsaref-2.0

# cd rsaref-2.0

# gzip -d -c ../rsaref20.tar.Z | tar xvf -

现在配置并构造OpenSSL库。

# cd rsaref-2.0

# cp -rp install/unix local

# cd local

# make

# mv rsaref.a librsaref.a

# cd ../..

安装OpenSSL。记住,你将用它来创建临时证书和CSR文件。--prefix选项指定主安装目录。

# cd openssl-0.9.x

# ./config -prefix=/usr/local/ssl

-L`pwd`/../rsaref-2.0/local/ rsaref -fPIC

现在make、测试并安装它。

# make

# make test

# make install

# cd ..

我们将配置MOD_SSL模块,然后用Apache配置指定它为一个可装载的模块。

# cd mod_ssl-2.5.x-1.3.x

# ./configure

--with-apache=../apache_1.3.x

# cd ..

现在我们可以把更多的Apache模块加到Apache源代码树中。可选的--enable-shared=ssl选项使得mod_ssl构造成为一个DSO“libssl.so”。关于在Apache支持DSO的更多信息,阅读Apache源代码树中的INSTALL和 htdocs/manual/dso.html文档。我强烈建议ISP和软件包装维护者为了最灵活地使用mod_ssl而使用DSO工具,但是注意,DSO不是在所有平台上的Apache都支持。

# cd apache_1.3.x

# SSL_BASE=../openssl-0.9.x

RSA_BASE=../rsaref-2.0/local

./configure --enable-module=ssl

--activate-module=src/modules/php4/libphp4.a

--enable-module=php4 --prefix=/usr/local/apache

--enable-shared=ssl

[...你可加入更多的选项...]

生成Apache,然后生成证书,并安装...

# make

如果你已正确地完成,你将得到类似于以下的信息:

+-----------------------------------------------------------------------+

| Before you install the package you now should prepare the SSL |

| certificate system by running the "make certificate" command. |

| For different situations the following variants are provided: |

| |

| % make certificate TYPE=dummy (dummy self-signed Snake Oil cert) |

| % make certificate TYPE=test (test cert signed by Snake Oil CA) |

| % make certificate TYPE=custom (custom cert signed by own CA) |

| % make certificate TYPE=existing (existing cert) |

| CRT=/path/to/your.crt [KEY=/path/to/your.key] |

| |

| Use TYPE=dummy when you’re a vendor package maintainer, |

| the TYPE=test when you’re an admin but want to do tests only, |

| the TYPE=custom when you’re an admin willing to run a real server |

| and TYPE=existing when you’re an admin who upgrades a server. |

| (The default is TYPE=test) |

| |

| Additionally add ALGO=RSA (default) or ALGO=DSA to select |

| the signature algorithm used for the generated certificate.