使用 XAMPP 包在本地显示 php 站点的问题.站点在远程服务器上运行良好

2022-01-14 00:00:00 xampp php dreamweaver htdocs

我第一次在 stackoverflow.com 上发帖!一个很棒的网站,我希望我的帖子能为他人的利益做出贡献.

My first ever post on stackoverflow.com! A great site, and I hope my post will contribute to the benefit of others.

情况:我被委托翻新一个真正小型、现有、php 驱动的网站.

The situation: I have been entrusted to renovate a really small, existing, php-driven web site.

所以,我开始设置我的环境:

So, I started to set up my environment:

  • Dreamweaver 已安装.
  • 我将文件从远程服务器通过 FTP 传输到我的计算机.
  • 我选择 Apache 和 MySQL 通过 XAMPP 包设置本地在我的电脑(PC,Windows XP)上安装主机,安装 XAMPP 并设置默认情况下省略的密码.
  • 我确保 Apache 和 MySQL 都已启动并运行.
  • 我设置了本地信息、远程信息和测试的参数Dreamweaver 中的服务器(这需要一些时间).

到目前为止一切都很好.

All's well so far.

但在浏览器中本地预览时,该网站无法正常工作.现场版运行良好.

But the site would not work properly when previewed locally in a browser. The live version ran just fine.

问题:该站点的第一页将在没有连接到 css 样式表或图像文件夹的情况下启动,并且在尝试生成的链接时,他们会点击根文件夹中的 XAMPP 重定向,并且会显示 XAMPP 橙色页面.

The problem: The first page of the site would launch with no connection to the css stylesheet or the images folder and when trying the generated links, they would hit the XAMPP redirect in the root folder and the XAMPP orange page would display.

那么,如何解决这个问题?

So, how to fix this?

再次感谢您提供了一个很棒的网站!/瓦克拉

Again, thanx for a great site! /Vaquera

推荐答案

解决方案...是编辑 xampp/apache/conf/httpd.conf 文件中的 DocumentRoot 设置.

The solution ...was to edit the DocumentRoot setting in the xampp/apache/conf/httpd.conf file.

问题是我将测试站点的动态内容所在的文件夹作为 XAMPPs 默认 webroot 文件夹 htdocs 的子文件夹放置:htdocs/MySampleSite

The thing was that I had placed the folder where the dynamic contents of my test site was as a subfolder to XAMPPs default webroot folder htdocs: htdocs/MySampleSite

当我将 xampp/apache/conf/httpd.conf 中的 DocumentRoot 设置从默认文件夹 DocumentRoot "C:/xampp/htdocs" 编辑到实际文件夹 DocumentRoot "C:/xampp/htdocs/MySampleSite" 时,所有问题自己解决了.

When I edited the DocumentRoot setting in the xampp/apache/conf/httpd.conf from the default folder DocumentRoot "C:/xampp/htdocs" to the actual folder DocumentRoot "C:/xampp/htdocs/MySampleSite" all the problems resolved themselves.

请记住,您需要在 httpd.conf 中的两个位置进行更改!除了上面提到的,您还必须将默认更改为

Do remember that you need to change this on two locations in httpd.conf! Apart from the above mentioned, you also have to change the default to

嗯,事后看来,我想这是相当微不足道的,但找到正确的地方需要一些时间,所以我希望这可能对其他人有所帮助.

Well, in hindsight, I guess it's rather trivial, but it took some time in finding the right place, so I hope this might help others.

再次感谢您提供了一个很棒的网站!瓦克拉

Again, thanx for a great site! Vaquera

相关文章