• 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. Topcoder SRM 563 Div1 500 SpellCards

    题意 [题目链接]这怎么发链接啊..... 有\(n\)张符卡排成一个队列,每张符卡有两个属性,等级\(li\)和伤害\(di\). 你可以做任意次操作,每次操作为以下二者之一: 把队首的符卡移动到队 ...

  2. C++基础--指针,&的用法

    #include "stdafx.h" #include <stdio.h> #include <string.h> int main() { ] = {, ...

  3. Chrome+ProxySwitchySharp+Putty

    好不容易写一个不编程的随笔了. 题目写出来,目的就已经很明确了,我就不详细解释原因了. 其实一年前多就已经配置成功了,写这篇随笔主要是给自己做一个备份,如果顺便能帮助其他人,也算功德无量了. 我就从最 ...

  4. 字符串相关函数-strcpy()与strcmp()

    一些小问题,避免出现低级错误. 1.strcmp(s1,s2): 字符串指针不见'\0'不回头,这个常在与单个字符作比较时写着写着就忘了. char* p_ch1="this is an e ...

  5. vim编辑下几个退出保存的命令

    :w 将数据写入硬盘 :w! 若文件属性为“只读”时,强制写入该文件.不过需要注意,这个是在你的权限可以改变的情况下才能成立 :q 离开vim :q! 修改过文件,又不想保存 :wq 保存后离开 :w ...

  6. 二、 OSI模型的实现TCP 、IP

    主要名词定义: IPIP层接收由更低层(网络接口层例如以太网设备驱动程序)发来的数据包,并把该数据包发送到更高层---TCP或UDP层:相反,IP层也把从TCP或UDP层接收来的数据包传送到更低层.I ...

  7. HDU 3336 KMP

    题意:求每一个前缀,跟前缀相同的每个子串. 此题:网上很多都是假程序,不过也AC了,的确我测试几个案例之后的的确确是存在这个问题. 分析:每一个前缀,可以考虑KMP,f失配指针,如何求得它出现了多少次 ...

  8. HDU 6034 6038

    6034:给每个字母26进制的贪心.例如一个字母 c = 7*26^89 + 6*26^50.... 这个字符串有10^5长度.普通的大整数会超时,这里要稀疏这个大数一个pair<int,int ...

  9. luogu P1710 地铁涨价

    嘟嘟嘟 一道最短路好题. 首先明确一点,把一条边的边权变成2,等于删去这条边.因为变成2后最短路肯定不会经过这条边,就相当于删去这条边了. 所以题目变成了依次删去Q条边,求每一次删完边后有几个点的最短 ...

  10. redis未授权访问getshell

    redis未授权访问的问题一年前就爆了,当时刚开始学安全,还不太懂.今天借着工作的机会来搞一把,看看能不能拿下一台服务器.其实前几天就写好了一直想找个实际环境复现一下,一直没有找到,只说下大致思路. ...