由于我比较懒,我直接把windows下手动搭建WAMP环境的教程从我博客上下载下来了,各位看客可以直接采用phpstudy、appserv等集成环境【个人推荐appserv,附带了VC库】
WAMP环境搭建Apache下载 配置Apache官网下载http://httpd.apache.org/
下载最新的Apache
由于Apache没有编译好的可执行文件因此只能下载别的平台编译好的
这里我们第一个ApacheHaus为例。
这里以VC14为例
下载,注意64位和32位以及OpenSSL模块版本
下载完是个压缩包
移动到想放的地方并解压(D盘为例)
然后把解压后的Apache24目录移动到D盘根目录
最后效果如下
CMD进入Apache的bin目录
CMD执行httpd -?可以看到httpd所有可用参数
D:\\Apache24\\bin httpd -?Usage: httpd [-D name] [-d directory] [-f file] [-C \"directive\"] [-c \"directive\"] [-w] [-k start|restart|stop|shutdown] [-n service_name] [-k install|config|uninstall] [-n service_name] [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]Options:-D name : define a name for use in IfDefine name directives-d directory : specify an alternate initial ServerRoot-f file : specify an alternate ServerConfigFile-C \"directive\" : process directive before reading config files-c \"directive\" : process directive after reading config files-n name : set service name and use its ServerConfigFile and ServerRoot-k start : tell Apache to start-k restart : tell running Apache to do a graceful restart-k stop|shutdown : tell running Apache to shutdown-k install : install an Apache service-k config : change startup Options of an Apache service-k uninstall : uninstall an Apache service-w : hold open the console window on error-e level : show startup errors of level (see LogLevel)-E file : log startup errors to file-v : show version number-V : show compile settings-h : list available command line options (this page)-l : list compiled in modules-L : list available configuration directives-t -D DUMP_VHOSTS: show parsed vhost settings-t -D DUMP_RUN_CFG : show parsed run settings-S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG-t -D DUMP_MODULES : show all loaded modules-M : a synonym for -t -D DUMP_MODULES-t -D DUMP_INCLUDES: show all included configuration files-t : run syntax check for config files-T : start without DocumentRoot(s) check-X : debug mode (only one worker, do not detach)
这里因为要安装为服务且不用默认名,所以执行
httpd -n Apache24_test -k install
执行完会报错,因为#httpd.conf第38行左右没有设置正确路径(默认是/Apache24)
找到第38行,然后改为正确的Apache24根路径
Define SRVROOT D:\\Apache24
ServerRoot ${SRVROOT}
默认网站路径是${SRVROOT}\\htdocs,在httpd.conf中251行左右可以修改,我修改为${SRVROOT}\\WWW
然后进入服务中启动Apache24进程即可,或者用ApacheMonitor.exe【推荐】进行控制
浏览器访问localhost,见到如下图界面即为配置且启动成功
PHP官网下载网址http://www.php.net/downloads.php
这里我选择线程安全X64版本
下载后
解压到D盘,目录重命名为PHP7
然后进入D:\\PHP7修改php.ini-development为php.ini
development为开发环境,production为产品环境,如果要上线,更改production为php.ini
然后设置环境变量
测试是否成功
cmd执行php –v
进入D:\\Apache24\\conf目录对httpd.conf文件进行编辑
在181行后添加PHP支持【httpd.conf文件注释语法为#】
LoadModule php7_module D:/php7/php7apache2_4.dll
AddType application/x-httpd-php .php
PhpIniDir D:/php7
文件改后如下图所示
进入D:/php7,编辑php.ini中898行和902行左右,使PHP对MySQL支持【PHP中注释为;】
编辑732行,设置PHP拓展目录
编辑932为date.timezone = PRC
编辑httpd.conf第284行
在D:\\Apache24\\WWW下新建index.php文件,内容是
?phpphpinfo();?
保存,本地访问localhost,出现如下图表示配置成功
下载地址https://dev.mysql.com/downloads/mysql/
进入后往下拉
选择X64版本的Zip是因为方便【好吧,我承认我懒】,图片中下面那个是用于开发测试的版本
这一步会提示登录帐号,不用管,直接下载
下载后解压重命名为mysql57并移动到D盘根目录,这时D盘目录如下图
然后进入mysql根目录,新建data空文件夹和my.ini
my.ini代码如下
[mysql]# 设置mysql客户端默认字符集default-character-set=utf8 [mysqld]#设置3306端口port = 3306 # 设置mysql的安装目录basedir=D:\\mysql57# 设置mysql数据库的数据的存放目录datadir=D:\\mysql57\\data# 允许最大连接数max_connections=200# 服务端使用的字符集默认为8比特编码的latin1字符集character-set-server=utf8# 创建新表时将使用的默认存储引擎default-storage-engine=INNODB
保存后cmd进入mysql57/bin
执行mysqld --verbose --help会提示帮助
D:\\mysql57\\bin mysqld --verbose --helpmysqldVer 5.7.20 for Win64 on x86_64 (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 itsaffiliates. Other names may be trademarks of their respectiveowners.Starts the MySQL database server.Usage: mysqld [OPTIONS]NT and Win32 specific options:--install Install the default service (NT).--install-manual Install the default service started manually (NT).--install service_name Install an optional service (NT).--install-manual service_name Install an optional service started manually (NT).--remove Remove the default service from the service list (NT).--remove service_name Remove the service_name from the service list (NT).--enable-named-pipe Only to be used for the default server (NT).--standalone Dummy option to start as a standalone server (NT).以下省略
执行mysqld --initialize-insecure --user=mysql,文档表明,MySQL5.7.6后自带数据库,使用-initialize生成随机密码,使用-initialize-insecure生成空密码。默认帐号root,后面的-user=mysql不更改
然后bin目录下执行mysqld install mysql57
由于默认是空密码,所以执行mysqladmin -u root -p password设置密码
然后执行net start mysql57
方便以后使用,新建环境变量D:\\mysql57\\bin
代码如下
test.php
?php$link = mysqli_connect(\'localhost\',\'root\',\'123456789\');//如果连接成功,会返回一个连接的标识,PHP7中去除了mysql_connect,改用mysqli_connect;if($link){ //如果有数据库连接标识,则为连接成功echo \"连接数据库成功\"; //echo是输出的意思}else{ //没有返回标识,则连接数据库失败echo \"连接数据库失败\";?
下载连接:https://www.phpmyadmin.net/
解压,改名为phpMyAdmin扔进web目录【D:\\Apache24\\WWW】
然后修改phpMyAdmin目录下的config.sample.inc.php为config.inc.php然后打开,编辑17行左右的$cfg[\'blowfish_secret\']=\'\';为$cfg[\'blowfish_secret\']=\'AbCdEfGhIjKlMn\';【任意字符串】
文件路径:D:\\Apache24\\WWW\\phpMyAdmin\\libraries\\config.default.php
修改以下项目:
$cfg[\'pmaabsoluteuri\'] = \'\';这里填写phpmyadmin的访问网址b.mysql主机信息
$cfg[\'servers\'][$i][\'host\'] = \'localhost\'; // mysql hostname or ip address 填写localhost或mysql所在服务器的ip地址,如果mysql和该phpmyadmin在同一服务器,则按默认localhost $cfg[\'servers\'][$i][\'port\'] = \'\'; // mysql port - leave blank for default port mysql端口,如果是默认3306,保留为空即可
c.mysql用户名和密码$cfg[\'servers\'][$i][\'user\'] = \'root\'; // mysql user访问phpmyadmin使用的mysql用户名fg[\'servers\'][$i][\'password\'] = \'\'; // mysql password (only needed对应上述mysql用户名的密码d.认证方法
$cfg[\'servers\'][$i][\'auth_type\'] = \'cookie\';
在此有四种模式可供选择,cookie,http,http,config
config方式即输入phpmyadmin的访问网址即可直接进入,无需输入用户名和密码,是不安全的,不推荐使用。
当该项设置为cookie,http或http时,登录phpmyadmin需要数据用户名和密码进行验证,,具体如下:
$cfg[\'blowfish_secret\'] = \'\';
如果认证方法设置为cookie,就需要设置短语密码,置于设置为什么密码,由您自己决定 ,但是不能留空,否则会在登录phpmyadmin时提示错误
不出意外的话访问localhost/phpmyadmin会出现以下界面
输入数据库帐号密码即可登录
至此,WAMP环境配置完毕,可正常使用了。
附
测试时区代码
?phpecho \"现在时间为: \"date(\'Y-m-d H:i:s\'); ?SQLI LABS搭建
github项目下载:https://github.com/Audi-1/sqli-labs
下载完成后解压,然后复制到网站目录下,
修改\\sql-connections目录下的db-creds.inc为你的数据库配置
如下图
然后打开localhost/sqli-labs-master/sqli-labs-master/进行安装数据库
【点击Setup/reset Database for labs】
当你看到上图,说明数据库已安装完毕,至此,环境配置完成
本文链接: http://syntasklabs.immuno-online.com/view-675684.html