jjzjj

php - window : Add site directory to Apache config

coder 2024-04-20 原文

我的计算机上有一个 Apache 的本地实例用于开发目的,我正在尝试将站点目录添加到 Apache 的 httpconf 文件,其中包含一些我正在尝试使用 Eclipse 调试的示例 Web 应用程序。我要添加的目录如下:

C:\Eclipse_Workspace\dummyWeb

添加路径后,我重新启动了 Apache 并尝试输入一个 URL 为:

http://localhost/Eclipse_Workspace/dummyWeb/enterGreeting.php

但我收到 404 错误页面。我不确定我必须做什么才能让页面正常打开。我是 Apache 服务器配置的新手,正在使用 ApacheConf Lite 作为基于 GUI 的服务器设置编辑器。我在 httpconf 文件中添加的新目录如下所示:

<Directory "C:\Eclipse_Workspace\dummyWeb">
  Options All
  Allow from All
  Order Allow,Deny
  AllowOverride None
</Directory>

我还尝试将最后一个斜杠设为正斜杠,就像默认的根目录一样:

<Directory "C:\Eclipse_Workspace/dummyWeb">
  Options All
  Allow from All
  Order Allow,Deny
  AllowOverride None
</Directory>

与默认根相比:

<Directory "C:\Program Files\Zend\Apache2/htdocs">
  # 
  # Possible values for the Options directive are "None", "All",
  # or any combination of:
  # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  # 
  # Note that "MultiViews" must be named *explicitly* --- "Options All"
  # doesn't give it to you.
  # 
  # The Options directive is both complicated and important.  Please see
  # http://httpd.apache.org/docs/2.2/mod/core.html#options
  # for more information.
  Options FollowSymLinks Indexes
  # 
  # AllowOverride controls what directives may be placed in .htaccess files.
  # It can be "All", "None", or any combination of the keywords:
  # Options FileInfo AuthConfig Limit
  Allow from all
  # 
  # Controls who can get stuff from this server.
  Order allow,deny
  AllowOverride None
  # 
  # Note that from this point forward you must specifically allow
  # particular features to be enabled - so if something's not working as
  # you might expect, make sure that you have specifically enabled it
  # below.
  # 
  # 
  # This should be changed to whatever you set DocumentRoot to.
</Directory>

但我仍然得到 404,我错过了什么?感谢您的帮助。

一些其他细节,我使用 Zend Server Community Edition 进行 PHP web 开发和 Eclipse with PDT。我的目标是能够通过 Eclipse 调试 PHP Web 应用程序。

更新:

看起来添加别名可能正是我要找的。虽然不确定它们是如何工作的,但目前正在阅读 Apache 文档。

更新 2:

宾果游戏!看起来添加别名就可以了。相关配置行如下:

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:\Program Files\Zend\Apache2/htdocs"

.

.

.

.

<IfModule alias_module>
  # 
  # Redirect: Allows you to tell clients about documents that used to
  # exist in your server's namespace, but do not anymore. The client
  # will make a new request for the document at its new location.
  # Example:
  # Redirect permanent /foo http://www.example.com/bar
  # 
  # Alias: Maps web paths into filesystem paths and is used to
  # access content that does not live under the DocumentRoot.
  # Example:
  Alias /webpath "C:/Eclipse_Workspace/dummyWeb/"
  <Directory "C:/Eclipse_Workspace/dummyWeb/">
  Options Indexes FollowSymLinks MultiViews ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
  </Directory>
  # 
  # If you include a trailing / on /webpath then the server will
  # require it to be present in the URL.  You will also likely
  # need to provide a <Directory> section to allow access to
  # the filesystem path.
  # 
  # ScriptAlias: This controls which directories contain server scripts.
  # ScriptAliases are essentially the same as Aliases, except that
  # documents in the target directory are treated as applications and
  # run by the server when requested rather than as documents sent to the
  # client.  The same rules about trailing "/" apply to ScriptAlias
  # directives as to Alias.
  ScriptAlias /cgi-bin/ "C:\Program Files\Zend\Apache2/cgi-bin/"
</IfModule>

因此,如果我输入以下 URL:http://localhost/webpath/,我将获得如下目录列表:

布兰登,感谢您的建议。我想保持文档根目录不变,我将修改别名以向上移动一个目录,即 C:/Eclipse_Workspace/ 这样我就可以在 eclipse 中调试我的所有 Web 应用程序工作区。这link还提供了一个关于添加别名时可能遇到的问题的好提示。

最后但同样重要的是,对于任何有兴趣设置简单的 PHP 开发环境的人,this PDF 文档被证明是非常宝贵的资源,请务必按照说明进行操作。我使用了 Zend's website 上提供的一体化打包工具,它们几乎是开箱即用的。

最佳答案

我查看了我自己的 apache 文件,我认为您遗漏了一个更改文档根目录的地方:

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:\Eclipse_Workspace\dummyWeb"

我相信这是关于 httpd.conf 文件中的第 210 行,我在这里使用你的目录。

关于php - window : Add site directory to Apache config,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6217649/

有关php - window : Add site directory to Apache config的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. ruby - 在 Windows 机器上使用 Ruby 进行开发是否会适得其反? - 2

    这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby​​-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub

  3. Vscode+Cmake配置并运行opencv环境(Windows和Ubuntu大同小异) - 2

    之前在培训新生的时候,windows环境下配置opencv环境一直教的都是网上主流的vsstudio配置属性表,但是这个似乎对新生来说难度略高(虽然个人觉得完全是他们自己的问题),加之暑假之后对cmake实在是爱不释手,且这样配置确实十分简单(其实都不需要配置),故斗胆妄言vscode下配置CV之法。其实极为简单,图比较多所以很长。如果你看此文还配不好,你应该思考一下是不是自己的问题。闲话少说,直接开始。0.CMkae简介有的人到大二了都不知道cmake是什么,我不说是谁。CMake是一个开源免费并且跨平台的构建工具,可以用简单的语句来描述所有平台的编译过程。它能够根据当前所在平台输出对应的m

  4. 深度学习部署:Windows安装pycocotools报错解决方法 - 2

    深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal

  5. ruby - 如何在 Ruby 中执行 Windows CLI 命令? - 2

    我在目录“C:\DocumentsandSettings\test.exe”中有一个文件,但是当我用单引号编写命令时`C:\DocumentsandSettings\test.exe(我无法在此框中显示),用于在Ruby中执行命令,我无法这样做,我收到的错误是找不到文件或目录。我尝试用“//”和“\”替换“\”,但似乎没有任何效果。我也使用过系统、IO.popen和exec命令,但所有的努力都是徒劳的。exec命令还使程序退出,这是我不想发生的。提前致谢。 最佳答案 反引号环境就像双引号,所以反斜杠用于转义。此外,Ruby会将空格解

  6. ruby-on-rails - 这个 C 和 PHP 程序员如何学习 Ruby 和 Rails? - 2

    按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它

  7. ruby - 错误 : Failed to build gem native extension on Windows - 2

    我在安装“redcarpet”gem时遇到以下错误。它在我friend的机器上安装没有问题。(我想安装它来运行yard)ruby版本:1.9.3命令输出:D:\Learning\Common_POM_FW\SampleProjects>yard[error]:Missing'redcarpet'gemforMarkdownformatting.Installitwith`geminstallredcarpet`D:\Learning\Common_POM_FW\SampleProjects>geminstallredcarpetTemporarilyenhancingPATHtoinc

  8. ruby - 从 Ruby 连接到适用于 Windows Phone 8 的 Microsoft 推送通知服务 - 2

    我们正在开发一个需要推送通知的WP8应用程序。为了测试它,我们使用CURL命令行运行推送通知POST请求,确保它实际连接,使用客户端SSL证书进行身份验证并发送正确的数据。我们确实知道,当我们收到对设备的推送时,这项工作是有效的。这是我们一直用于测试目的的CURL命令:curl--certclient_cert.pem-v-H"Content-Type:text/xml"-H"X-WindowsPhone-Target:Toast"-H"X-NotificationClass:2"-XPOST-d"MytitleMysubtitle"https://db3.notify.live.ne

  9. ruby - 在 Windows 7 上运行 Jekyll - 2

    我在Windows7上运行Jekyll时遇到问题。当我运行时jekyll出现以下错误C:\temp\jekyll\kouphax.github.com>jekyllConfigurationfromC:/temp/jekyll/kouphax.github.com/_config.ymlBuildingsite:C:/temp/jekyll/kouphax.github.com->C:/temp/jekyll/kouphax.github.com/_siteunit-testingYouaremissingalibraryrequiredforTextile.Pleaserun:$[s

  10. ruby - 尝试在 Windows 8 (x64) : Error installing fast-stemmer-1. 0.2.gem 上安装 Jekyll - 2

    我正在尝试使用本手册让Jekyll在Windows8x64上运行:RunningJekyllonWindows我正在使用来自rubyinstaller.org的以下两个下载:ruby2.0.0-p0(x64)DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe所以我根据手册设置了Ruby和DevKit(希望它是更新的版本)。我尝试运行一点HelloWorld.rb脚本,它工作正常,路径变量已设置。然后我尝试运行geminstalljekyll并得到以下输出:geminstalljekyll-outputonpastebin.com问题似乎出在名为f

随机推荐