红联Linux门户
Linux帮助

一次性成功整合apache+php !!(原创) 针对初学者

发布时间:2006-12-07 16:30:10来源:红联作者:heven8383
一次性成功整合apache+php !!(原创) 针对初学者
心得体会:一切从基础开始,如果能成功配置apache+php,那么在这个基础上去配置(apache+mysql+php)等就不难了~~。在配置过程中,最主要的是学会配置的方法,特别是懂得如何检测配置和编译是否正确!在配置过程中要有耐心,每编译一步后都检测下是否成功,这样做虽然麻烦点,但是却确保你一次就可以配置成功!只要你每一步都检测到位,那么最后一定是可以配置成功!

软件包:
httpd-2.0.55.tar.gz
php-4.4.4.tar.gz
先来安装apache
1. tar -zxvf httpd-2.0.55.tar.gz
2. cd httpd-2.0.55
3. ./configure --prefix=/usr/local/apche2 --enable-modules=so --enable-so
4. make
5. make install
了解: --prefix=/usr/local/apche2(指定安装apache的目录)
--enable-modules用来指定系统允许使用的功能扩展模块的类型,这里指定为so类型。
--enabel-so 用来指定允许使用DSO(Dynamic Share Object动态共享对象)
重点:用httpd -l 命令查看是否加载mod_so.c 模块 ,如果没有查看到证明DSO没有编译正确!



再来安装php
1. tar -zxvf php-4.4.4.tar.gz
2. cd php-4.4.4
(注意:初学者用./configure ——help 了解下apx2的用法再来编译!)
用法如下:
--with-apxs2[=FILE] EXPERIMENTAL: Build shared Apache 2.0 module. FILE is the optional pathname to the Apache apxs tool; defaults to apxs

3. ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs(以dso方式安装php至/usr/local/php)

如果出现如下证明快成功了。
+--------------------------------------------------------------------+
│ License: │
│ This software is subject to the PHP License, available in this │
│ distribution in the file LICENSE. By continuing this installation │
│ process, you are bound by the terms of this license agreement. │
│ If you do not agree with the terms of this license, you must abort │
│ the installation process at this point. │
+--------------------------------------------------------------------+

Thank you for using PHP.
4. make
5. make install
重点:按照如下方法检测安装和编译的php是否成功和apache整合!
1. 在、usr/local/apache2/modules找到有libphp4.so 或者在vi http.conf 下找到 LoadModule php4_module modules/libphp4.so 没有就证明刚才的php编译有问题,不成功!

(二) php与apache整合
1. 设置PHP配置文件php.ini
cp php4.4.4/php.ini.dist /usr/local/php/lib/php.ini
说明:在压缩包里有个php.ini文件,把他拷贝到/usr/local/lib/php.ini
然后打开文件,修改register_globals值为 register_globals = On
2. 设置apache的配置文件
vi /usr/local/apache2/conf/httpd.conf 找到DirectoryIndex改为如下: DirectoryIndex index.html index.htm index.html.var index.php (注意要有空格)
找到
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在它后面添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps



重点:
测试php:在 /usr/local/apache2/htdocs下新建一个文件index.php
添加
启动apache后 打开浏览器,输入
http://192.168.188.188/index.php(你的主机ip地址)
可以看到关于php的信息,证明php安装成功!!


翱翔(heven)
2006.12.7
文章评论

共有 7 条评论

  1. nettx 于 2007-02-27 12:19:58发表:

    !!!!!!!!!~~经典这作~

  2. 暗夜 于 2006-12-29 01:39:58发表:

    :ha3nd

  3. heven8383 于 2006-12-25 18:52:22发表:

    补充:关于重点:用httpd -l 命令查看是否加载mod_so.c 模块 ,如果没有查看到证明DSO没有编译正确!

    由于这个命令可能在某些系统无法查到这个模块,只能查到静态模块.而我们是动态编译进去的.但是都是编译正确的.最好的方法是查看apache的httpd.conf 文件里面有
    LoadModule caucho_module /usr/local/httpd-2.0.55/modules/mod_caucho.so

    ResinConfigServer localhost 6802

    就可以证明配置成功!

  4. peoong 于 2006-12-22 21:11:35发表:

    :0(1

  5. bridgegame 于 2006-12-20 21:26:25发表:

    :0L :time:1

  6. media 于 2006-12-13 10:53:04发表:

    很不错

  7. postsunboy 于 2006-12-09 01:50:13发表:

    支持,。。。。。