Orchard doesn't currently run on Mono, and hence can't run on Linux.
Orchard目前不在Mono上运行,因此无法在Linux上运行。
All command line examples in this article assume you are using a Linux machine.
本文中的所有命令行示例都假定您使用的是Linux计算机。
You can test the CMS using our virtual machine and/or Live CD SuSE Studio appliance.
您可以使用我们的[虚拟机和/或Live CD](http://susegallery.com/a/n1C2rA/orchard-cms-mono-demo)SuSE Studio设备测试CMS。
Prerequisites
先决条件
You will need the following software in order to run Orchard on your Linux distribution of choice:
您需要以下软件才能在您选择的Linux发行版上运行 b> Orchard:
-
PostgreSQL RDBMS version 8.2 or newer (8.4 recommended) installed, with rights to create databases
-
安装了PostgreSQL RDBMS 8.2或更高版本(推荐8.4),具有创建数据库的权限 *
-
Mono 2.10.1 or newer
-
[Mono 2.10.1](http://www.go-mono.com/mono-downloads/download.html)或更新版本 *
-
Apache 2 (optional, you can use Mono's XSP development server for testing)
-
Apache 2(可选,您可以使用[Mono](http://mono-project.com/)XSP开发服务器进行测试) *
-
A set of Linux utilities installed on your machine: wget, patch, unzip and sudo (for root access - you must have administrative/root rights on the machine)
-
您的计算机上安装了一组Linux实用程序:wget,patch,unzip和sudo(对于root访问权限 - 您必须具有该计算机的管理/ root权限) *
If you want to compile Orchard from source on Linux (compiling with VisualStudio is, of course, also supported), you will also need:
如果你想在Linux上从源代码编译Orchard(当然,也支持用VisualStudio编译),你还需要:
-
MonoDevelop 2.6 Beta 1 or newer
-
[MonoDevelop 2.6 Beta 1](http://monodevelop.com/Download)或更新版本 *
-
Mono versions of certain assemblies used by Orchard
-
[Orchard某些程序集的版本](http://dl.dropbox.com/u/22037511/orchard/orchard-mono-sources-overlay-current.zip)由Orchard使用 *
Common Setup Steps
常用设置步骤
Add a Host Name Alias for the Demo
为演示添加主机名别名
Since you are using a non-existing DNS name for this demo, you need to let the system know how to find the server. To do so, execute the following sequence of commands:
由于您在此演示中使用了不存在的DNS名称,因此您需要让系统知道如何查找服务器。为此,请执行以下命令序列:
sudo -i
echo "127.0.0.1 orchard-demo" >> /etc/hosts
If you want to visit the Orchard demo from another machine, you will need to modify the machine's /etc/hosts file in the similar way, replacing 127.0.0.1 with your server's IP address.
如果您想从另一台机器访问Orchard演示,则需要以类似的方式修改机器的 / etc / hosts tt>文件,将 127.0.0.1 tt>替换为您的服务器IP地址。
Database Setup
数据库设置
First, make sure you have PostgreSQL installed and running:
首先,确保已安装并运行PostgreSQL:
ps ax|grep postgres
Output of the command should be similar to:
命令输出应类似于:
1275 ? Ss 0:00 postgres: logger process
1277 ? Ss 0:00 postgres: writer process
1278 ? Ss 0:00 postgres: wal writer process
1279 ? Ss 0:00 postgres: autovacuum launcher process
1280 ? Ss 0:00 postgres: stats collector process
When PostgreSQL is running and ready, type the commands below to create the database and the user:
当PostgreSQL运行并准备就绪时,键入以下命令来创建数据库和用户:
sudo -i
su - postgres
createuser -l -D -R -S -P orchard
Type the password when prompted and then create the database (it will be named orchard):
在提示时键入密码,然后创建数据库(它将命名为 orchard b>):
createdb -E UTF8 -O orchard orchard
At this point you must make sure the new orchard user has access rights to the database. In order to do it, you need to find the pg_hba.conf file and open it in the editor (you must be doing that with administrator/root rights). The file is located in /var/lib/pgsql/data/ on SuSE and in /etc/postgresql/X.Y/main/ on distributions derived from Debian (X.Y is the major.minor version number of your PostgreSQL server). After the file is found and opened, make sure it contains a line similar to this:
此时,您必须确保新的 orchard b>用户具有对数据库的访问权限。为此,您需要找到 pg_hba.conf tt>文件并在编辑器中打开它(您必须使用管理员/ root权限执行此操作)。该文件位于SuSE上的 / var / lib / pgsql / data / tt>中,以及从Debian派生的分布中的 / etc / postgresql / XY / main / tt>(XY是major.minor PostgreSQL服务器的版本号)。找到并打开文件后,请确保它包含类似于以下内容的行:
host all all 127.0.0.1/32 md5
It is extremely important that the last item in the line above is not ident - it should be md5, password or trust (for other authentication methods please refer to the PostgreSQL documentation). After the line is in the file, restart PostgreSQL and you're ready to use the new database from Orchard.
非常 b>重要的是,上面一行中的最后一项是不 b> ident tt> - 它应该是 md5 tt>,< tt>密码 tt>或 trust tt>(有关其他身份验证方法,请参阅PostgreSQL文档)。该行在文件中后,重新启动PostgreSQL,您就可以使用Orchard中的新数据库了。
Configuring with Apache 2 and mod_mono
使用Apache 2和mod_mono进行配置
Make sure you have Apache 2 (the Worker MPM is recommended) and mod-mono 2.10.1 (or newer) installed. Configuration paths given below are specific to OpenSuSE 11.4, you will need to adjust them for your distribution. Contents of the created files does not change (save for the filesystem paths, of course).
确保安装了Apache 2(建议使用Worker MPM)和mod-mono 2.10.1(或更新版本)。下面给出的配置路径是OpenSuSE 11.4特有的,您需要根据您的分发进行调整。创建文件的内容不会更改(当然,除了文件系统路径外)。
Create Apache Virtual Host Configuration File
创建Apache虚拟主机配置文件
sudo -i
cd /etc/apache2/vhosts.d
At this point you will need a working text editor. You can try typing any of the following commands to launch one: gedit, mcedit, joe, vi. editor below is used as a placeholder:
此时,您将需要一个有效的文本编辑器。您可以尝试键入以下任何命令来启动一个:gedit,mcedit,joe,vi。下面的编辑器 tt>用作占位符:
editor /etc/apache2/vhosts.d/orchard-demo.conf
One of them should result in the editor starting. If you don't know how to use the started editor, refer to its online help. After the editor is started, paste the following code in it:
其中一个应该导致编辑器启动。如果您不知道如何使用已启动的编辑器,请参阅其在线帮助。编辑器启动后,将以下代码粘贴到其中:
<VirtualHost *:80>
ServerAdmin webmaster@orchard-demo
ServerName orchard-demo
# Change the path below to suit your configuration
DocumentRoot /srv/www/vhosts/orchard-demo
# The paths used here should be common for all Linux distributions
ErrorLog /var/log/apache2/orchard-demo_error.log
CustomLog /var/log/apache2/orchard-demo_access.log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
# Make ABSOLUTELY sure that the path in double quotes ends with a slash!
Alias / "/srv/www/vhosts/orchard-demo/"
AddMonoApplications OrchardDemo "/:/srv/www/vhosts/orchard-demo"
# Orchard is a .NET 4.0 application. If your Mono was installed in a different prefix, replace /usr/bin/ with that prefix below.
MonoServerPath OrchardDemo /usr/bin/mod-mono-server4
# Helps when you get stack traces
MonoDebug OrchardDemo True
# Orchard assumes a case-insensitive filesystem
MonoIOMAP OrchardDemo all
<Directory "/srv/www/vhosts/orchard-demo">
SetHandler mono
MonoSetServerAlias OrchardDemo
</Directory>
</VirtualHost>
Save the file, close the editor and type one the following commands to restart Apache (use only one of those):
保存文件,关闭编辑器并键入以下命令以重新启动Apache(仅使用其中一个):
service apache2 restart
/etc/init.d/apache2 restart
To make sure Mono backend has been started correctly, type:
要确保已正确启动Mono后端,请键入:
ps ax|grep OrchardDemo
As the result you should see output similar to:
结果你应该看到类似于的输出:
2252 ? Ssl 0:00 /usr/bin/mono --debug /usr/lib/mono/4.0/mod-mono-server4.exe --filename /tmp/mod_mono_server_OrchardDemo --applications /:/srv/www/vhosts/orchard-demo --nonstop
Now you are ready to start your favorite web browser and point it to http://orchard-demo/!
现在您已准备好启动您喜欢的Web浏览器并将其指向 http:// orchard-demo / tt>!
Configuring for XSP
配置XSP
No extra steps are necessary. You need to run xsp4 in the Orchard.Web directory using the following command line:
无需额外的步骤。您需要使用以下命令行在 Orchard.Web tt>目录中运行 xsp4 tt>:
MONO_IOMAP=all xsp4
Using Binary Version of Orchard
使用二进制版本的Orchard
Currently Orchard needs to be patched in order to run on Mono with PostgreSQL database, so for your convenience a precompiled version is available. All you need to do is to download the archive, create a directory on your server in which you want to put the application and unzip the archive in that directory (locations used here are samples which would work without changing on a machine running OpenSuSE 11.4):
目前Orchard需要修补才能在带有PostgreSQL数据库的Mono上运行,所以为方便起见[预编译版本](http://dl.dropbox.com/u/22037511/orchard/orchard-1.0.20- mono_bin.zip)。您需要做的就是下载存档,在您要放置应用程序的服务器上创建一个目录,并将存档解压缩到该目录中(这里使用的位置是可以在不更改运行的机器上运行的样本[OpenSuSE 11.4] ](http://software.opensuse.org)):
sudo -i
mkdir -p /srv/www/vhosts/orchard-demo
cd /tmp
wget http://dl.dropbox.com/u/22037511/orchard/orchard-1.0.20-mono_bin.zip
cd /srv/www/vhosts/orchard-demo
unzip /tmp/orchard-1.0.20-mono_bin.zip
Compiling Orchard from Source
从Source编译Orchard
We will use the current (as of March 11 2011) version of Orchard sources - 1.0.20. After downloading and unzipping them in a directory of your choice, you need to perform the steps outlined below in before compiling the application.
我们将使用当前(截至2011年3月11日)版本的Orchard来源 - [1.0.20](http://orchard.codeplex.com/releases/view/50197#DownloadId=197217)。在您选择的目录中下载并解压缩后,您需要在编译应用程序之前执行下面列出的步骤。
Patching the Source
修补源代码
Ideally, in the future Orchard will not need to be patched in order to work under Mono, but for the moment you need to download two little patches and apply them to the source. Unzip the archive in the directory where you unpacked the Orchard sources and issue the following commands:
理想情况下,将来Orchard不需要修补以便在Mono下工作,但目前你需要[下载两个小补丁](http://dl.dropbox.com/u/22037511/orchard/orchard -mono-patches-current.zip)并将它们应用于源代码。将存档解压缩到解压缩Orchard源的目录中,并发出以下命令:
patch -p1 < 01.\ orchard-1.0-mono-support.patch
patch -p1 < 02.\ orchard-1.0-postgresql-support.patch
And Orchard is patched!
而乌节是修补的!
Overlaying Mono Versions of Some Assemblies
覆盖某些装配体的单声道版本
Orchard comes with a host of assemblies it depends upon both during compilation and the execution. Two of those assemblies (Microsoft.Web.Infrastructure.dll and NHibernate.dll) have to be replaced because the versions shipped with Orchard will work only in the Microsoft .NET environment. The assemblies can be found in this archive which has to be unzipped in the directory where you unpacked your Orchard sources.
Orchard附带了一系列程序集,它们在编译和执行期间都依赖于它们。必须更换其中两个程序集( Microsoft.Web.Infrastructure.dll tt>和 NHibernate.dll tt>),因为Orchard附带的版本仅适用于Microsoft .NET环境。程序集可以在[此存档](http://dl.dropbox.com/u/22037511/orchard/orchard-mono-sources-overlay-current.zip)中找到,必须在解压缩的目录中解压缩你的果园来源。
Compiling
编译
You must use MonoDevelop 2.6 or newer to compile on Orchard on Linux (you can also use VisualStudio after performing the steps above) since its earlier versions had a bug which would require you to edit assembly references in all of the Orchard projects. Compilation using Mono's xbuild is also currently not possible because of missing features (but we're working on it and soon you should be able to compile Orchard from command line).
你必须 b>使用MonoDevelop 2.6或更新版本在Linux上的Orchard上编译(你也可以在执行上述步骤后使用VisualStudio),因为它的早期版本有一个错误,需要你编辑所有的程序集引用果园项目。使用Mono的xbuild进行编译目前也不可能,因为缺少功能(但我们正在努力,很快您就可以从命令行编译Orchard)。
You must make absolutely sure that the full Mono 2.10.1 (or newer) stack is installed - all of the development files, assemblies, compilers have to be present on your system.
您必须确保已安装完整的Mono 2.10.1(或更新版本)堆栈 - 所有开发文件,程序集和编译器都必须存在于您的系统上。
After opening the solution in MonoDevelop just type F8 (or use the Build -> Build All menu option) and after a while you should have Orchard compiled and ready to run.
在MonoDevelop中打开解决方案后,只需键入 F8 tt>(或使用 Build - > Build All tt>菜单选项),过一会儿就应该编译Orchard并准备运行。
Deploying
部署
Unfortunately at the time of this writing MonoDevelop will not deploy Orchard properly, so you need to do it manually. To do so, copy contents of the src/Orchard.Web/ directory to your website root. If you want to remove the source and binary files which aren't necessary for the CMS to run, please consult the binary release of Orchard and use it as a template of what has to remain and what can be removed safely.
不幸的是,在撰写本文时,MonoDevelop将无法正确部署Orchard,因此您需要手动完成。为此,请将 src / Orchard.Web / tt>目录的内容复制到您的网站根目录。如果要删除CMS不需要的源文件和二进制文件,请参阅[Orchard的二进制版本](http://orchard.codeplex.com/releases/view/50197#DownloadId=197216并使用它作为必须保留的内容和可以安全删除的内容的模板。
Resources
资源
SuSE Studio Appliance with Orchard and Mono
SuSE Studio设备与Orchard和Mono
We have prepared a virtual machine and a Live CD based on OpenSuSE 11.4 with Orchard 1.0.20 and Mono 2.10.1 preinstalled so that you can test the CMS without having to go through any of the steps above.
我们准备了基于OpenSuSE 11.4的[虚拟机和Live CD](http://susegallery.com/a/n1C2rA/orchard-cms-mono-demo),预装了Orchard 1.0.20和Mono 2.10.1,以便您无需执行上述任何步骤即可测试CMS。
The Virtual Machine can be loaded both in Virtual Box (recommended, tested with version 4.0.4) and VMware.
可以在Virtual Box(推荐,使用4.0.4版测试)和VMware中加载虚拟机。
After starting the VM/Live CD, type http://orchard-demo/ in the browser (FireFox will auto-start) and watch it work!
启动VM / Live CD后,在浏览器中键入 http:// orchard-demo / tt>(FireFox将自动启动)并观察它是否正常工作!
The first time you browse the above URL you will be greeted with Orchard setup screen and prompted for database connection string. You need to use the following:
第一次浏览上面的URL时,您将看到Orchard设置屏幕,并提示您输入数据库连接字符串。您需要使用以下内容:
Server=localhost;Database=orchard;User ID=orchard;Password=orchard
Known Issues
已知的问题
-
Orchard requires Mono IOMAP to be active since there are a few files and directories that use inconsistent name case.
-
Orchard要求[Mono IOMAP](http://mono-project.com/IOMap)处于活动状态,因为有一些文件和目录使用不一致的名称大小写。 *
-
After a few requests you might get npgsql (PostgreSQL ADO.NET provider) connection errors. Only restarting the application will cure it.
-
在几个请求之后,您可能会遇到 npgsql tt>(PostgreSQL ADO.NET提供程序)连接错误。只有重新启动应用程序才能解决问题。 *