首页

wamp下Apache配置vhost和设置MySQL的密码

kkcode
2020-06-03  阅读 772

配置vhost

1、由于后面虚拟机中需要用到Rewrite所以先编辑Apache的conf目录下的httpd.conf文件。

文件位置:\wamp\bin\apache\apache2.4.9\conf\httpd.conf

  a. 添加mod_rewrite.so模块支持。去掉下列行中前面的#号。

   LoadModule rewrite_module modules/mod_rewrite.so

  b.配置apache支持虚拟机,去掉#Include conf/extra/httpd-vhosts.conf前的#。

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

  c.找到Directory,修改里面的内容为:

<Directory />
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
复制代码

2、编辑conf目录下extra文件夹下的httpd-vhosts.conf。

在文件最下面添加新有配置,配置文件如下:

<VirtualHost *:80> 
#管理员邮箱
ServerAdmin webmaster@dummy-host2.example.com

#项目根目录
DocumentRoot "E:/www/qdgithub.com"

#域名
ServerName qdgithub.com

#别名,可根据实际需要添加                         
ServerAlias qdgithub.com

#错误日志路径,可根据实际需要添加
ErrorLog "logs/qdgithub.com.cn-error.log"
CustomLog "logs/qdgithub.com.cn-access.log" common    

# 重写规则,可根据实际需要添加 
RewriteEngine on
RewriteRule  ^/(.*)$       /apps/index.php [L]
</VirtualHost>
复制代码

3.到c盘hosts文件下添加域名

文件位置:C:\Windows\System32\drivers\etc

127.0.0.1 qdgithub.com

4.重启wampserver

设置MySQL的密码

先登录mysql客户端,由于起始密码是空,所以直接回车,进入mysql客户端。输入sql命令:update user set Password=PASSWORD('your password') where user='root'; 网上有博文说还需要输入flush priviliges,否则密码不能保存,但是我没有经过这一步也是可以的,

然后直接修改“D:\wamp\apps\phpmyadmin3.4.10.1\config.inc.php”文件,将

$cfg['Servers'][$i]['password'] = 'your password';复制代码

用户名不变,仍为'root',最后重启wamp就可以啦!

本文为作者原创文章,转载无需和我联系,但请注明转载链接。 【前端黑猫】