当前位置:web 服务器 > Apache >>

超级服务器apache+mysql+php+ssl之完全安装攻略(2)

答案: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. |

| |

| Use "make certificate VIEW=1" to display the generated data. |

| |

| Thanks for using Apache & mod_ssl. Ralf S. Engelschall |

| rse@engelschall.com |

| www.engelschall.com |

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

现在你可以创建一个定制的证书。该选项将提示输入你的地址、公司、和其他一些东西。关于证书,请参阅本文的结尾。

# make certificate TYPE=custom

现在安装Apache...

# make install

如果一切正常,你应该看到类似于以下的信息:

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

| You now have successfully built and installed the |

| Apache 1.3 HTTP server. To verify that Apache actually |

| works correctly you now should first check the |

| (initially created or preserved) configuration files |

| |

| /usr/local/apache/conf/httpd.conf |

| and then you should be able to immediately fire up |

| Apache the first time by running: |

| |

| /usr/local/apache/bin/apachectl start |

| Or when you want to run it with SSL enabled use: |

| |

| /usr/local/apache/bin/apachectl startssl |

| Thanks for using Apache. The Apache Group |

| http://www.apache.org / |

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

现在验证Apache和PHP是否正在工作。然而,我们需要编辑srm.conf和httpd.conf保证我们把PHP类型加到了配置中。查看httpd.conf并去掉下列行的注释。如果你精确地遵循了本文的指令,你的httpd.conf文件将位于/usr/local/apache/conf目录。文件有一行针对php4的addtype加了注释,现在就去掉注释。httpd.conf 文件--片断

>

> # And for PHP 4.x, use:

> #

---> AddType application/x-httpd-php .php

---> AddType application/x-httpd-php-source .phps

>

>

现在我们准备启动Apache服务器看它是否在工作。首先我们将启动不支持SSL的服务器看它是否启动了。我们将检查对PHP的支持,然后我们将停止服务器并且启动启用了SSL支持的服务器并检查我们是否一切正常。configtest 将检查所有配置是否正确设置。

# cd /usr/local/apache/bin

# ./apachectl configtest

Syntax OK

# ./apachectl start

./apachectl start: httpd started

测试我们的工作

Apache 正在工作吗?

如果它工作正常,当你用Netscape连接服务器时,你将看见一幅类似于这幅屏幕捕获的屏幕。这是基本上 是Apache缺省安装的页面。

注意:你可以用域名或机器实际的IP地址与服务器连接。检查这两种情形,确保一切工作正常。

PHP支持正在工作吗??

现在将测试PHP支持……创建一个文件(名为:test.php ),它有下列信息。文件需要位于文档根路径下,它应该缺省设置为/usr/local/apache/htdocs。注意这依赖于我们以前选择的前缀,然而,这可在 httpd.conf中改变。设置多个虚拟主机将在另一篇文章加少,请留意,因为它将涉及安装Apache和它的指令的一些很基本的选项。

test.php 文件

<?

phpinfo();

?>

它将显示有关服务器、php和环境的信息。下面是输出页面的顶部的屏幕抓取。

很酷吧,PHP起作用了。

SSL 选择正在工作吗??

好了,现在我们准备测试SSL了。首先停止服务器,并以启用SSL的选项重启它。

# /usr/local/apache/bin/apachectl stop

# /usr/local/apache/bin/apachectl startssl

测试它是否工作:通过用一个Netscape与服务器连接并且选择https协议,即:https://youserver.yourdomain.com 或 http://yoursever.yourdomain.com:443 ,也可以再试一下你的服务器的 i

上一个:php3.ini及php.ini配置文件各选项的说明
下一个:超级服务器apache+mysql+php+ssl之完全安装攻略(1)

Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,