Ubuntu
1.hosts文件位置!/etc/hosts
ubuntu 配置虚拟主机
方法一:添加端口号
- 第一步进入 /etc/apache2/sites-available/ 目录,将 000-default.conf 复制一份到当前目录下并重命名,然后开始编辑。命令和编辑内容如下
cd /etc/apache2/sites-available/2
sudo cp 000-default.conf your.conf3
sudo vim your.conf
- 第二步将修改后的your.conf 文件 软链接到 sites-enabled 目录下
sudo ln -s /etc/apache2/sites-available/your.conf ../sites-enabled/
或者2 sudo ln -s ../sites-available/your.conf ../sites-enabled/
- 第三步重启apache
sudo /etc/init.d/apache2 restart
方法二:添加域名
方法二 只是 比方法一 多了一步修改hosts文件,在配置your.cnf 文件时略有不同
- 第一步在 /etc/hosts 文件中添加 127.0.0.1 对应的域名
sudo vim /etc/hosts
- 第二步和 方法一:第一步 一样只是 配置不同,详情如下图:
- 第三步和第四步就是添加一个软链接然后重启,参考法一。
Ubuntu下apache2的rewrite模块默认是不加载的。
只要运行了一下这个命令:a2enmod rewrite 就可以启用rewrite模块了。
或:
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load