wampserver 站点管理
0 wampserver介绍
Windows下的Apache+Mysql/MariaDB+Perl/PHP/Python,一组常用来搭建动态网站或者服务器的开源软件,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。
随着开源潮流的蓬勃发展,开放源代码的LAMP已经与J2EE和.Net商业软件形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个IT界的关注。
LAMP是基于Linux,Apache,MySQL/MariaDB和PHP的开放资源网络开发平台,PHP是一种有时候用Perl或Python可代替的编程语言。这个术语来自欧洲,在那里这些程序常用来作为一种标准开发环境。名字来源于每个程序的第一个字母。每个程序在所有权里都符合开放源代码标准:Linux是开放系统;Apache是最通用的网络服务器;mySQL是带有基于网络管理附加工具的关系数据库;PHP是流行的对象脚本语言,它包含了多数其它语言的优秀特征来使得它的网络开发更加有效。
开发者在Windows操作系统下使用这些Linux环境里的工具称为使用WAMP。
1 wampserver 更改默认站点方法
主要修改三个文件,
{wampserver}/bin/apache/apache2.4.35/conf/httpd.conf
{wampserver}/bin/apache/apache2.4.35/conf/extra/httpd-vhosts.conf
{wampserver}/scripts/config.inc.php
其中前两个为apache的配置文件,修改其中的Document Root即可,请注意每个文件需要修改两处
改为如下示例即可
DocumentRoot "${INSTALL_DIR}/www/thinkphp5.0.22/public"
<Directory "${INSTALL_DIR}/www/thinkphp5.0.22/public/">
#
# 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>
将路径信息修改即可
对config.inc.php文件主要修改内容如下
$wampConf = @parse_ini_file($configurationFile);
//We enter the variables of the template with the local conf
$c_installDir = $wampConf['installDir'];
$wwwDir = $c_installDir.'/www/thinkphp5.0.22/public';
$c_wampVersion = $wampConf['wampserverVersion'];
$c_wampMode = $wampConf['wampserverMode'];
$c_navigator = $wampConf['navigator'];
2 wampserver 设置站点可允许远程访问
主要修改以下两个文件
{wampserver}/bin/apache/apache2.4.35/conf/httpd.conf
{wampserver}/bin/apache/apache2.4.35/conf/extra/httpd-vhosts.conf
首先设置网站挂载的ip地址,wampserver默认设置网站挂在0.0.0.0上,即全网卡可访问,所以首先要设置网站挂载在指定网卡上,可照下例修改**{wampserver}/bin/apache/apache2.4.35/conf/httpd.conf**文件
# 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 192.168.1.147:80
Listen [::0]:80
然后修改网站全ip可访问
此处两个文件均需更改
{wampserver}/bin/apache/apache2.4.35/conf/httpd.conf
DocumentRoot "${INSTALL_DIR}/www/thinkphp5.0.22/public"
<Directory "${INSTALL_DIR}/www/thinkphp5.0.22/public/">
#
# 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
Require all granted
</Directory>
{wampserver}/bin/apache/apache2.4.35/conf/extra/httpd-vhosts.conf
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/thinkphp5.0.22/public"
<Directory "${INSTALL_DIR}/www/thinkphp5.0.22/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
#Require local
Require all granted
</Directory>
</VirtualHost>
3 wampserver 站点动态调试
此处使用phpstorm作为ide,需要修改php.ini(如不知php.ini 具体位置,新建php脚本运行phpinfo()即可在其中查找到php.ini的位置)
在php.ini的最后添加如下代码即可
[xdebug]
zend_extension ="C:\WorkSpace\wampserver\bin\php\php7.2.10\zend_ext\php_xdebug-2.6.1-7.2-vc15.dll"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
修改php.ini之后打开phpstorm
File–>settings(shift+alte+s)
选择Languages & Frameworks–>PHP
首先设置xdebug port 与php.ini中的xdebug.remote_port相同即可,此处为9000
设置PHP–>Debug–>“DBGp proxy”
IDE key:PHPSTORM
Host:localhost
Port:80
再设置PHP–>Servers添加Server地址
此处为
Name:localhost
Host:localhost
Port:80
Debugger:Xdebug
以上配置设置完毕,设置断点,选择配置文件即可