translated wi-cuckoo

This commit is contained in:
wi-cuckoo 2015-04-27 11:27:44 +08:00
parent d1de6b25bb
commit 957ecbc7a9
2 changed files with 156 additions and 161 deletions

View File

@ -1,161 +0,0 @@
translating wi-cuckoo
How to Install Discourse in a Docker Container
================================================================================
Hi all, today we'll learn how to install Discourse using Docker Platform. Discourse is the 100% open source discussion platform built for the next decade of the Internet featuring as a mailing list, a discussion forum and a long-form chat room. It is a smart way of attempt to reimagine what a modern, sustainable, fully open-source Internet discussion platform should be today, both from a technology standpoint and a sociology standpoint. Discourse is simple, clean, and straightforward way for discussion. It is really an awesome platform for any kinds of discussions on internet featuring such a cool services out of the box. Docker is an open source platform that provides an open platform to pack, ship and run any application as a lightweight container. Docker containers makes Discourse a lot handy and easy to setup app.
So, here are some quick and easy steps in order to install Discourse inside a Docker environment.
### 1. Installing Docker ###
First of all, we need to make sure that we have Docker installed in our host Operating System. To install, we'll need to the run the following command in a shell or terminal.
#### On Ubuntu ####
Package docker is available in Ubuntu's repository so, we'll be using apt manager to install it in sudo or root mode.
# apt-get install docker
#### On CentOS 7 ####
On CentOS 7 machine, we'll use yum manager to install docker as it is also available in CentOS's repository.
# yum install docker
![Installing Docker](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-docker.png)
### 2. Setting Swap Memory ###
If you have RAM size less than 1 GB then, make sure you upgrade your system to 1 GB or above cause Discourse doesn't get installed in 512 MB RAM. If you are now ready to install Discourse with 1 GB or above, follow the following steps to setup swap memory for you VPS or Server.
We'll create an empty swapfile by running the following command.
# install -o root -g root -m 0600 /dev/null /swapfile
If you want your swap memory to be 1 GB, then do the below step and skip the next step.
# dd if=/dev/zero of=/swapfile bs=1k count=1024k
if you want it to be 2 GB, follow the below. Make sure you skip the above step.
# dd if=/dev/zero of=/swapfile bs=1k count=2048k
Then, we'll point Swap Memory as swapfile .
#mkswap /swapfile
To activate it run the following command.
#swapon /swapfile
Now, we'll add it to the file system table so its there after reboot:
# echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
Set the swappiness to 10 so its only uses as an emergency buffer.
# sudo sysctl -w vm.swappiness=10
# echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
### 3. Installing Discourse ###
After installing Docker in our host machine, we'll now go further towards installing Discourse. We'll now clone Discourse from the official Discourse Github into /var/discourse directory. To do so, we'll need to run the following command.
# mkdir /var/discourse/
# cd /var/discourse/
# git clone https://github.com/discourse/discourse_docker.git /var/discourse/
After cloning the git repository, we'll copy the configuration file for our discourse server.
# cp samples/standalone.yml containers/app.yml
![Cloning Discourse Docker](http://blog.linoxide.com/wp-content/uploads/2015/04/cloning-discourse-docker.png)
### 4. Configuring Discourse ###
Next, we'll edit the discourse configuration ie app.yml located inside containers directory using our favorite text editor.
# nano containers/app.yml
Now, we need to set the developer's email address to DISCOURSE_DEVELOPER_EMAILS as follows.
DISCOURSE_DEVELOPER_EMAILS: 'arun@linoxide.com'
Then, we'll set the hostname as the domain name of our server.
DISCOURSE_HOSTNAME: 'discourse.linoxide.com'
Then, set the mail credentials per our SMTP Server hosted in the same discourse machine or vps. The SMTP settings are required to send mail from your Discourse instance
DISCOURSE_SMTP_ADDRESS: smtp.linoxide.com
DISCOURSE_SMTP_PORT: 587 # (optional)
DISCOURSE_SMTP_USER_NAME: admin@linoxide.com # (optional)
DISCOURSE_SMTP_PASSWORD: test123 # (optional)
![](http://blog.linoxide.com/wp-content/uploads/2015/04/discourse-configuration.png)
Discourse Configuration
If you are using a 1 GB instance, set UNICORN_WORKERS to 2 and db_shared_buffers to 128MB so you have more memory room.
It is compulsory to create a mailing server to run Discourse. If you have a server then its cool, we can use its credentials. If you have no existing mail server, or you don't know what it is? No problem, create a free account on [Mandrill][1] ([Mailgun][2], or [Mailjet][3]), and use the credentials provided in the dashboard.
### 5. Starting Discourse App ###
After configuring the discourse configuration file, we'll surely wanna start our Discourse server. To do so, first we'll launch discourse bootstrap by running the following command under the current directory ie /var/discourse/ .
# ./launcher bootstrap app
![Starting Discourse Bootstrap](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse-bootstrap.png)
The above command may take some minutes which automatically configures our Discourse environment. Then, after the processes are finished, we'll need to run the following to start our Discourse App.
#./launcher start app
![Starting Discourse](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse.png)
If everything went as expected accordingly, we'll be able to access our fresh Discourse Web Interface using our favorite Web Browser by pointing the url to http://ip-address/ or http://discourse.linoxide.com/ . Then, we can create a new account and become admin.
![Discourse Web interface](http://blog.linoxide.com/wp-content/uploads/2015/04/Discourse-web-interface.png)
### Maintenance ###
Here below are the usages of the launcher command inside /var/discourse/ directory so that we can commit maintenance and control over the Discourse Docker Container.
Usage: launcher COMMAND CONFIG [--skip-prereqs]
Commands:
start: Start/initialize a container
stop: Stop a running container
restart: Restart a container
destroy: Stop and remove a container
enter: Use nsenter to enter a container
ssh: Start a bash shell in a running container
logs: Docker logs for container
mailtest: Test the mail settings in a container
bootstrap: Bootstrap a container for the config based on a template
rebuild: Rebuild a container (destroy old, bootstrap, start new)
cleanup: Remove all containers that have stopped for > 24 hours
Options:
--skip-prereqs Don't check prerequisites
--docker-args Extra arguments to pass when running docker
### Conclusion ###
Hurray! We have successfully installed Discourse with Docker Technology. Docker technology makes Discourse very much easy to install in any Platform with all the requirement fulfilled. We need our own mailing server or credentials of a mailing server to get started with it. It is a great platform for easy modern mailing list, discussion platform.
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/install-discourse-docker-container/
作者:[Arun Pyasi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/arunp/
[1]:https://mandrillapp.com/
[2]:http://www.mailgun.com/
[3]:https://www.mailjet.com/pricing

View File

@ -0,0 +1,156 @@
如何在一个Docker容器里安装Discourse
=============================================================================
大家好今天我们将会学习如何利用Docker平台安装Discourse。Discourse是完全开源的讨论平台为互联网的下一个十年而搭建拥有一个邮件列表一个论坛和一个long-form(此处不明白聊天室。不管从技术角度还是社会学角度当你试图去重新想象当今一个现代的可持续的完全开源的互联网讨论平台该是什么样子Discourse都是一个不错的途径。Discourse简洁直接之于讨论。它确实是一个令人称赞的平台对于互联网上各种各样的讨论来说提供了在机器之外如此酷的一个服务。Docker是一个开源平台提供打包运输和运行任何应用的平台如一个轻量级容器。Docker容器技术使得Discourse更加方便和容易去建立应用程序。
所以下面是一些快速且容易的步骤用来安装Discourse在一个Docker环境里面。
### 1. 安装Docker ###
首先我们需要确认我们的主机操作系统已经安装了Docker。我们需要在shell或者终端运行以下命令安装Docker。
#### 在Ubuntu上 ####
docker安装包在Ubuntu的仓库里面是可用的所以我们将会使用apt管理器安装以sudo或者root模式
# apt-get docker
#### 在CentOS 7上 ####
在CentOS 7的主机上我们使用yum管理器安装docker,因为CentOS的仓库里同样有docker安装包
# yum install docker
![Installing Docker](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-docker.png)
### 2. 设定交换内存 ###
如果你的RAM容量小于1GB那么确保升级你的系统达到1GB或者以上否则Discourse不会在512MB的RAM下安装。如果你现在准备好了安装Discourse根据下面的步骤为你的VPSVirtual Private Servers或者服务器设定交换内存
运行下面的命令,创建一个空的交换文件。
# install -o root -g root -m 0600 /dev/null /swapfile
如果你想你的交换内存达到1GB那么执行下面的步骤并且跳过接下来的第二步。
# dd if=/dev/zero of=/swapfile bs=1k count=1024k
如果你想达到2GB跳过上面的所有步骤跟着下面做
# dd if=/dev/zero of=/swapfile bs=1k count=2014k
接着我们指定交换内存为swapfile
#mkswap /swapfile
运行下面的命令激活交换内存
#swapon /swapfile
现在,我们将其添加到文件系统分区表里,这样重启之后就自动挂载了。
# echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
设置swappiness为10这样交换内存仅作为一个紧急缓冲区用。
# sudo sysctl -w vm.swappiness=10
# echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
### 3. 安装Discourse ###
在我们的主机上安装Docker后我们将会安装Discourse。现在我们从官方的Discourse GitHub仓库克隆一份到/var/discourse目录下。我们需要运行下面的命令完成这一步。
# mkdir /var/discourse/
# cd /var/discourse/
# git clone https://github.com/discourse/discourse_docker.git /var/discourse/
克隆好仓库后我们会为discourse服务器复制配置文件
# cp samples/standalone.yml containers/app.yml
![Cloning Discourse Docker](http://blog.linoxide.com/wp-content/uploads/2015/04/cloning-discourse-docker.png)
### 4. 配置Discourse ###
接下来我们用自己喜欢的文本编辑器编辑容器目录下的discourse配置文件app.yml
# nano containers/app.yml
现在我们需要设置开发者的邮箱地址为DISCOURSE_DEVELOPER_EMAILS如下。
DISCOURSE_DEVELOPER_EMAILS: 'arun@linoxide.com'
然后,我们会设置主机名为服务器的域名。
DISCOURSE_HOSTNAME: 'discourse.linoxide.com'
接着为每个托管在相同discourse主机或者vps上的SMTP服务器设定邮箱证书。SMTP设置需要从你的Discourse发送邮件
DISCOURSE_SMTP_ADDRESS: smtp.linoxide.com
DISCOURSE_SMTP_PORT: 587 # (optional)
DISCOURSE_SMTP_USER_NAME: admin@linoxide.com # (optional)
DISCOURSE_SMTP_PASSWORD: test123 # (optional)
![](http://blog.linoxide.com/wp-content/uploads/2015/04/discourse-configuration.png)
Discourse 配置
如果你在使用一个1GB的Discourse设定UNICORN_WORKERS为2db_shared_buffers为128MB这样你会有更多的内存空间。
运行Discourse需要强制性地创建一个邮件服务器。如果你已经有一个服务器了那就好办多了我们可以使用它的证书。如果你没有现成的邮件服务器或者你不知道那是什么。没关系创建一个免费的帐号在[Mandrill][1] ([Mailgun][2],或者[Mailjet][3]),然后使用面板上提供的证书。
### 5. 启动Discourse应用 ###
配置完discourse的配置文件后我们当然是想启动Discourse服务器。首先在/var/discourse/目录下运行下面的命令加载discourse引导程序。
# ./launcher bootstrap app
![Starting Discourse Bootstrap](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse-bootstrap.png)
上述命令可能会花去几分钟时间会自动配置我们的Discourse环境。然后该进程完成后我们需要运行下面的命令启动Discourse App
#./launch start app
![Starting Discourse](http://blog.linoxide.com/wp-content/uploads/2015/04/starting-discourse.png)
### 维护 ###
这里往下是/var/discourse/目录里加载命令的使用这使得我们可以承担维护的任务通过Docker 容器控制Disourse。这里不太明白原文表达意思
Usage: launcher COMMAND CONFIG [--skip-prereqs]
Commands:
start: Start/initialize a container
stop: Stop a running container
restart: Restart a container
destroy: Stop and remove a container
enter: Use nsenter to enter a container
ssh: Start a bash shell in a running container
logs: Docker logs for container
mailtest: Test the mail settings in a container
bootstrap: Bootstrap a container for the config based on a template
rebuild: Rebuild a container (destroy old, bootstrap, start new)
cleanup: Remove all containers that have stopped for > 24 hours
Options:
--skip-prereqs Don't check prerequisites
--docker-args Extra arguments to pass when running docker
### 总结 ###
Hurray我们已经成功使用Docker技术安装了Discourse。Docker技术使得Discourse十分容易安装在任何平台并且包含所有的要求。我们需要自己的邮件服务器或者邮件服务器的证书来启动它。对于便捷的现代邮件列表论坛来说Discourse是一个伟大的平台。最后这句有些别扭
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/install-discourse-docker-container/
作者:[Arun Pyasi][a]
译者:[wi-cuckoo](https://github.com/wi-cuckoo)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/arunp/
[1]:https://mandrillapp.com/
[2]:http://www.mailgun.com/
[3]:https://www.mailjet.com/pricing