Linux服务器更改Apache2默认页面

方式一

获取root权限

su root //或者 sudo -i

进入 /var/www目录下

cd /var/www

创建目录

mkdir -m 777 myhtml  // myhtml为自己创建的文件名

上传我们要更换的页面html

  • 此处我使用的是FileZilla应用

修改配置文件

进入到/etc/apache2目录中

vim sites-available

打开000-default.conf

定位到这行DocumentRoot /var/www/html
把这个改成DocumentRoot /var/www/myhtml(此处改为前房创建的文件夹名)

然后退出到/etc/apache2/下的目录
进入到mods-enabled目录中

打开dir.conf文件
将DirectoryIndex 后面改成Main.html(此处为你上传的HTML),如图:

最后需要更改上传的HTML 的权限

  • 方式一: FileZilla选择文件右键
  • 方式二:chmod 777 Main.Html

重启apache2

sudo /etc/init.d/apache2 restart

方式二

  • 直接更换index.html页面

结束

参考:https://www.jianshu.com/p/9b8fa4e0bdbc

posted @ 2019-08-06 22:15  PoetryAndYou  阅读(3810)  评论(0编辑  收藏  举报