运行 WHM 时如何以正确的方式添加虚拟主机?

发布于 2024-11-27 11:05:36 字数 594 浏览 1 评论 0原文

我正在运行一台专用服务器,为我的客户使用 WHM 和 CentOS 5 分隔帐户。我的一个客户要求我安装 subversion,并将存储库存储在 webroot 下。

  • 存储库的真实文件夹将位于“/home/theirfolder/svn”中,
  • 存储库将通过“svn.theirdomain.com”上的子域访问

我知道执行此操作的常规方法是在 Apache 中设置一个虚拟主机来处理重定向。问题是 WHM 似乎超越了整个虚拟主机过程,迫使我将更改烘焙到似乎对我不起作用的外部文件中。当保留 webroot 下的文件夹时,我根本无法让虚拟主机识别该文件夹的路径。

我得到的最接近的结果是将 subversion 文件夹移动到 webroot 上,但即使如此,我使用身份验证的说明也没有得到遵循,所以从安全角度来看,这不是一个好的解决方案。在此设置中,页面似乎是由 Apache 而不是由 Subversion 生成的。

这里的任何人都可以为我指明可以指导我完成此类设置的教程的方向,或者为我提供关于我需要做什么的清晰的分步指南吗?我尝试了很多事情,但没有什么能真正让我到达那里。我已经正确下载并安装了 Subversion 及其所有依赖项。

提前致谢!

I'm running a dedicated server separating accounts for my clients with WHM and CentOS 5. One of my clients has asked me to install subversion, and have the repository stored beneath the webroot.

  • repo's true folder will be in "/home/theirfolder/svn"
  • repo will be accessed through a subdomain on "svn.theirdomain.com"

I know that the regular way to do this is to set up a virtual host in Apache that handles the redirect. The problem is that WHM seems to overtake the whole virtual hosting process, forcing me to bake changes into external files that don't even seem to work for me. When retaining the folder beneath the webroot, I could not get virtual hosting to recognize the path to this folder at all.

The closest I've gotten was instead moving the subversion folder onto the webroot, but even then, my instructions for using Authentication are not followed, so that's not a good solution, security-wise. It also appeared that in this setting pages were being generated by Apache and not by Subversion.

Can anyone here point me in the direction of a tutorial that can guide me through this type of setup, or give me a clear, step-by-step guide on what I need to do? I've tried a lot of things but nothing has really gotten me there. I already have Subversion and all of its dependencies downloaded and installed correctly.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凯凯我们等你回来 2024-12-04 11:05:36

实现此目的的一种方法是使用 之一WHM 的自定义包含文件,并以“常规方式”在其中添加自定义 指令。在这些文件中所做的更改将在 WHM 自动重建 Apache 配置文件时保留下来,而直接对 /etc/httpd/conf/httpd.conf 进行的任何更改可能不会。

主 httpd.conf 在不同点包含三个自定义包含文件。这些文件(如果运行 Apache 2.x)位于:

  • /usr/local/apache/conf/includes/pre_virtualhost_2.conf,包含在自动生成的 指令
  • /usr/local/apache/conf/includes/post_virtualhost_2.conf,包含在自动生成的之后指令
  • /usr/local/apache/conf/includes/pre_main_2.conf,包含在 httpd.conf 的顶部

您可以直接编辑这些文件,或通过 WHM 管理面板(服务配置 -> Apache 配置,包括编辑器,在 WHM 11.30 上)。

当 WHM/cpanel 无法通过其他配置方法执行我想要的操作时,我使用 post_virtualhost_2.conf 为客户帐户设置额外的虚拟主机。任何有效的 Apache 配置指令都可以放入该文件中 - 它只是完整地包含在主 httpd.conf 中。

One way to accomplish this is to use one of WHM's custom include files, and add your custom <virtualhost> directives there the "regular way". Changes made in these files will survive an automatic rebuild of the Apache configuration files by WHM, while any changes made directly to /etc/httpd/conf/httpd.conf might not.

There are three custom include files that are included by the main httpd.conf at different points. These files (if running Apache 2.x) are located at:

  • /usr/local/apache/conf/includes/pre_virtualhost_2.conf, included before the automatically generated <virtualhost> directives
  • /usr/local/apache/conf/includes/post_virtualhost_2.conf, included after the automatically generated <virtualhost> directives
  • /usr/local/apache/conf/includes/pre_main_2.conf, included at the top of httpd.conf

You can edit these files directly, or via the WHM admin panel (Service Configuration -> Apache Configuration, Include Editor, on WHM 11.30).

I've used post_virtualhost_2.conf to setup additional vhosts for client accounts when WHM/cpanel won't do what I want it to via other configuration methods. Any valid Apache configuration directives can go in the file - it's simply included in its entirety in the main httpd.conf.

可可 2024-12-04 11:05:36

上述说明并不是您针对每个帐户使用的说明。放置在 apache include 中的任何内容都是服务器范围的。
您可能希望使用 apache include 来包含 mod dav 和 mod authz 共享对象。您可能已经设置好了,但为了以防万一,这里有说明。
在 WHM 中,转到服务配置 -> Apache 配置 -> 包含编辑器
将其放置在 Pre Main Include 中:

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

接下来,您要创建一个 .conf 文件并将其放置在

/usr/local/apache/conf/userdata/std/2/<user account name>/svn.conf

如果您想要 SSL 中,请执行相同操作

/usr/local/apache/conf/userdata/ssl/2/<user account name>/svn.conf

如果上面的目录尚不存在,那么您将需要创建它们。

文件将包含:

<IfModule mod_dav_svn.c>
<Location /svn>
DAV svn
SVNPath /home/<user account>/svn
AuthType Basic
AuthName "My Repo"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
</IfModule> 

用户名和密码可以设置为:

htpasswd -cm /etc/svn-auth-conf myusername

然后提交文件更改执行:

/scripts/ensure_vhost_includes --user=<user account>
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd

您应该能够浏览

yourdomain.com/svn 

并从中提取

/home/<user account>/svn

The instructions above are not what you would use on a per account basis. Anything placed in the apache includes are server wide.
You would want to use the apache includes to include the mod dav and mod authz shared object. You probably already have it set but here are instructions just in case.
In WHM go to Service Configuration->Apache Configuration->Include Editor
Place this in the Pre Main Include:

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Next you want to make a .conf file and place it in

/usr/local/apache/conf/userdata/std/2/<user account name>/svn.conf

If you want SSL do the same in

/usr/local/apache/conf/userdata/ssl/2/<user account name>/svn.conf

If the directories above are not already present then you will need to create them.

file would contain:

<IfModule mod_dav_svn.c>
<Location /svn>
DAV svn
SVNPath /home/<user account>/svn
AuthType Basic
AuthName "My Repo"
AuthUserFile /etc/svn-auth-conf
Require valid-user
</Location>
</IfModule> 

Username and password can be set with:

htpasswd -cm /etc/svn-auth-conf myusername

Then to commit file changes execute:

/scripts/ensure_vhost_includes --user=<user account>
/scripts/rebuildhttpdconf
/scripts/restartsrv_httpd

You should be able to browse to

yourdomain.com/svn 

and it will be pulling from

/home/<user account>/svn
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文