• 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. sort属性

    学习文章---链接 总结笔记 ①sort是Array.prototype的属性, ②如果不写入参数,则按照转换为的字符串的每个字符的unicode位点进行排序, ③如果传入一个比较函数sort(fun ...

  2. rem,em,px

    http://pxtoem.com/  px,em,rem单位转换工具 px(Pixel)根据显示屏分辨率,固定大小 em,根据父元素大小进行改变 rem,根据html进行相对改变 em 1. bod ...

  3. 如何用dva来构建你的应用

    dva的github地址: https://github.com/dvajs/dva-knowledgemap#%E9%80%9A%E8%BF%87-connect-%E7%BB%91%E5%AE%9 ...

  4. javascript实现数据结构与算法系列

    1.线性表(Linear list) 线性表--简单示例及线性表的顺序表示和实现 线性表--线性链表(链式存储结构) 线性表的静态单链表存储结构 循环链表与双向链表 功能完整的线性链表 线性链表的例子 ...

  5. Linux中怎么从root用户切换到普通用户

    su是在用户间切换,可以是从普通用户切换到root用户, test@ubuntu:~$ su Password:  root@ubuntu:/home/test# 也可以是从root用户切换到普通用户 ...

  6. 在Eclipse安装Genymotion插件的经验心得

    个人心得分享,不当之处还请指正. Eclipse自带的Android模拟器已经无力吐槽了,新手刚上手时或许配置完环境已经精疲力尽了,或许还沉浸在开发成功的喜悦当中,对AVD模拟器的运行情况关注不大,渐 ...

  7. PHP:数字转Excel列头

    转自我的个人博客:阔野飞花 http://www.rexcao.net/archives/169 前段时间升级一个项目的Excel导出功能,这次的列数大概有60多条,在处理过程中发现一个问题,原先做好 ...

  8. 64位MATLAB和C混合编程以及联合调试

    [环境说明] 电脑操作系统:win 7 旗舰版,64位 MATLAB版本:R2013b VS版本:Microsoft Visual Studio 2010 [操作说明] 1.在原来工程的基础上添加下列 ...

  9. Jcrontab定时任务

           两篇博客:     http://blog.csdn.net/jijijiujiu123/article/details/9086847    网站同事写的(chenrui)       ...

  10. Protobuf协议的Java应用例子

    Protobuf协议,全称:Protocol Buffer 它跟JSON,XML一样,是一个规定好的数据传播格式.不过,它的序列化和反序列化的效率太变态了…… 来看看几张图你就知道它有多变态. Pro ...