• 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. shell 重启 tomcat 脚本

    #!/bin/sh # author hapday -- export TOMCAT_HOME=/usr/local/tomcat-pms tomcat_pid=$(ps -ef | grep ${T ...

  2. SharePoint 2013 - Workflow Manager

    1. Workflow Manager可以与SharePoint 安装在同一台机器上,只是不建议这么做:由于Workflow Manager 需要使用数据库,我个人将其安装在 SQL Server机器 ...

  3. 开通cnblogs博客

    开通博客,准备记录学习和开发过程

  4. github 专案介绍 – Python 范例:透过互动式的 Jupyter 和数学解释流行的机器学习演算法

    对于机器学习有兴趣,不少人应该会先从 Andrew Ng ( 吴恩达 ) 的机器学习课程开始,但是吴恩达的课程是使用 octave 这个工具当作练习.这个 github 项目包含使用 Python 实 ...

  5. vs2010开发链接服务器出现错误(SourceSafe)

    用vs2010开发项目链接服务器时出现 之前是因为权限问题,每次打开项目文件时 ,都要先直接进服务器然后打开项目. 用了两天,又不行了.就这个问题已经问了了老大不下3次了. 其实很是不想再麻烦他老人家 ...

  6. 服务器常用命令之 启用/禁用PING状态

    启用 echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all  (PING的通) 禁用 echo 1 > /proc/sys/net/ipv4/i ...

  7. 使用slmgr查看、删除windows 授权(key)

    查看 slmgr.vbs /dlv 删除授权 使用管理员权限进入cmd All program -> accessories -> Command Prompt (右键 已管理员方式运行) ...

  8. Python简单介绍以及Python环境搭建(入门1)

    转载请标明出处: http://www.cnblogs.com/why168888/p/6400694.html 本文出自:[Edwin博客园] Python 简单介绍 适合领域: Web网站和各种网 ...

  9. Android(java)学习笔记53:局部内部类

    1. 局部内部类 /* 局部内部类 A:可以直接访问外部类的成员 B:在局部位置,可以创建内部类对象,通过对象调用内部类方法,来使用局部内部类功能 面试题: 局部内部类访问局部变量的注意事项? A:局 ...

  10. Android(java)学习笔记45:深入分析Java ClassLoader原理

    1. 前言: Android中的动态加载机制能更好的优化我们的应用,同时实现动态的更新,这就便于我们管理我们的应用,通过插件化来减轻我们的内存以及CPU消耗,在不发布新版本的情况下能更新某些模块. 当 ...