如何使用 XAMPP 测试网站? [英] How do I test a website using XAMPP?

查看:12
本文介绍了如何使用 XAMPP 测试网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个相当普遍的查询,因为我对如何执行此操作感到非常困惑.我想使用作为 XAMPP 的一部分下载的 apache 服务器来测试我正在构建的网站,该网站将使用 php 和 mysql.一般的问题是:我该怎么做?

This is a fairly general query as I'm very confused about how to do this. I want to use the apache server which I have downloaded as part of XAMPP in order to test the website I am building, which will use php and mysql. The general question is: how do I do this?

据我了解,文件进入 C:xampphtdocs,然后可以通过 localhost 访问.让我感到困惑的是 XAMPP 管理的东西也位于这里 - 例如,我无法在不失去对 phpMyAdmin 的访问权限的情况下替换文件 index.php 等等.我必须在其中为网站创建一个新文件夹吗?

As far as I understand it, the files go into C:xampphtdocs, which can then be accessed via localhost. What confuses me though is that the XAMPP admin stuff is also located here - so, for instance, I can't replace the file index.php without losing access to phpMyAdmin and so on. Do I have to create a new folder for the website within this?

我尝试使用网上找到的说明设置虚拟主机.例如,我按照 here 的指示将其添加到 Windows 主机文件和 xampp 主机配置文件中.完成此操作后,Apache 服务将无法启动并给我一个非常类似于 这个.我按照答案中给出的说明进行操作,但仍然无效.我已经删除并重新安装了它,它再次工作正常,但没有设置虚拟主机.

I tried setting up a virtual host using instructions I found online. I added it to the windows host file and to the xampp hosts config file as directed here, for instance. Having done this the Apache service would not start and gave me an error log very similar to this one. I followed the instructions given in the answer to that, and it still did not work. I have since removed and reinstalled it and it is working ok again, but without the virtual hosts set up.

最后,我想使用 HTMLPad 来构建网站,因为我真的很喜欢它的实时预览功能.但是,要设置它,它需要再次与服务器连接.它给出的指令是:

Finally, I want to use HTMLPad to build the website because I really like its real time preview feature. However, to set this up, it again needs to be connected with the server. The instructions it gives are:

深入教程:如何预览 PHP 文件?

In-depth Tutorial: How do I preview PHP files?

为了能够在本地预览 PHP 文件而无需上传到网络,您需要在您的计算机上安装 Web 服务器,并且它必须是配置为支持 PHP 文件.请参考 PHP 和 web 服务器有关安装支持 PHP 的 Web 服务器的更多信息的手册.

To be able to preview PHP files locally without uploading to web, you need to have a web server installed on your computer and it must be configured to support PHP files. Please refer to PHP and web server manuals for more info on installing web server with PHP support.

我们建议使用来自 apache.org 的免费 Apache Web 服务器

We recommend to use the free Apache web server from apache.org

第 1 步 - 您的文档根目录是什么?找出您的本地网络是什么服务器文档根文件夹.文档根文件夹存放网页可通过您的 Web 服务器 URL 获得的文件.请参考您的网站服务器手册了解更多信息.

Step 1 - What is your document root? Find out what is your local web server document root folder. The document root folder stores web page files available via your web server URL. Please refer to your web server manual for more info.

第 2 步 - 您的网络服务器地址是什么?找出什么是你的本地Web 服务器 URL,通常是 http://localhost/

Step 2 - What is your web server address? Find out what is your local web server URL, usually it is http://localhost/

第 3 步 - 确保您的网络服务器正常工作 验证您的网络服务器真正适用于 PHP 文件.为此,将 PHP 文件保存到您的网站文档根目录并尝试通过网络浏览器打开它.例如,如果您的Web 文档根目录为 c:htdocs,将文件另存为 c:htdocsindex.php并尝试通过 URL http://localhost/index.php

Step 3 - Make sure your web server works Verify that your web server really works with PHP files. To do this, save a PHP file to your web document root and try to open it via web browser. For example, if your web document root is c:htdocs, save your file as c:htdocsindex.php and try to open it via URL http://localhost/index.php

如果您的网络服务器正常工作,您现在可以配置内部预览.

If your web server works, you are now ready to configure internal preview.

第 4 步 – 配置内部预览 现在您必须告诉编辑软件如何使用你的 web 服务器来显示 PHP 文件预览.

Step 4 – Configure internal preview Now you must tell the editor software how to use your web server to display the PHP file preview.

在选项"菜单上,单击首选项";在首选项窗口中,单击预览文件夹;点击映射,然后点击添加;输入您的文件根文件夹和对应的网址,在上面的例子中您将输入 c:htdocs 和 http://localhost/

On the Options menu, click Preferences; In Preferences window, click Preview folder; Click Mappings, then click Add; Enter your document root folder and the corresponding web address, in the above example you would enter c:htdocs and http://localhost/

同样,在上述所有情况下,我不太确定我是否理解这一点.大概这链接到原始 htdocs 文件夹中的所有 php、mysql 等文件?但是,例如,我正在处理的文件保存在哪里重要吗?

Again, in the context of all the above, I'm not quite sure I understand this. Presumably this links to all the php, mysql etc files within the original htdocs folder? But does it matter where the files I'm working on are saved, for example?

基本上,我只是有点困惑,非常感谢任何帮助!

Basically, I'm just a bit confused, and any help would be very much appreciated!

推荐答案

在线服务器上的网页位于位置,看起来有点像这样:http://www.somerandomsite.com/index.php

The webpages on an online server reside in a location which looks somewhat like this: http://www.somerandomsite.com/index.php

由于xampp离线,所以设置了一个本地服务器,地址是这样的http://localhost/

Since xampp is Offline, it sets up a local server whose address is like this http://localhost/

基本上,xampp 在您的系统中设置一个服务器(apache 和其他).所有的文件,如 index.php、somethingelse.php 等,都位于 xampphtdocs 文件夹中.

Basically, xampp sets up a server (apache and others) in your system. And all the files such as index.php, somethingelse.php, etc., reside in the xampphtdocs folder.

浏览器会在 localhost 中定位服务器,并会在上述文件夹中搜索其中的任何可用资源.

The browser locates the server in localhost and will search through the above folder for any resources available in there.

因此,在每个文件夹的xampphtdocs"中创建任意数量的文件夹,从而形成一个网站(在构建时).

So create any number of folders inside the "xampphtdocs" each folder thus forming a website (as you build it).

有时 apache 甚至不会启动.这是由于端口与某些应用程序发生冲突.我经常遇到的其中一些是Skype.确保它被完全杀死并重新启动 apache

Sometimes apache won't even start. This is due to the clashing of ports with some applications. Some of them I commonly encounter is Skype. See to that it is killed completely and restart apache

这篇关于如何使用 XAMPP 测试网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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