WAMPServer配置修改及问题汇总

时间:2022-05-11 21:40:42

备忘录

软件版本wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b

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

配置修改

自定义网站根目录:

  1、修改Apache配置:找到 "  盘符:\wamp\bin\apache\apache2.4.9\conf\httpd.conf  "下Apache配置文件,查找documentroot关键字,修改230行位置documentroot路径和252行<Directory "路径">标签对中的路径

  2、修改WAMP菜单[www目录(W)]:在wamp根目录 "  盘符:\wamp  "下,找到wampmanager.ini文件,查找Menu.Left关键字,在[Menu.Left]下的

  Type: item; Caption: "www 目录"; Action: shellexecute; FileName: "d:/wamp/www"; Glyph: 2  中修改Caption(名字)和FileName(路径)

  Type: item; Caption: "WAMPworkspace 目录"; Action: shellexecute; FileName: "E:/WAMPworkspace"; Glyph: 2

      接着在同目录下找到wampmanager.tpl文件,查找Menu.Left关键字,在[Menu.Left]下的

  Type: item; Caption: "${w_wwwDirectory}"; Action: shellexecute; FileName: "${wwwDir}"; Glyph: 2  中修改Caption(名字)和FileName(路径)

  Type: item; Caption: "WAMPworkspace 目录"; Action: shellexecute; FileName: "E:/WAMPworkspace"; Glyph: 2

  重启服务

WAMP多站定配置

  1、找到"  盘符:\wamp\bin\apache\apache2.4.9\conf\extrea\httpd-vhosts.conf  "下Apache的配置文件(作用:" 虚拟目录配置文件 "),复制

  <VirtualHost *:80>//80是端口,修改过端口的需要改端口值
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
  ServerName dummy-host2.example.com
  ErrorLog "logs/dummy-host2.example.com-error.log"
  CustomLog "logs/dummy-host2.example.com-access.log" common
  </VirtualHost>

  标签对即可,ServerAdmin:设置管理员邮箱地址;DocumentRoot:网站目录所在路径;ServerName:主机名;ErrorLog:错误日志;CustomLog:日常日志

  例如添加站点

  <VirtualHost *:80>
  DocumentRoot "E:/WAMPworkspace/demo"
  ServerName demo.com
  </VirtualHost>

  2、找到Apache配置文件" httpd.conf",查找httpd-vhosts,

  #Include conf/extra/httpd-vhosts.conf  去掉前边的"#"(#表示注释),修改为

   Include conf/extra/httpd-vhosts.conf

  3、修改windows hosts文件:目录: "  C:\Windows\System32\drivers\etc\hosts  "  ,在最后添加以下语句配置站点:

    127.0.0.1     demo.com  //遇到demo.com时,优先从127.0.0.1请求资源

  说明:由于我使用的版本是WAMP2.5的版本,所以在httpd.conf文件的<Directory "E:/WAMPworkspace/">...</Directory>标签对中如下显示

  #   onlineoffline tag - don't remove

    Require local

  此处的值不必修改,如果是WAMP的早期版本,在httpd.conf文件的<Directory "E:/WAMPworkspace/">...</Directory>标签对中如下显示

   #   onlineoffline tag - don't remove

     Order Deny,Allow

     Deny from all

     Allow from 127.0.0.1

  意思是说,拒绝一切访问资源,但允许127.0.0.1的访问资源,修改为

   #   onlineoffline tag - don't remove

     Order Deny,Allow

     Allow from all

   # Allow from 127.0.0.1

  重启服务

  最后尝试用 http://demo.com访问站点看看(首先要之前设置的demo站点中有内容)

自定义端口号

  1、找到Apache配置文件httpd.conf,查找Listen关键字,找到

    #Listen 12.34.56.78:80
      Listen 0.0.0.0:80
      Listen [::0]:80

  修改加粗处的端口号(任意端口)

  2、找到Apache配置文件httpd.conf,查找ServerName localhost关键字,在221行位置,找到

    ServerName localhost:80

   修改加粗处的端口号(和第一步修改的端口一致)

  3、修改WAMP菜单

   找到wampmanager.ini文件,查找Menu.Left关键字,找到Caption为Localhost、phpMyAdmin的菜单项,在Parameters的内容中加入端口

    Type: item; Caption: "Localhost"; Action: run; FileName: "C:\Windows\explorer.exe"; Parameters: "http://localhost:8088/"; Glyph: 5

    Type: item; Caption: "phpMyAdmin"; Action: run; FileName: "C:\Windows\explorer.exe"; Parameters: "http://localhost:8088/phpmyadmin/"; Glyph: 5

   找到wampmanager.tpl文件,查找Menu.Left关键字,找到Caption为${w_localhost}、${w_phpmyadmin}的菜单项,在Parameters的内容中加入端口   

    Type: item; Caption: "${w_localhost}"; Action: run; FileName: "${c_navigator}"; Parameters: "http://localhost:8088/"; Glyph: 5

    Type: item; Caption: "${w_phpmyadmin}"; Action: run; FileName: "${c_navigator}"; Parameters: "http://localhost:8088/phpmyadmin/"; Glyph: 5

  重启服务

  注意:修改完端口后,之前配置的站点中的端口号都要修改,例如修改端口为8088,访问http://demo.com:8088/看看修改结果

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

问题一

  Apache服务无法启动,WAMPServer图标处于粉红色

  解决办法:卸载重装

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