From 56ba34b3f5f1b369c8e901a163f0012f207da791 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 18 Sep 2018 08:43:55 +0800 Subject: [PATCH 1/2] translated --- ...ow to build a URL shortener with Apache.md | 84 ------------------- ...ow to build a URL shortener with Apache.md | 82 ++++++++++++++++++ 2 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 sources/tech/20180720 How to build a URL shortener with Apache.md create mode 100644 translated/tech/20180720 How to build a URL shortener with Apache.md diff --git a/sources/tech/20180720 How to build a URL shortener with Apache.md b/sources/tech/20180720 How to build a URL shortener with Apache.md deleted file mode 100644 index 2599b9ecca..0000000000 --- a/sources/tech/20180720 How to build a URL shortener with Apache.md +++ /dev/null @@ -1,84 +0,0 @@ -translating---geekpi - -How to build a URL shortener with Apache -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) - -Long ago, folks started sharing links on Twitter. The 140-character limit meant that URLs might consume most (or all) of a tweet, so people turned to URL shorteners. Eventually, Twitter added a built-in URL shortener ([t.co][1]). - -Character count isn't as important now, but there are still other reasons to shorten links. For one, the shortening service may provide analytics—you can see how popular the links are that you share. It also simplifies making easy-to-remember URLs. For example, [bit.ly/INtravel][2] is much easier to remember than . And URL shorteners can come in handy if you want to pre-share a link but don't know the final destination yet. - -Like any technology, URL shorteners aren't all positive. By masking the ultimate destination, shortened links can be used to direct people to malicious or offensive content. But if you surf carefully, URL shorteners are a useful tool. - -We [covered shorteners previously][3] on this site, but maybe you want to run something simple that's powered by a text file. In this article, we'll show how to use the Apache HTTP server's mod_rewrite feature to set up your own URL shortener. If you're not familiar with the Apache HTTP server, check out David Both's article on [installing and configuring][4] it. - -### Create a VirtualHost - -In this tutorial, I'm assuming you bought a cool domain that you'll use exclusively for the URL shortener. For example, my website is [funnelfiasco.com][5] , so I bought [funnelfias.co][6] to use for my URL shortener (okay, it's not exactly short, but it feeds my vanity). If you won't run the shortener as a separate domain, skip to the next section. - -The first step is to set up the VirtualHost that will be used for the URL shortener. For more information on VirtualHosts, see [David Both's article][7]. This setup requires just a few basic lines: -``` -    - -        ServerName funnelfias.co - -    - -``` - -### Create the rewrites - -This service uses HTTPD's rewrite engine to rewrite the URLs. If you created a VirtualHost in the section above, the configuration below goes into your VirtualHost section. Otherwise, it goes in the VirtualHost or main HTTPD configuration for your server. -``` -    RewriteEngine on - -    RewriteMap shortlinks txt:/data/web/shortlink/links.txt - -    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] - -``` - -The first line simply enables the rewrite engine. The second line builds a map of the short links from a text file. The path above is only an example; you will need to use a valid path on your system (make sure it's readable by the user account that runs HTTPD). The last line rewrites the URL. In this example, it takes any characters and looks them up in the rewrite map. You may want to have your rewrites use a particular string at the beginning. For example, if you wanted all your shortened links to be of the form "slX" (where X is a number), you would replace `(.+)` above with `(sl\d+)`. - -I used a temporary (HTTP 302) redirect here. This allows me to update the destination URL later. If you want the short link to always point to the same target, you can use a permanent (HTTP 301) redirect instead. Replace `temp` on line three with `permanent`. - -### Build your map - -Edit the file you specified on the `RewriteMap` line of the configuration. The format is a space-separated key-value store. Put one link on each line: -``` -    osdc https://opensource.com/users/bcotton - -    twitter https://twitter.com/funnelfiasco - -    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html - -``` - -### Restart HTTPD - -The last step is to restart the HTTPD process. This is done with `systemctl restart httpd` or similar (the command and daemon name may differ by distribution). Your link shortener is now up and running. When you're ready to edit your map, you don't need to restart the web server. All you have to do is save the file, and the web server will pick up the differences. - -### Future work - -This example gives you a basic URL shortener. It can serve as a good starting point if you want to develop your own management interface as a learning project. Or you can just use it to share memorable links to forgettable URLs. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/apache-url-shortener - -作者:[Ben Cotton][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/bcotton -[1]:http://t.co -[2]:http://bit.ly/INtravel -[3]:https://opensource.com/article/17/3/url-link-shortener -[4]:https://opensource.com/article/18/2/how-configure-apache-web-server -[5]:http://funnelfiasco.com -[6]:http://funnelfias.co -[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache diff --git a/translated/tech/20180720 How to build a URL shortener with Apache.md b/translated/tech/20180720 How to build a URL shortener with Apache.md new file mode 100644 index 0000000000..8a88338a9c --- /dev/null +++ b/translated/tech/20180720 How to build a URL shortener with Apache.md @@ -0,0 +1,82 @@ +如何使用 Apache 构建 URL 缩短器 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) + +很久以前,人们开始在 Twitter 上分享链接。140 个字符的限制意味着 URL 可能消耗一条推文的大部分(或全部),因此人们使用 URL 缩短器。最终,Twitter 加入了一个内置的 URL 缩短器([t.co][1])。 + +字符数现在不重要了,但还有其他原因要缩短链接。首先,缩短服务可以提供分析 - 你可以看到你分享的链接的受欢迎程度。它还简化了制作易于记忆的 URL。例如,[bit.ly/INtravel][2] 比更容易记住。如果你想预先共享一个链接,但还不知道最终地址,这时 URL 缩短器可以派上用场。。 + +与任何技术一样,URL 缩短器并非都是正面的。通过屏蔽最终地址,缩短的链接可用于指向恶意或冒犯性内容。但是,如果你仔细上网,URL 缩短器是一个有用的工具。 + +我们之前在网站上[发布过缩短器的文章][3],但也许你想要运行一些由简单的文本驱动的缩短器。在本文中,我们将展示如何使用 Apache HTTP 服务器的 mod_rewrite 功能来设置自己的 URL 缩短器。如果你不熟悉 Apache HTTP 服务器,请查看 David Both 关于[安装和配置][4]的文章。 + +### 创建一个 VirtualHost + +在本教程中,我假设你购买了一个很酷的域名,你将它专门用于 URL 缩短器。例如,我的网站是 [funnelfiasco.com][5],所以我买了 [funnelfias.co][6] 用于我的 URL 缩短器(好吧,它不是很短,但它可以满足我的虚荣心)。如果你不将缩短器作为单独的域运行,请跳到下一部分。 + +第一步是设置将用于 URL 缩短器的 VirtualHost。有关 VirtualHosts 的更多信息,请参[ David Both 的文章][7]。这步只需要几行: +``` +    + +        ServerName funnelfias.co + +    + +``` + +### 创建 rewrite + +此服务使用 HTTPD 的重写引擎来重写 URL。如果你在上面的部分中创建了 VirtualHost,则下面的配置跳到你的 VirtualHost 部分。否则跳到服务器的 VirtualHost 或主 HTTPD 配置。 +``` +    RewriteEngine on + +    RewriteMap shortlinks txt:/data/web/shortlink/links.txt + +    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] + +``` + +第一行只是启用重写引擎。第二行在文本文件构建短链接的映射。上面的路径只是一个例子。你需要使用系统上使用有效路径(确保它可由运行 HTTPD 的用户帐户读取)。最后一行重写 URL。在此例中,它接受任何字符并在重写映射中查找它们。你可能希望重写时使用特定的字符串。例如,如果你希望所有缩短的链接都是 “slX”(其中 X 是数字),则将上面的 `(.+)` 替换为 `(sl\d+)`。 + +我在这里使用了临时 (HTTP 302) 重定向。这能让我稍后更新目标 URL。如果希望短链接始终指向同一目标,则可以使用永久 (HTTP 301) 重定向。用 `permanent` 替换第三行的 `temp`。 + +### 构建你的映射 + +编辑配置文件 “RewriteMap” 行中的指定文件。格式是空格分隔的键值存储。在每一行上放一个链接: +``` +    osdc https://opensource.com/users/bcotton + +    twitter https://twitter.com/funnelfiasco + +    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html + +``` + +### 重启 HTTPD + +最后一步是重启 HTTPD 进程。这是通过 `systemctl restart httpd` 或类似命令完成的(命令和守护进程名称可能因发行版而不同)。你的链接缩短器现已启动并运行。当你准备编辑映射时,无需重新启动 Web 服务器。你所要做的就是保存文件,Web 服务器将获取到差异。 + +### 未来的工作 + +此示例为你提供了基本的 URL 缩短器。如果你想将开发自己的管理接口作为学习项目,它可以作为一个很好的起点。或者你可以使用它分享容易记住的链接到那些容易忘记的 URL。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/apache-url-shortener + +作者:[Ben Cotton][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/bcotton +[1]:http://t.co +[2]:http://bit.ly/INtravel +[3]:https://opensource.com/article/17/3/url-link-shortener +[4]:https://opensource.com/article/18/2/how-configure-apache-web-server +[5]:http://funnelfiasco.com +[6]:http://funnelfias.co +[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache From 452a7fe4669302353e405e1ae70dce2001be53ee Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 19 Sep 2018 08:54:09 +0800 Subject: [PATCH 2/2] translated --- ...ouse Support For Linux Virtual Consoles.md | 126 ------------------ ...ouse Support For Linux Virtual Consoles.md | 124 +++++++++++++++++ 2 files changed, 124 insertions(+), 126 deletions(-) delete mode 100644 sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md create mode 100644 translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md diff --git a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md deleted file mode 100644 index 3a4412e5c1..0000000000 --- a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md +++ /dev/null @@ -1,126 +0,0 @@ -translating---geekpi - -How To Configure Mouse Support For Linux Virtual Consoles -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) - -I use Oracle VirtualBox to test various Unix-like operating systems. Most of my VMs are headless servers that does not have graphical desktop environment. For a long time, I have been wondering how can we use the mouse in the text-based terminals in headless Linux servers. Thanks to **GPM** , today I learned that we can use Mouse in virtual consoles for copy and paste operations. **GPM** , acronym for **G** eneral **P** urpose **M** ouse, is a daemon that helps you to configure mouse support for Linux virtual consoles. Please do not confuse GPM with **GDM** (GNOME Display manager). Both serves entirely different purpose. - -GPM is especially useful in the following scenarios: - - * New Linux server installations or for systems that cannot or do not use an X windows system by default, like Arch Linux and Gentoo. - * Use copy/paste operations around in the virtual terminals/consoles. - * Use copy/paste in text-based editors and browsers (Eg. emacs, lynx). - * Use copy/paste in text file managers (Eg. Ranger, Midnight commander). - - - -In this brief tutorial, we are going to see how to use Mouse in Text-based terminals in Unix-like operating systems. - -### Installing GPM - -To enable mouse support in Text-only Linux systems, install GPM package. It is available in the default repositories of most Linux distributions. - -On Arch Linux and its variants like Antergos, Manjaro Linux, run the following command to install GPM: - -``` -$ sudo pacman -S gpm -``` - -On Debian, Ubuntu, Linux Mint: - -``` -$ sudo apt install gpm -``` - -On Fedora: - -``` -$ sudo dnf install gpm -``` - -On openSUSE: - -``` -$ sudo zypper install gpm -``` - -Once installed, enable and start GPM service using the following commands: - -``` -$ sudo systemctl enable gpm -$ sudo systemctl start gpm -``` - -In Debian-based systems, gpm service will be automatically started after you installed it, so you need not to manually start the service as shown above. - -### Configure Mouse Support For Linux Virtual Consoles - -There is no special configuration required. GPM will start working as soon as you installed it and started gpm service. - -Have a look at the following screenshot of my Ubuntu 18.04 LTS server before installing GPM: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/Ubuntu-18.04-CLI.png) - -As you see in the above screenshot, there is no visible Mouse pointer in my Ubuntu 18.04 LTS headless server. Only a blinking cursor and it won’t let me to select a text, copy/paste text using mouse. In CLI-only Linux servers, the mouse is literally not useful at all. - -Now check the following screenshot of Ubuntu 18.04 LTS server after installing GPM: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM.png) - -See? I can now be able to select the text. - -To select, copy and paste text, do the following: - - * To select text, press the left mouse button and drag the mouse. - * Once you selected the text, release the left mouse button and paste text in the same or another console by pressing the middle mouse button. - * The right button is used to extend the selection, like in `xterm’. - * If you’re using two-button mouse, use the right button to paste text. - - - -It’s that simple! - -Like I already said, GPM works just fine and there is no extra configuration needed. Here is the sample contents of GPM configuration file **/etc/gpm.conf** (or `/etc/conf.d/gpm` in some distributions): - -``` -# protected from evaluation (i.e. by quoting them). -# -# This file is used by /etc/init.d/gpm and can be modified by -# "dpkg-reconfigure gpm" or by hand at your option. -# -device=/dev/input/mice -responsiveness= -repeat_type=none -type=exps2 -append='' -sample_rate= -``` - -In my example, I use USB mouse. If you’re using different mouse, you might have to change the values of **device=/dev/input/mice** and **type=exps2** parameters. - -For more details, refer man pages. - -``` -$ man gpm -``` - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ diff --git a/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md new file mode 100644 index 0000000000..a01ffa267c --- /dev/null +++ b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @@ -0,0 +1,124 @@ +如何为 Linux 虚拟控制台配置鼠标支持 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) + +我使用 Oracle VirtualBox 来测试各种类 Unix 操作系统。我的大多数虚拟机都是无头服务器,它们没有图形桌面环境。很长一段时间,我一直想知道如何在无头 Linux 服务器的基于文本的终端中使用鼠标。感谢 **GPM**,今天我了解到我们可以在虚拟控制台中使用鼠标进行复制和粘贴操作。 **GPM**,**G** eneral **P** urpose **M** ouse 的首字母缩写,它是一个守护程序,可以帮助你配置 Linux 虚拟控制台的鼠标支持。请不要将 GPM 与 **GDM**(GNOME 显示管理器)混淆。两者有完全不同的用途。 + +GPM 在以下场景中特别有用: + + * 新的 Linux 服务器安装或默认情况下不能或不使用 X Windows 的系统,如 Arch Linux 和 Gentoo。 + * 在虚拟终端/控制台中使用复制/粘贴操作。 + * 在基于文本的编辑器和浏览器中使用复制/粘贴(例如,emacs、lynx)。 + * 在文本文件管理器中使用复制/粘贴(例如 Ranger、Midnight commander)。 + + + +在这个简短的教程中,我们将看到如何在类 Unix 操作系统中在基于文本的终端中使用鼠标。 + +### 安装 GPM + +要在纯文本 Linux 系统中启用鼠标支持,请安装 GPM 包。它在大多数 Linux 发行版的默认仓库中都有。 + +在 Arch Linux 及其变体如 Antergos、Manjaro Linux 上,运行以下命令来安装 GPM: + +``` +$ sudo pacman -S gpm +``` + +在 Debian、Ubuntu、Linux Mint 中: + +``` +$ sudo apt install gpm +``` + +在 Fedora 上: + +``` +$ sudo dnf install gpm +``` + +在 openSUSE 上: + +``` +$ sudo zypper install gpm +``` + +安装后,使用以下命令启用并启动 GPM 服务: + +``` +$ sudo systemctl enable gpm +$ sudo systemctl start gpm +``` + +在基于 Debian 的系统中,gpm 服务将在你安装后自动启动,因此你无需如上所示手动启动服务。 + +### 为 Linux 虚拟控制台配置鼠标支持 + +无需特殊配置。GPM 将在你安装并启动 gpm 服务后立即开始工作。 + +在安装 GPM 之前,看下我的 Ubuntu 18.04 LTS 服务器的屏幕截图: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Ubuntu-18.04-CLI.png) + +正如你在上面的截图中看到的,我的 Ubuntu 18.04 LTS 无头服务器中没有可见的鼠标指针。只有一个闪烁的光标,它不能让我选择文本,使用鼠标复制/粘贴文本。在仅限 CLI 的 Linux 服务器中,鼠标根本没用。 + +在安装 GPM 后查看 Ubuntu 18.04 LTS 服务器的以下截图: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM.png) + +看见了吗?我现在可以选择文字了。 + +要选择,复制和粘贴文本,请执行以下操作: + + * 要选择文本,请按下鼠标左键并拖动鼠标。 + * 选择文本后,放开鼠标左键,并按下中键在同一个或另一个控制台中粘贴文本。 + * 右键用于扩展选择,就像在 `xterm` 中。 + * 如果你使用的是双键鼠标,请使用右键粘贴文本。 + + + +就这么简单! + +就像我已经说过的那样,GPM 工作得很好,并且不需要额外的配置。以下是 GPM 配置文件 **/etc/gpm.conf**(或在某些发行版中是 `/etc/conf.d/gpm`)的示例内容: + +``` +# protected from evaluation (i.e. by quoting them). +# +# This file is used by /etc/init.d/gpm and can be modified by +# "dpkg-reconfigure gpm" or by hand at your option. +# +device=/dev/input/mice +responsiveness= +repeat_type=none +type=exps2 +append='' +sample_rate= +``` + +在我的例子中,我使用 USB 鼠标。如果你使用的是其他鼠标,则可能需要更改 **device=/dev/input/mice** 和 **type=exps2** 参数的值。 + +有关更多详细信息,请参阅手册页。 + +``` +$ man gpm +``` + +就是这些了。希望这个有用。还有更多的好东西。敬请期待! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/