Heim  >  Artikel  >  Backend-Entwicklung  >  Apache2.4+PHP5.6+MySQL5.6整合配置

Apache2.4+PHP5.6+MySQL5.6整合配置

巴扎黑
巴扎黑Original
2016-11-11 11:10:001259Durchsuche

1.Apache安装

      Apache24\conf文件夹下的http.conf文件进行修改:

      (1)修改ServerRoot Apache的根路径

               默认下是ServerRoot"c:/Apache24",修改为:ServerRoot "D:/phpEnv/Apache24"(即为你解压后所在的文件夹)

      (2) 修改ServerName你的主机名称

                将ServerNamewww.example.com:80将前面的#去掉,该属性在从命令行启动Apache时需要用到。

      (3) 修改DocumentRoot Apache访问的主文件夹目录(即php,html代码文件所放置的路径位置)

                Apache默认的路径是在htdocs(D:\phpEnv\Apache24\htdocs)下面,里面会有个简单的入口文件index.html。这个路径可以自己进行修改,可将其配置在我自己新建的文件夹下,并在httpconf文件配置到新建的文件夹

                DocumentRoot "c:/Apache24/htdocs"

                

               修改为:

               DocumentRoot "D:\phpEnv\www"

              

       (4)修改入口文件配置:DirectoryIndex一般情况下我们都是以index.php、index.html、index.htm作为web项目的入口

            

                   DirectoryIndexindex.html

            

             修改为

            

                   DirectoryIndex  index.php index.htm index.html

            

       (5)设定serverscript的目录

               ScriptAlias/cgi-bin/ "c:/Apache24/cgi-bin/"改为=> ScriptAlias/cgi-bin/ "D:/phpEnv/Apache24/cgi-bin"

       

          AllowOverride None

          Options None

          Require all granted

       

        修改为

       

          AllowOverride None

          Options None

          Require all granted

       

       (6)测试Apache环境

                开始---运行,输入cmd,打开命令提示符。接着进入D:\phpEnv\Apache24\bin目录下回车httpd回车

 没有报错的话就可以测试了(保持该命令窗口为打开的状态)。

                访问DocumentRoot Apache文件夹下的index.html文件,出现"it works"说明正确安装并启动服务了。

        (6)配置windows服务

             新的命令窗口进入到\Apache24\bin目录下,敲入代码行:httpd.exe -k install -n "servicename",servicename表示服务名称自己修改,如“Apache24”。

 

2.PHP5.6安装

         1.将目录下的php.ini-development文件复制一份并改名为php.ini他是php的配置文件

         2、为Apache服务添加php支持

           # php5 support
           LoadModule php5_module E:/Java/server/phpEnv/php/php5apache2_4.dll
          # configure thepath to php.ini
          PHPIniDir "E:/Java/server/phpEnv/php"
          AddType application/x-httpd-php .php .phtml

        3.重启服务

          新建index.php文件,内容为保存,访问出现php的信息就说明php已经成功安装。

       4.常用配置修改(修改php.ini文件)

          (1)时区配置:date.timezone = Asia/Shanghai

          (2)mysql数据库支持:extension_dir = "ext",去掉前面的“;”并改为extension_dir ="D:\phpEnv\php\ext"打开php的扩展支持(ext文件夹下是对很多php扩展支持的文件)。

                  去掉以下行前面的";"                 

                  extension=php_mysql.dll

                  extension=php_mysqli.dll

                  重新启动服务,即可支持mysql数据库。


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php文件操作Nächster Artikel:安装memcache及php扩展