在站点目录中创建符号链接 [英] Creating a symbolic link in Sites directory

查看:37
本文介绍了在站点目录中创建符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 ~/Sites 目录中有一个文件,当我通过 coderama.local/~coderama/index2.php

I have a file in my ~/Sites directory that works fine when I browse to it through coderama.local/~coderama/index2.php

现在我想变得棘手并将我的 index2.php 文件移动到我系统上的其他地方,所以我通过创建一个符号链接来做到这一点.但是,当我尝试访问 coderama.local/~coderama/index2.php 时,我现在收到以下错误.

Now I want to get tricky and move my index2.php file to somewhere else on my system, so I do this by creating a symbolic link. However, when I try to access coderama.local/~coderama/index2.php I now get the following error.

大家有什么想法吗?

谢谢!

您无权访问此服务器上的/~coderama/index2.php.

Forbidden

You don't have permission to access /~coderama/index2.php on this server.

推荐答案

这是一个可配置的 Apache 选项.似乎默认情况下,在 Mac 上(可能还有大多数安装)Apache 被配置为不遵循符号链接.我猜(正如上面其他人提到的)这是出于安全目的.

That's a configurable Apache option. It appears that by default on Macs (and probably most installations) Apache is configured to not follow symbolic links. I'm guessing (as others mention above) that it's for security purposes.

但有时启用符号链接跟踪确实很方便,尤其是在开发某些类型的应用程序期间.您需要做的是 1) 更改 Apache 配置以允许以下符号链接,然后 2) 重新启动 Apache.

But it can be really convenient at times to enable following of symbolic links, particularly during development of certain kinds of apps. What you need to do is 1) change the Apache configuration to allow the following of symbolic links, and then 2) restart Apache.

配置步骤如下:

a) cd/etc/apache2(这是 Apache 的配置文件在 Mac 上的默认位置)

a) cd /etc/apache2 (this is where Apache's configuration files are by default on a Mac)

b) 您会在这里看到几个目录.一种叫做用户

b) you'll see a couple of directories here. One is called users

c) cd 用户

d) ls 应该显示一个 .conf 文件,其中包含您的登录名 (login.conf) 我是marvo",所以我的名为marvo.conf"

d) ls should reveal a .conf file with your login name (login.conf) I'm "marvo" so mine is named "marvo.conf"

e) 编辑此文件(我使用 vi)——但您必须使用 sudo 来完成:

e) Edit this file (I use vi) -- but you have to do it using sudo:

sudo vi marvo.conf

f) 你会看到类似

<Directory "/Users/marvo/Sites/">
    Options Indexes MultiViews 
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

g) 添加FollowSymLinks"选项,使该 .conf 文件的第二行看起来像:

g) Add the "FollowSymLinks" option so that the second line of that .conf file looks like:

Options Indexes MultiViews FollowSymLinks

(你可以在网上找到其他配置选项.我找到了这个页面:http://httpd.apache.org/docs/2.0/mod/core.html#directory)

(You can find other configuration options out there on the 'net. I found this page: http://httpd.apache.org/docs/2.0/mod/core.html#directory )

h) 保存文件.

现在您必须重新启动 Apache,以便它接受配置更改.谷歌搜索了一下,我发现这最容易从命令行使用以下命令完成:

Now you have to restart Apache so that it picks up the configuration change. Googling around a bit, I found that this is most easily done from the command line with the following command:

sudo /usr/sbin/apachectl restart

(在 http://mcapewell.wordpress.com/2006/09/22/restart-apache-in-mac-os-x/ )

现在符号链接应该可以在您的站点页面上正常工作.

Now that symbolic link should work just fine on your Sites pages.

这篇关于在站点目录中创建符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆