zoukankan      html  css  js  c++  java
  • php手动搭建wamp环境(一)--之 Windows系统下PHP环境搭建

    1、PHP环境搭建的前提是 Apache HTTP Server (Apache 服务器)已经安装部署成功,并可以正常访问到服务器的主页面。Apache HTTP Server 的安装部署已经在上一篇讲解的很详细了,不清楚的可以点击“ Apache HTTP Servcer-Apache服务器下载与Windows系统下安装”查看具体操作。

    2、PHP下载:

        2.1、下载地址:http://php.net/downloads.php

        2.1、版本选择:如果是与 Apache 搭配,建议选择 Thread Safe 版本;如果是与 CGI 或者 FAST-CGI 搭配,建议选择 Non Thread Safe 版本。

    3、PHP环境搭建:

        3.1、将下载的 .zip 压缩包解压到指定的安装目录,此处安装路径为:D:soltphp_5.6.33。

        3.2、将 PHP 的根目录下的 php.ini-development 或者 php.ini-production复制一份并改名为 php.ini,作为PHP的配置文件;

        3.3、打开php.ini,修改配置信息:

            说明:a、ini文件的注释是分号(英文分号),所以取消注释就删除分号;

                       b、${phphome}是PHP的根目录,即:D:soltphp_5.6.33,配置文件中写成绝对路径。

            3.3.1、修改扩展文件的路径:

    ; extension_dir = "ext" 

        取消注释,或者改为: 

    extension_dir = "${phphome}ext";

        注意:如果是与 Apache 搭配,建议将扩展文件路径改为绝对路径,因为有可能加载不了。


            3.3.2、修改需要加载的扩展文件,下面代码是取消部分扩展程序的注释之后的代码:

    extension=php_bz2.dll
    extension=php_curl.dll
    extension=php_fileinfo.dll
    extension=php_gd2.dll
    extension=php_gettext.dll
    ;extension=php_gmp.dll
    ;extension=php_intl.dll
    ;extension=php_imap.dll
    ;extension=php_interbase.dll
    ;extension=php_ldap.dll
    extension=php_mbstring.dll
    extension=php_exif.dll ; Must be after mbstring as it depends on it
    extension=php_mysql.dll
    extension=php_mysqli.dll
    ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client
    extension=php_openssl.dll
    ;extension=php_pdo_firebird.dll
    extension=php_pdo_mysql.dll
    ;extension=php_pdo_oci.dll
    extension=php_pdo_odbc.dll
    extension=php_pdo_pgsql.dll
    extension=php_pdo_sqlite.dll
    extension=php_pgsql.dll
    ;extension=php_shmop.dll
    
    ; The MIBS data available in the PHP distribution must be installed. 
    ; See http://www.php.net/manual/en/snmp.installation.php 
    ;extension=php_snmp.dll
    
    extension=php_soap.dll
    extension=php_sockets.dll
    extension=php_sqlite3.dll
    ;extension=php_sybase_ct.dll
    extension=php_tidy.dll
    extension=php_xmlrpc.dll
    extension=php_xsl.dll

            3.3.3、设置默认的时区:

    [Date]
    ; Defines the default timezone used by the date functions
    ; http://php.net/date.timezone 选择时区列表网址
    date.timezone = Asia/Shanghai

            3.3.4、设置 ssl :

    [openssl]
    ; The location of a Certificate Authority (CA) file on the local filesystem
    ; to use when verifying the identity of SSL/TLS peers. Most users should
    ; not specify a value for this directive as PHP will attempt to use the
    ; OS-managed cert stores in its absence. If specified, this value may still
    ; be overridden on a per-stream basis via the "cafile" SSL stream context
    ; option.
    openssl.cafile= cacert.pem

        根据需求可以自己添加扩展。

        3.4、修改 Apache24conf 目录下的 httpd.conf 配置 Apache ,让 Apache 和 PHP 协同工作;

            3.4.1、DocumentRoot 设置:

                修改前:默认的是 Apache24 下的 htdocs 目录:

       

                修改后:指定到自定义的路径,但是要记住这个路径。

        

            3.4.2、修改默认的索引,以支持 PHP :
                修改前:

    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    <IfModule dir_module>
    DirectoryIndex index.html
    </IfModule>

             修改后:

    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    <IfModule dir_module>
    DirectoryIndex index.html index.php index.htm
    </IfModule>

            3.4.3、开启 rewrite 功能:将下面这行代码前面的 # 去掉:

    LoadModule rewrite_module modules/mod_rewrite.so

            3.4.4、加载 PHP 模块,注意绝对路径:

            如果是 PHP 5,在 httpd.conf 文件最后添加如下代码:

    #php5.6
    LoadModule php5_module D:/soft/php-5.6.33/php5apache2_4.dll 
    <IfModule php5_module> 
    PHPIniDir "D:/soft/php-5.6.33/" 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    </IfModule>

            如果是 PHP 7,则相应的更改,示例如下:

    #php7
    LoadModule php7_module D:/soft/php-7.x.x/php7apache2_4.dll
    <IfModule php7_module> 
    PHPIniDir "D:/soft/php-7.x.x/" 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    </IfModule>

        3.5、如果安装的PHP x64位版本,Apache也需要是x64位版本的。然后还要将php目录下的libeay32.dll、ssleay32.dll、libssh2.dll以及ext目录下的php_curl.dll等四个文件,都复制放到System32目录下。否则curl扩展无法使用。参考链接:http://my.oschina.net/lsfop/blog/496181  。未做验证,只是照做,正常显示。

    4、Apache + PHP 启动运行测试:

        4.1、在 D:softphp_5.6.33www 目录下,创建 index.php 文件,文本内容如下:

    <?php
    echo phpinfo();
    ?>

        4.2、重启 Apache 服务,打开浏览地址栏输入: localhost:8081/index.php 或者 127.0.0.1:8081/index.php ,就可以打开 PHP 页面。


    ---------------------

    原文链接:https://blog.csdn.net/weixin_39082031/article/details/79110311

  • 相关阅读:
    UVALive 7141 BombX
    CodeForces 722D Generating Sets
    CodeForces 722C Destroying Array
    CodeForces 721D Maxim and Array
    CodeForces 721C Journey
    CodeForces 415D Mashmokh and ACM
    CodeForces 718C Sasha and Array
    CodeForces 635C XOR Equation
    CodeForces 631D Messenger
    田忌赛马问题
  • 原文地址:https://www.cnblogs.com/echoppy/p/9959296.html
Copyright © 2011-2022 走看看