gongzhonghao.png
扫码关注我们
最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

详解wamp搭建实例教程

来源:http://erdangjiade.com/topic/3091.html 你好,世界。 2017-09-25 22:42浏览(26)

好久没搭环境了,这次还算顺利。

先来回顾一下网站运行的原理。

OK,进入正题,本次搭建环境wamp版本如下:

Apache24: httpd-2.4.26-x64-vc11
php:php-5.6.30-Win32-VC11-x64
mysql:mysql-installer-community-5.5.56

1.文件夹路径如下:

(因配置文件 httpd.conf中多处默认路径为Apache24,方便起见文件夹名不做改动)

2.Apache安装

  • 下载后解压至Apache24

  • 准备Apache运行环境Visual C++ 2012

  • 进入命令提示符cmd运行指令查看是否可运行

  • 保持cmd光标闪动状态,即正在运行。测试地址栏 http://localhost,显示默认主页即表示可运行。

  • 大部分情况,我们要把Apache当作Windows服务器,故需要安装Apache

  • 在cmd中,上述路径下,httpd -k install httpd -k start

  • 此时在计算机服务中已加入该服务。

  • 为了使得在任何地方都可通过 httpd.exe运行该服务,需要添加环境变量。系统---高级系统设置---环境变量。

3.PHP安装

  • 下载并解压至php文件夹,nts版本不含 php5apache2_4.dll文件,无法被Apache加载,此处选择ts版本。

  • 为了能在cmd根目录下运行 php.exe,首先设置环境变量。

  • 设置环境变量之后,可在cmd根目录下运行命令 php.exe -f php文件路径,来运行PHP文件,如

    <?php 
    for($i=1;$i<=10;$i++){
        echo "$i";        
    }?>

    则在cmd模式下会显示

    12345678910

    *php可独立运行。

4.配置httpd.conf,使Apache可处理php

  • cmd根目录下,查看Apache已加载的模块

    httpd.exe -M

  • 在 httpd.conf文件中加入如下:

    LoadModule php5_module D:/wamp/php/php5apache2_4.dll
    PHPIniDir "D:/wamp/php"
    AddType application/x-httpd-php .php .html .htm

5.配置php.ini,使其可加载其他模块

  • 复制 php.ini-development一份,重命名为php.ini

    修改时区
    date.timezone=PRC
    修改加载模块的路径
    extension_dir = "D:/wamp/php/ext"
    选择要加载的模块并去掉分号
    extension=php_mysql.dll
    extension=php_mysqli.dll等等

  • 同样可在cmd根目录下,查看php已加载的模块

    php.exe -M

      

6.配置虚拟主机

  • 修改 httpd.conf,将#去掉,就可以启用设置

    #Virtual hosts
     Include conf/extra/httpd-vhosts.conf

  • 修改 httpd-vhost.conf

    添加:
    <VirtualHost *:80>
        DocumentRoot "G:/color"
        ServerName color.com
        ErrorLog "logs/color.log"
        CustomLog "logs/color.log" common
    </VirtualHost> 

  • 将 httpd.conf 的Require all denied注释,即

    <Directory />
        AllowOverride none
      # Require all denied
    </Directory>
    缺少这一步,会显示 403 Forbidden

      

7.安装mysql

  • 下载 选择MSI Installer)

  • 安装略。

  • 测试是否可正常运行

    C:>net stop mysql
    MySQL 服务正在停止.
    MySQL 服务已成功停止。
    C:>net start mysql
    MySQL 服务正在启动.
    MySQL 服务已经成功启动。

  • 登录到mysql服务器

    C:>mysql.exe -hlocalhost -uroot -proot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.5.56 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql>

    即表示登陆mysql成功。

至此,环境已经基本搭建完成。重启apache命令:httpd -k restart

以上就是详解wamp搭建实例教程的详细内容,更多请关注二当家的素材网其它相关文章!

评论0
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

1 2