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

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

问题描述

我在文件〜/网站目录时,我通过 coderama.local /〜$浏览到它工作正常C $ crama / index2.php

现在我想要得到棘手和移动我的 index2.php 文件到我的系统上别的地方,所以我通过创建符号链接做到这一点。然而,当我尝试访问 coderama.local /〜coderama / index2.php 我现在碰到下面的错误。

任何想法吗?

谢谢!


  

禁止


  
  

您没有权限访问此服务器上/~$c$crama/index2.php。



解决方案

这是一个可配置的Apache选项。看来,在默认情况下在Mac上(可能大多数安装)的Apache配置为不遵循符号链接。我猜(如其他上述提及),这是出于安全的目的。

但它可以很方便的时间,使符号链接的下面,特别是在某些类型的应用程序的开发。你需要做的是1)修改Apache的配置,以允许符号链接的下面,然后2)重新启动Apache。

的配置步骤如下进行:

A)CD的/ etc / Apache2的(这是Apache的配置文件默认情况下在Mac上)

b)你会看到一对夫妇的目录在这里。一个被称为用户

C)CD的用户

D)LS应揭示.conf文件与登录名(登录的.conf文件)我是marvo,因此矿被命名为marvo.conf

E)编辑此文件(我用vi) - 但你必须做使用sudo是:

 须藤六marvo.conf

f)你会看到类似

 <目录/用户/ marvo /网站/>
    选择多视图索引
    设置AllowOverride无
    为了允许,拒绝
    所有允许
< /目录>

G)添加了FollowSymLinks选项,以便该.conf文件的第二行是这样的:

 选项指标多视图的FollowSymLinks

(您可以在网上找到其他的配置选项,在那里我找到了这个网页:<一href=\"http://httpd.apache.org/docs/2.0/mod/core.html#directory\">http://httpd.apache.org/docs/2.0/mod/core.html#directory )

高)保存文件。

现在,你必须重新启动Apache,以便它拿起配置更改。逛了一下谷歌搜索,我发现,这是最容易通过命令行完成使用下面的命令:

  sudo的/ usr / sbin目录/ apachectl中重启

(发现,在<一个href=\"http://mcapewell.word$p$pss.com/2006/09/22/restart-apache-in-mac-os-x/\">http://mcapewell.word$p$pss.com/2006/09/22/restart-apache-in-mac-os-x/ )

现在该符号链接应该只是罚款在您的网站的网页。

I have a file in my ~/Sites directory that works fine when I browse to it through 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.

Any ideas anyone?

Thanks!

Forbidden

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

解决方案

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.

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.

The configuration step is performed as follows:

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

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

c) cd users

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

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

sudo vi marvo.conf

f) You'll see something like

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

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

Options Indexes MultiViews FollowSymLinks

(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) Save the file.

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

(Found that at 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天全站免登陆