版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhang44429824/article/details/80002105
今天然想在自己的服务器上上传一个静态页面,并通过IP地址访问,于是在网上查了很多资料,大部分情况都是如下:
修改根目录:
在 /etc/apache2/sites-available 中修改 000-default.conf
中的DocumentRoot /var/www/
修改为想要的目录
比如:DocumentRoot /var/www/html/mainpage
接下来重启apache,sudo apache2ctl -k restart
即可
修改默认网页:
修改/etc/apache2/mods-available/dir.conf中的内容
原来是:
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
添加上想要的/wordpress就行啦
<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /wordpress
</IfModule>
后来,我发现一个很简单的方法直接访问我的页面:
首先下载个xftp,一般xshell5的这个位置都会提示你有,然后去下载一个安装:
下载完成后安装,直接将本地文件拖到服务器的/var/www/html里面:
然后通过IP地址访问:
大功告成!