PHP学习笔记8(WAMPServer)

(1)WAMPServer介绍

这里写图片描述

(2)修改www目录

  • 打开Apache下的httpd.conf文件
  • 把这里的地址替换为我们自定义的目录
DocumentRoot "${INSTALL_DIR}/www"  C:\Users\wangc\Desktop\php

<Directory "${INSTALL_DIR}/www">  C:\Users\wangc\Desktop\php
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
</Directory>
  • 如果出现一下情况

这里写图片描述

  • 这是由于之前配置了wampserver的本地虚拟服务器,现在想把本地项目访问从虚拟幻境访问改为http://localhost/这种方式访问,所有导致服务器找不到用户请求的UR修改Apache下的httpd.conf文件
  • 修改Apache下的httpd.conf文件(加一个#把虚拟服务器注释掉)
# Virtual hosts
# Include conf/extra/httpd-vhosts.conf
<?php
    echo 'success';
?>
  • 但是我们点击www 目录还是跳转安装目录下www文件夹,不是我们自定义的php文件夹
  • 修改D:\ITSoft\wamp64\wampmanager.ini
[Menu.Left]
;WAMPMENULEFTSTART
Type: separator; Caption: "Made in France by Otomatic"
Type: item; Caption: "Localhost"; Action: run; FileName: "C:/Program Files (x86)/Internet Explorer/iexplore.exe"; Parameters: "http://localhost/"; Glyph: 27
Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:/Program Files (x86)/Internet Explorer/iexplore.exe"; Parameters: "http://localhost/phpmyadmin/"; Glyph: 28
;WAMPVHOSTSUBMENU
Type: submenu; Caption: "Your VirtualHosts"; Submenu: myVhostsMenu; Glyph: 3

;WAMPALIASSUBMENU
;WAMPPROJECTSUBMENU

Type: item; Caption: "www 目录"; Action: shellexecute; FileName: "D:/ITSoft/wamp64/www"; Glyph: 2
Type: submenu; Caption: "Apache"; SubMenu: apacheMenu; Glyph: 3
Type: submenu; Caption: "PHP"; SubMenu: phpMenu; Glyph: 3
Type: submenu; Caption: "MySQL"; SubMenu: mysqlMenu; Glyph: 3
Type: separator; Caption: "64bit - Quick Admin"
Type: item; Caption: "启动所有服务"; Action: multi; Actions: StartAll
Type: item; Caption: "停止所有服务"; Action: multi; Actions: StopAll
Type: item; Caption: "重新启动所有服务"; Action: multi; Actions: RestartAll
Type: separator;
  • 将上述黄色文本改为以下
Type: item; Caption: "phpDemo"; Action: shellexecute; FileName: "C:\Users\wangc\Desktop\php"; Glyph: 2
  • 修改D:\ITSoft\wamp64\ wampmanager.tpl
[Menu.Left]
;WAMPMENULEFTSTART
Type: separator; Caption: "Made in France by Otomatic"
Type: item; Caption: "${w_localhost}"; Action: run; FileName: "${c_navigator}"; Parameters: "${c_edge}http://localhost${UrlPort}/"; Glyph: 27
Type: item; Caption: "${w_phpmyadmin}"; Action: run; FileName: "${c_navigator}"; Parameters: "${c_edge}http://localhost${UrlPort}/phpmyadmin/"; Glyph: 28
;WAMPVHOSTSUBMENU
;WAMPALIASSUBMENU
;WAMPPROJECTSUBMENU

Type: item; Caption: "${w_wwwDirectory}"; Action: shellexecute; FileName: "${wwwDir}"; Glyph: 2
Type: submenu; Caption: "Apache"; SubMenu: apacheMenu; Glyph: 3
Type: submenu; Caption: "PHP"; SubMenu: phpMenu; Glyph: 3
Type: submenu; Caption: "MySQL"; SubMenu: mysqlMenu; Glyph: 3
Type: separator; Caption: "${c_wampMode} - Quick Admin"
Type: item; Caption: "${w_startServices}"; Action: multi; Actions: StartAll
Type: item; Caption: "${w_stopServices}"; Action: multi; Actions: StopAll
Type: item; Caption: "${w_restartServices}"; Action: multi; Actions: RestartAll
Type: separator;
${ItemPutOnline}Type: item; Caption: "${w_putOnline}"; Action: multi; Actions: onlineoffline
;Type: item; Caption: "For local test only"; Action: run; FileName: "${c_phpExe}"; Parameters: "test.php";WorkingDir: "${c_installDir}/scripts"; Flags: waituntilterminated; Glyph: 9
;WAMPMENULEFTEND
  • 将上述黄色文本改为以下
Type: item; Caption: "php 目录"; Action: shellexecute; FileName: "C:\Users\wangc\Desktop\php"; Glyph: 2

(3)多站点配置

  • 修改D:\ITSoft\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf添加新的站点名
    • ServerName 站点名
    • DocumentRoot 站点根目录
# Virtual Hosts
#

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot D:/ITSoft/wamp64/www
    <Directory  "D:/ITSoft/wamp64/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName test01.com
    DocumentRoot C:\Users\wangc\Desktop\php\test01
</VirtualHost>

<VirtualHost *:80>
    ServerName test02.com
    DocumentRoot C:\Users\wangc\Desktop\php\test02
</VirtualHost>
#
  • 修改Apache下的httpd.conf文件
    • 把虚拟主机的注释去掉
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
  • 设置那些站点可以访问,此处设置为本地
<Directory "C:\Users\wangc\Desktop\php">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options +Indexes +FollowSymLinks +Multiviews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Require local
</Directory>
  • 修改C:\Windows\System32\drivers\etc\host
    • 表示访问test01.com会从本地的站点先找
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
127.0.0.1    test01.com
127.0.0.1    test02.com
  • 测试是否成功
    • C:\Users\wangc\Desktop\php目录添加test01 test02目录
    • 目录下添加index.php
    • 浏览器直接访问test01.com test02.com,能成功访问其中的index.php文件则证明配置成功

(4)修改端口号

  • 修改Apache下的httpd.conf文件
    • 把默认80端口改为8080端口
#
# Mutex: Allows you to set the mutex mechanism and mutex file directory
# for individual mutexes, or change the global defaults
#
# Uncomment and change the directory if mutexes are file-based and the default
# mutex file directory is not on a local disk or is not appropriate for some
# other reason.
#
# Mutex default:logs

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:8080
Listen [::0]:8080



# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName localhost:8080
  • 测试成功
    • 此时在浏览器访问localhost/test.php失败(等效于localhost:8080/test.php默认端口为80)
    • 必须默认localhost:8080/test.php
WampServer教程 据我所知很多同学都想要试着学习一下PHP,无奈要在Windows下安装搭建好一个PHP环境来学习对于菜鸟同学来说繁琐程度足以让一半以上的人放弃,毕竟 Apache+PHP+MySQL 这3个程序配置起来比较麻烦,对于新手来说,要弄清楚那些配置还真是云里雾里。所以傻瓜式整合型的WAMP程序(Windows+Apache+PHP+MySQL)就出来了,这类软件可以让懒人和新手朋友们免除安装配置多款服务器软件的麻烦,让同学们更快地投入到PHP语言本身的开发与学习当中去。 WAMP类的软件有许多,并且基本上都是免费的,比如 XAMPP 等,而今天在这里我们要向大家介绍的是——WAMP Server,没错!它就是叫做WAMP! LAMP是一个缩写,它指一组通常一起使用来运行动态网站或者服务器的著名免费开源的软件,其中包括:Linux操作系统;Apache网页服务器;MySQL数据库管理系统(或者数据库服务器);PHP 和有时 Perl 或 Python脚本语言。取各自名字的首个字母就组成LAMP这个词了。同样,在Windows操作系统下使用这些软件组合,就叫做WAMP了。 虽然这些开放源代码程序本身并不是专门设计成同另外几个程序一起工作的,但由于它们都是用于构建Web服务器的影响较大的开源软件,这就导致了这些组件经常配合在一起使用。在过去的几年里,这些组件的兼容性不断完善,在一起的应用情形变得更加普遍。并且它们为了改善不同组件之间的协作,已经创建了某些扩展功能。目前,几乎在所有的Linux发布版中都默认包含了这些产品。Linux操作系统、Apache服务器、MySQL数据库和Perl、PHP或者 Python语言,这些产品共同组成了一个强大的Web应用程序平台。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代码充电宝

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值