一、配置二级域名

修改hosts文件,模拟dns解析。

位置:/etc/hosts

添加

127.0.0.1  myweb.service.com

二、创建项目目录

apache默认目录是/var

mkdir -p  wwwroot/myweb

然后在目录下,创建index.html

路徑:/var/wwwroot/myweb/index.html

三、apache配置虚拟主机最核心的几个参数

cd  /etc/apache2/sites-available/

default.conf文件

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

#ServerName www.example.com

ServerAdmin webmaster@localhost

DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

复制,命名为 myweb.conf然后按照实际情况进行配置。

1.加ServerName参数    域名

2.修改DocumentRoot参数   路径

3.如果沒有下面這段,必須加上

DocumentRoot  /var/wwwroot/myweb

<Directory /var/wwwroot/myweb/>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

例子:

<VirtualHost *:80>

# The ServerName directive sets the request scheme, hostname and port that

# the server uses to identify itself. This is used when creating

# redirection URLs. In the context of virtual hosts, the ServerName

# specifies what hostname must appear in the request's Host: header to

# match this virtual host. For the default virtual host (this file) this

# value is not decisive as it is used as a last resort host regardless.

# However, you must set it for any further virtual host explicitly.

ServerName myweb.service.com  --記得去掉注釋#號

ServerAdmin webmaster@localhost

        DocumentRoot /var/wwwroot/myweb

<Directory var/wwwroot/myweb/>

        Options Indexes FollowSymLinks

        AllowOverride None

        Require all granted

</Directory>

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,

# error, crit, alert, emerg.

# It is also possible to configure the loglevel for particular

# modules, e.g.

#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are

# enabled or disabled at a global level, it is possible to

# include a line for only one particular virtual host. For example the

# following line enables the CGI configuration for this host only

# after it has been globally disabled with "a2disconf".

#Include conf-available/serve-cgi-bin.conf

</VirtualHost>

四、在/etc/apache2/sites-enabled    目录下还要创建软连接。

ln -s ../sites-available/myweb.conf  myweb.conf

***一定要加上後綴名.conf ****

五、完成之后,重启apache---service apache2 restart

现在到浏览器中访问配置好的域名就OK了。

例如myweb.service.com

ubuntu18下lamp虚拟路劲配置的更多相关文章

  1. 引用的时候js不能使用虚拟路劲,调试时用排除法测试

    今天碰到2个问题,搞了半天都没明白,又不报错: 就是js的问题:-->我返回了一个json,返回的json是正确的,但是view页面接受不到这个虚拟对象. 完全懵了,不知道为什么view页面接受 ...

  2. Windows下Apache 虚拟主机 VirtualHost 配置

    以下方式适合原生 Apache, XAMPP 和 WAMP 套件 1.修改Apache配置文件(httpd.conf),如下: # Virtual hostsInclude conf/extra/ht ...

  3. iis部署网站,使用虚拟路劲

    此前一直使用vs2010,没有考虑过配置IIS,但是一个项目完成后交付给甲方使用.肯定是要考虑IIS的安装和部署的.现从IIS的安装和asp.NET项目的部署两个方面讲解. IIS安装: 网上很多教程 ...

  4. 烂泥:ubuntu下vsftpd虚拟用户配置

    本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我微信ilanniweb. 以前搭建vsftpd都是在centos下,本以为在ubuntu按照以前的步骤搭建即可.可 ...

  5. ubuntu下的apache的虚拟主机的配置

    ubuntu下的虚拟主机的配置相对window下的虚拟主机配置有些许不同. 对于要新建的虚拟主机,我们可以有如下几个步骤: 1.在/etc/apache2/sites-available/目录下新建一 ...

  6. Ubuntu16.04下LAMP环境的安装与配置

    Ubuntu16.04下LAMP环境的安装与配置 最近做个实验需要用到Ubuntu环境的靶场,所以这里介绍下Ubuntu环境下LAMP的安装与配置,话不多说,我们gkd! 1.Apache2的安装 首 ...

  7. Python中的绝对路劲和相对路径

    1.绝对路径 os.path.abspath("文件名"): 显示的是一个文件的绝对路劲 eg: >>> import os >>> os.ch ...

  8. classpath路劲

    1.指的是tomcat下的web-if下的classes路劲 2. 发布时,红框中的文件全都会放到classes下,并且如果出现重名,下面的有可能会覆盖上面的文件

  9. centos LAMP第二部分apache配置 下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转 配置apache的访问日志 配置静态文件缓存 配置防盗链 访问控制 apache rewrite 配置开机启动apache tcpdump 第二十节课

    centos    LAMP第二部分apache配置  下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转  配置apache的访问日志  配置静态文件缓存  配置防盗链 ...

随机推荐

  1. 【UOJ#129】 【NOI2015】寿司晚宴

    题目描述 为了庆祝 NOI 的成功开幕,主办方为大家准备了一场寿司晚宴.小 G 和小 W 作为参加 NOI 的选手,也被邀请参加了寿司晚宴. 在晚宴上,主办方为大家提供了 n−1 种不同的寿司,编号 ...

  2. netty实现客户端服务端心跳重连

    前言: 公司的加密机调度系统一直使用的是http请求调度的方式去调度,但是会出现网络故障导致某个客户端或者服务端断线的情况,导致很多请求信息以及回执信息丢失的情况,接着我们抛弃了http的方式,改为T ...

  3. CodeForces 349B--Color the Fence(贪心)

    B. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. SimpleThreadPool给线程池增加自动扩充线程数量,以及闲时自动回收的功能

    给线程池增加自动扩充线程数量,以及闲时自动回收的功能 package com.dwz.concurrency.chapter13; import java.util.ArrayList; import ...

  5. LocalDate/LocalDateTime与String的互相转换示例(附DateTimeFormatter详解)

    摘自:https://www.jianshu.com/p/b7e72e585a37 LocalDate/LocalDateTime与String的互相转换示例(附DateTimeFormatter详解 ...

  6. crossdomain.xml解决跨域问题

    特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...

  7. 第六周学习总结&第四次实验报告

    第六周学习总结&第四次实验报告 学习总结 这周我们简单的学习了一点点关于接口的内容,接口是Java中最重要的概念之一,接口可以理解为一个特殊的类, 里面由全局常量和公共的抽象方法组成,接口摆脱 ...

  8. Mysql 中需不需要commit

    摘自:https://blog.csdn.net/zzyly1/article/details/81003122 mysql在进行增删改操作的时候需不需要commit,这得看你的存储引擎, 如果是不支 ...

  9. legend3---laravel中获取控制器名称和方法名称

    legend3---laravel中获取控制器名称和方法名称 一.总结 一句话总结: \Route::current()->getActionName();会有完整的当前控制器名和方法名 pub ...

  10. EventChannel 原生向Flutter传递数据

    目的:原生页面主动向Flutter页面传递信息 1 flutter步骤 定义EventChannel static const EventChannel eventChannel = EventCha ...