zoukankan      html  css  js  c++  java
  • Modify the apache2 default document and home page on ubuntu (ubuntu下修改apache2默认目录和默认主页)

    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“文件夹里面文件的链接,所以你只需要修改任意两者之一。

    感谢你的浏览!

  • 相关阅读:
    boboJavaScript中innerHTML,innerText,value
    bobo JS中document.write(" ");
    bobo window.location.href
    bobojQuery选择器总结
    bobo jquery attr()方法
    bobowindow.location.hash 属性使用说明
    bobo$(function(){})和$(document).ready(function(){})
    bobo使用jQuery解析JSON数据
    MyBatis实现CRUD操作
    第一个MyBatis程序
  • 原文地址:https://www.cnblogs.com/Smbands/p/11413592.html
Copyright © 2011-2022 走看看