Html 如何在远程unix服务器中查看html文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21124869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view html file in remote unix server?
提问by cjavier70
I currently have an html file on a remote unix server that I ssh to. I have been using SFTP to constantly transfer it to my local machine to view it after my edits, but I am tired of this.
我目前在远程 unix 服务器上有一个 html 文件,我可以通过 ssh 连接到该文件。我一直在使用SFTP不断地将其传输到我的本地机器以在我编辑后查看它,但我已经厌倦了。
What is the best program/method for Mac users to have a browser window view of the html file that is stored in a remote unix server? Or is there an ssh client that can easily edit html files?
Mac 用户拥有存储在远程 unix 服务器中的 html 文件的浏览器窗口视图的最佳程序/方法是什么?或者有没有可以轻松编辑html文件的ssh客户端?
回答by Anoop
It is possible, but with some playing around on the server.
这是可能的,但在服务器上有一些玩弄。
Once you have ssh'ed into the server, install a web server in that box.
Say the file is named index.html, you should make it available at the URL http://localhost:8000/index.html
or port number can be anything.
一旦您通过 ssh 连接到服务器,请在该框中安装一个 Web 服务器。假设文件名为index.html,您应该使其在 URLhttp://localhost:8000/index.html
或端口号可用,可以是任何内容。
The simplest method I can think of starting a web server at that location is
我能想到的在该位置启动 Web 服务器的最简单方法是
cd /directory/where/html/is/present
python -m SimpleHTTPServer 8000 # For python 2
python3 -m http.server 8000 # For python 3
This works provided python is installed on the server. It should not be that hard to install it as python is available from almost every package manager in every flavor of linux.
如果服务器上安装了python,则此方法有效。安装它应该不难,因为几乎每个包管理器都可以在每种 linux 版本中使用 python。
Now that html is available at python
现在 html 在 python 中可用
http://localhost:8000/index.html
http://localhost:8000/index.html
on that machine.
在那台机器上。
But we have not yet configured the browser in such way.
但是我们还没有以这种方式配置浏览器。
To do that you need to ssh into the server again, but with a -D option this time
为此,您需要再次通过 ssh 进入服务器,但这次使用 -D 选项
ssh servername -D 7000
-D specifies application level tunneling when connecting via ssh
-D 指定通过 ssh 连接时的应用程序级隧道
Then in Firefox, preferences/options -> Advanced -> Networks -> Connection Settings -> Choose Manual Proxy configuration
然后在 Firefox 中,首选项/选项 -> 高级 -> 网络 -> 连接设置 -> 选择手动代理配置
SOCKS HOST should be localhost , port no 7000.
SOCKS HOST 应该是 localhost ,端口号为 7000。
Then the html should be directly available at
那么html应该可以直接在
http://localhost:8000/index.html
http://localhost:8000/index.html
in your Firefox browser.
在您的 Firefox 浏览器中。
This feature is only available in the Firefox browser.
此功能仅在 Firefox 浏览器中可用。
回答by al-ash
You can mount the remote directory with sshfs which gives you easy access to all the files. E.g.:
您可以使用 sshfs 挂载远程目录,这使您可以轻松访问所有文件。例如:
sshfs user@server:/directory/to/mount /local/directory/
回答by Benny Hill
There are multitudes of editors for *nix. A very common one is vi(or vim) however you may be happier using something like nano- many of the people I've helped with this sort of thing like the key-bindings of nano
better than they do vi
. And of course emacsis very common on *nix.
*nix 有很多编辑器。一个非常常见的方法是vi(或 vim),但是您可能会更喜欢使用nano 之类的东西- 我帮助过的许多人处理这类事情,例如nano
比他们做的更好的键绑定vi
。当然,emacs在 *nix 上很常见。