当前位置 主页 > 服务器问题 > Linux/apache问题 >

    apache php模块整合操作指南

    栏目:Linux/apache问题 时间:2020-02-05 11:00

    apache的版本:
    httpd-2.2.21-win32-x86-no_ssl
    php的版本:
    php-5[1].3.8-Win32-VC9-x86
    (一) 准备工作
    1.先找在D:/amp/php中找到php.ini-development这个文件,然后把它改成php.ini这个文件名
    2.用记事本,或editplus将其打开
    (二)操作步骤:
    1.告诉php所用的扩展模块所在位置
    807行 extension_dir = "D:/amp/php/ext" 点我查看
    2. 告诉php所用的时区 998行 点我查看代码
    date.timezone = PRC
    3.让apache引入php解释引擎 点我查看
    4. 如果要用php中引入相应模块 点我查看
    注意当在PHP中引入extension=php_curl.dll这个模块时apache2.2就会提示找到相应模块。如下图
     
    这时在apache2.2的配置文件pttd.conf中加入: 点我查看
    LoadFile "D:/amp/php/libeay32.dll"
    LoadFile "D:/amp/php/ssleay32.dll"
    5.如果整合PHP后,apache不能启动,且测试配置文件的结果类似于下图
     
    这是因为系统上没有相应的vc编译器的库文件和头文件.安装相应的库文件即可.以vc9为例, 安装 vcredist_x86.exe,即可解决
    以下是在apache2.2中的操作
    1):加载php模块
    例:在loadModule 语句下面,添加一行
    LoadModule php5_module "D:/amp/php/php5apache2_2.dll"
    2):通过声明,让apache能够识别.php程序
    在Addtyp 系列行附近,添加一行
    AddType application/x-httpd-php .php
    3):声明php.ini配置文件的位置,使apache能够读取php运行的相关参数.
    在apache的主记录行里(非<if Module>这样的配置段),添加一行
    PHPIniDir "D:/amp/php"
    4): 重启apache 测试效果.
    代码展示:
    复制代码 代码如下:
    [PHP]

    ; About php.ini ;

    ; PHP's initialization file, generally called php.ini, is responsible for
    ; configuring many of the aspects of PHP's behavior.
    ; PHP attempts to find and load this configuration from a number of locations.
    ; The following is a summary of its search order:
    ; 1. SAPI module specific location.
    ; 2. The PHPRC environment variable. (As of PHP 5.2.0)
    ; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
    ; 4. Current working directory (except CLI)
    ; 5. The web server's directory (for SAPI modules), or directory of PHP
    ; (otherwise in Windows)
    ; 6. The directory from the --with-config-file-path compile time option, or the
    ; Windows directory (C:\windows or C:\winnt)
    ; See the PHP docs for more specific information.
    ; http://php.net/configuration.file
    ; The syntax of the file is extremely simple. Whitespace and Lines
    ; beginning with a semicolon are silently ignored (as you probably guessed).
    ; Section headers (e.g. [Foo]) are also silently ignored, even though
    ; they might mean something in the future.
    ; Directives following the section heading [PATH=/www/mysite] only
    ; apply to PHP files in the /www/mysite directory. Directives
    ; following the section heading [HOST=www.example.com] only apply to
    ; PHP files served from www.example.com. Directives set in these
    ; special sections cannot be overridden by user-defined INI files or