• Change the apache2 default website directory

As we know, The apache2 default directory at /var/www/,If you want to modify it or you have some virtual hosts,You need to find the file which in "/etc/apache2/sites-enabled/000-default",Use vi editor and look for the "DocumentRoot" and Modify to your path.(Don`t forget restart your apache2 service ! ! !)


root@root:/etc/apache2/sites-enabled# ls
000-default.conf
root@root:/etc/apache2/sites-enabled# vi 000-default.conf


ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/

  • Change the apache2 default home page.

The apache2 default home page file at /etc/apache2/apache2.conf , This is a important file . I suggest you`d better to backup it before you modify it .After you enter this file,you need add "your site file name" behind "DirectoryIndex" , But,The  "DirectoryIndex" locations are diffierent with diffierent versions . At this time , you should press the order "grep -iR DirectoryIndex" ,and then it will show you:

root@root:/etc/apache2# grep -iR DirectoryIndex
mods-available/dir.conf: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /myblog
mods-enabled/dir.conf: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /myblog

You must feeling strange , Why do two files have same content? Because files in  "mods-enabled"  are all links to "mods-available" , So you just modify either of the two.

Thanks for your browsing !

  • 修改apache2默认网站目录

我们都知道,apache2默认目录是在/var/www/,假如你想去修改或者你有一些虚拟主机的话,你需要找到"/etc/apache2/sites-enabled/000-default“,使用VI编辑器并且找到”DocumentRoot“ 然后修改成你的路径。(不要忘记重启你的apache2服务!!!)

  • 修改默认主页

apache2 的默认主页文件在/etc/apache2/apache2.conf,这是个比较重要的文件,我建议你修改前备份,进入这个文件后,你需要在”DirectoryIndex“后面添加"你的站点主页文件夹名称",但是,因为不同版本的apache,”DirectoryIndex“文件位置也不一样,在这个时候,你需要按下命令”grep -iR DirectoryIndex“,然后会出现如下:

你一定会觉得奇怪,为什么会出现两个一样内容的文件?因为啊在”mods-enabled“文件夹的所有文件都是”mods-available“文件夹里面文件的链接,所以你只需要修改任意两者之一。

感谢你的浏览!

Modify the apache2 default document and home page on ubuntu (ubuntu下修改apache2默认目录和默认主页)的更多相关文章

  1. ubuntu下修改apache2.4的rewrite

    sudo a2enmod rewrite 修改/etc/apache2/apache2.conf中 AllowOverride None 为 AllowOverride ALL 重启 service ...

  2. Default Document <defaultDocument> IIS中的默认页面

    https://docs.microsoft.com/en-us/iis/configuration/system.webserver/defaultdocument/index Default do ...

  3. Opening Default document on IIS (HTML With WebAPI)

    Question: I've a deployed ASP.NET Web API with a website on the same folder that consume it. When I ...

  4. Ubuntu Server 14.04 & Apache2.4 虚拟主机、模块重写、隐藏入口文件配置

    环境: Ubuntu Server 14.04 , Apache2.4 一.Apache2.4 虚拟主机配置 01. 新建一份配置文件 在apache2.4中,虚拟主机的目录是通过/etc/apach ...

  5. 【ubuntu】Ubuntu 修改 Apache2 运行用户/用户组及修改方法

    我们在安装apache后,有时在上传文件的时候,提示没有权限或者是不可写,我们都会去查文件夹的权限.通过ls -l /var/www/html/website可以很直观的看出我们文件和文件夹的权限,d ...

  6. 在ubuntu上安装svn+apache2

    参考网站: http://www.thinksaas.cn/group/topic/335434/ http://blog.sina.com.cn/s/blog_3eba8f1c0100dqk1.ht ...

  7. ubuntu14.04下直接修改apache2默认目录导致wordpress样式改变的解决办法

    一开始看到网上有各种各样的解决方法: 第一种是直接将 sites-available目录下的000-default.conf中的下列代码: DocumentRoot /var/www/html 修改为 ...

  8. ubuntu-14.04服务器版下搭建apache2+svn+svnmanager服务

    本人linux小白,新进公司,被分配此任务,好崩溃,只能一边百度linux命令一边完成任务.从装系统开始一直到搭建好服务,也快一周了,足见水平之差,以下博文基本靠网络,再加上自己的摸索,直至搭建成功. ...

  9. CentOS6.5下安装apache2.2和PHP 5.5.28

    CentOS6.5下安装apache2.2 1. 准备程序 :httpd-2.2.27.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache2 ...

随机推荐

  1. scss-算术运算符

    由于scss具有编程语言的特点,那么运算符是必不可少的. 下面就通过代码实例分别做一下介绍. 一.赋值运算符: 赋值运算符就是我们最为熟悉的冒号(:),用来给声明的变量赋值. 代码实例如下: $hig ...

  2. HttpComponents

    一 概述 1.HttpComponents的作用 HttpComponents的作用是模拟浏览器获取网页内容. 二 使用 1.使用HttpComponents需要先导入架包. 2.使用 Closeab ...

  3. easyui datebox 精确到秒并且显示值

    其实这个官网文档有的,也就不啰嗦了,直接贴官网的代码吧. <input id="dt" type="text" name="birthday&q ...

  4. SpannableString与SpannableStringBuilder使用

    转自:http://blog.it985.com/14433.html1.SpannableString.SpannableStringBuilder与String的关系 首先SpannableStr ...

  5. python 正则,os,sys,hashlib模块

    简单的小算法 random随机获取数据 import random def getrandata(num): a=[] i= while i<num: a.append(random.randi ...

  6. IIS10搭建FTP服务

    1.首先是基本搭建 http://jingyan.baidu.com/article/0bc808fc408fa91bd585b94f.html 2.计算机—管理----本地用户和组----本地用户- ...

  7. SQL Server ->> SET ANSI_PADDING对于字符串插入的影响

    前面写了<SQL Server ->> 字符串对比>讲了SQL Server在做字符串对比和排序时的对尾随空格的处理方法. 再说说有一个和字符串尾随空格相关联的东西就是SET ...

  8. Laravel SMS 短信发送包

    Laravel Sms Laravel 贴合实际需求同时满足多种通道的短信发送组件 我们基于业务需求在 overtrue/easy-sms 基础进行扩展开发,主要实现如下目标: 支持短信验证码直接在 ...

  9. SQA冲刺

    下学期的第三次冲刺 一 SQA是什么 软件质量保证的目的是使软件过程对于管理人员来说是可见的.它通过对软件产品和活动进行评审和审计来验证软件是合乎标准的.软件质量保证组在项目开始时就一起参与建立计划. ...

  10. python:部分内置函数与匿名函数

    一.内置函数 1,数据类型:int,bool .......... 2,数据结构:dict,list,tuple,set,str 3,reversed--保留原列表,返回一个反序的迭代器 revers ...