今天然想在自己的服務器上上傳一個靜態頁面,並通過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地址訪問:
大功告成!