搭建本地环境,本地使用apache设置绑定多个域名
2017-06-16 11:04
507 查看
使用的是phpstudy本地LAMP环境,主要通过修改Apache的vhosts.conf和本地的hosts两个文件来实现
通常使用的是同一端口不同域名访问不同的根目录
首先设置Apache的vhosts.conf
第一个网站使用域名一访问目录D:\software\phpstudy\WWW\laraDemoshop\public
第二个网站使用localhost.cn域名访问目录D:\software\phpstudy\WWW
<VirtualHost *:80>
DocumentRoot "D:\software\phpstudy\WWW\laraDemoshop\public"
ServerName 域名一
ServerAlias
<Directory "D:\software\phpstudy\WWW\laraDemoshop\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\software\phpstudy\WWW"
ServerName localhost.cn
ServerAlias
<Directory "D:\software\phpstudy\WWW">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
注意,修改的Apache的配置文件,修改完成后一定要重启,作者就是因为忘记重启,怎么都不生效,严重到怀疑人生。
然后修改本地的hosts目录,路径一般如下C:\Windows\System32\drivers\etc
修改的时候你应该要有权限,注意都是指向127.0.0.1不要加端口号
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
127.0.0.1 域名一
127.0.0.1 localhost.cn
保存修改,在命令行模式使用
ipconfig/flushdns清理下dns缓存,试一下,应该ok了。
参考文章: http://booby325.iteye.com/blog/1757303 https://jingyan.baidu.com/article/948f59241fa06cd80ef5f969.html
通常使用的是同一端口不同域名访问不同的根目录
首先设置Apache的vhosts.conf
第一个网站使用域名一访问目录D:\software\phpstudy\WWW\laraDemoshop\public
第二个网站使用localhost.cn域名访问目录D:\software\phpstudy\WWW
<VirtualHost *:80>
DocumentRoot "D:\software\phpstudy\WWW\laraDemoshop\public"
ServerName 域名一
ServerAlias
<Directory "D:\software\phpstudy\WWW\laraDemoshop\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\software\phpstudy\WWW"
ServerName localhost.cn
ServerAlias
<Directory "D:\software\phpstudy\WWW">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
注意,修改的Apache的配置文件,修改完成后一定要重启,作者就是因为忘记重启,怎么都不生效,严重到怀疑人生。
然后修改本地的hosts目录,路径一般如下C:\Windows\System32\drivers\etc
修改的时候你应该要有权限,注意都是指向127.0.0.1不要加端口号
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
127.0.0.1 域名一
127.0.0.1 localhost.cn
保存修改,在命令行模式使用
ipconfig/flushdns清理下dns缓存,试一下,应该ok了。
参考文章: http://booby325.iteye.com/blog/1757303 https://jingyan.baidu.com/article/948f59241fa06cd80ef5f969.html
相关文章推荐
- 使用WampServer搭建本地PHP环境,绑定域名,配置伪静态
- 使用WampServer搭建本地PHP环境,绑定域名,配置伪静态
- 使用WampServer搭建本地PHP环境,绑定域名,配置伪静态
- Lamp环境下设置绑定apache域名的方法分析
- windows快速搭建本地apache+php+mysql开发环境,多站点域名访问
- 使用apache设置绑定多个域名或网站
- 使用apache设置绑定多个域名或网站
- windows快速搭建本地apache php mysql开发环境,多站点域名访问
- 使用apache设置绑定多个域名或网站
- 使用apache设置绑定多个域名或网站
- Linux环境下,apache设置禁止恶意域名绑定和直接ip访问方法
- windows快速搭建本地apache+php+mysql开发环境,多站点域名访问
- PHP 开发环境的搭建和使用 01--apache服务器配置以及 IIS端口冲突解决
- 使用Apache+Dreamweaver(或者H-builder)搭建php开发环境
- 使用Jekyll + GitHub Pages搭建个人博客(绑定域名)
- 搭建Maven环境——使用本地的maven环境
- JavaWeb项目(发布)部署到云服务器 环境搭建 域名绑定项目 配置修改server.xml
- hosts 的设置将域名与iP在本地绑定
- 使用WAMP5搭建Apache+MySQL+PHP环境
- PHP环境搭建:设置Zend+Apache Httpd的虚拟主机