xampp 虚拟主机_在Windows中使用XAMPP在本地主机上运行您的第一个PHP脚本

xampp 虚拟主机

This article helps you to run your first PHP script successfully on Windows from your local host. It should be useful for PHP novices on Windows.  Before dive in to PHP, lets set up an environment to run PHP on Windows.

本文可帮助您从本地主机在Windows上成功运行第一个PHP脚本。 对于Windows上PHP新手来说,它应该很有用。 在深入探讨PHP之前,让我们建立一个环境以在Windows上运行PHP。

Yes, If you use PHP on Windows then you are not only on Win environment but on Win - Win Environment. You will feel this after you run your first PHP script on windows. OK,let's get into action.
是的,如果您 在Windows上使用 PHP,则不仅在Win环境中,而且在 Win-Win环境中。 在Windows上运行第一个PHP脚本后,您会感觉到这种情况。 好,让我们开始行动。
Note: 注意:

Code attached with this is verified and has been run successfully on Windows XP, Windows 7, Windows VISTA on all commonly-used browsers.

附带的代码已经过验证,并已在所有常用浏览器的Windows XP,Windows 7,Windows VISTA上成功运行。



1个 (1)

Download XAMPP,  an opensource package that holds Apache, PHP, MySQL, PERL (very old but powerful) which makes our work easier. 下载XAMPP ,这是一个开放源代码包,其中包含Apache,PHP,MySQL,PERL(虽然很旧,但功能强大),这使我们的工作更加轻松。 Read more here (I mean the installation and configuration of PHP, Apache and MySQL on windows).  Download 在这里阅读更多 (我的意思是在Windows上安装和配置PHP,Apache和MySQL)。 下载 XAMPP self extracting RAR archive .EXE file which in turn is an easy way rather than a zipped archive. Install it on your top level folder / directory of any drive Eg : C:\xampp or D:\xampp. The XAMPP自解压RAR存档 .EXE文件,这反过来是一种简单的方法,而不是压缩存档。 将其安装在任何驱动器的顶级文件夹/目录中,例如C:\ xampp或D:\ xampp。 instructions on the XAMPP web page are very clear with good screenshots. XAMPP网页上的说明非常清晰,并带有良好的屏幕截图。

A few words about XAMPP ingredients,  

关于XAMPP成分的几句话,

Apache - A powerful and popular Web server to run server side scripts like PHP, ASP, JSP, CFML etc. Read More

Apache-一种功能强大且流行的Web服务器,用于运行服务器端脚本,例如PHP,ASP,JSP,CFML等

PHP - A simple, flexible, powerful and easy to learn and get help server side scripting language with huge community support. Read More

PHP-一种简单,灵活,功能强大且易于学习的方法,并获得社区大力支持的服务器端脚本语言。 阅读更多

MySQL - An open source RDBMS (database management system) with great set of features and very compatible with PHP. Read More

MySQL-一种开源RDBMS(数据库管理系统),具有许多功能,并且与PHP十分兼容。 阅读更多

PERL -  A 22 year-old powerful scripting language -- perhaps a pioneer of PHP or server side scripting.   A person with the basics of 'C' and 'UNIX' finds it easier to work with.Read More

PERL -22年的强大脚本语言-也许是PHP或服务器端脚本的先驱。 具有“ C”和“ UNIX”基础知识的人会发现使用它更容易。 阅读更多

2 (2)

现在只需打开安装XAMPP的文件夹,然后通过运行以下命令来运行xampp控制面板

    xampp-control.exe

xampp-control.exe

inside your xampp folder.        

在您的xampp文件夹中。

If you find the running... label highlighted in green color next to Apache and MySql then it is time to script your first PHP program, and our environment is ready.  If not, just click the check boxes near to Apache and MySQL to install them as Windows services and click start button.  (Wait for a while, don't lose your temper -- don't click the start button again and again which you more likely to do as a beginner.)

如果您在Apache和MySql旁边找到以绿色突出显示的running ...标签,那么该是编写第一个PHP程序脚本的时候了,我们的环境已经准备就绪。 如果不是,只需单击Apache和MySQL附近的复选框以将它们安装为Windows服务,然后单击“开始”按钮。 (请稍等片刻,不要发脾气-不要一次又一次单击“开始”按钮,您可能更适合初学者。)

At this point, some students get struck -- they find Apache / xampp not running on localhost even after this.  Most of the times it is because the IIS (Microsoft's web server) runs by default and occupied the HTTP port  : 80, which Apache demands by default. There are two ways to resolve this.

在这一点上,一些学生感到震惊-他们甚至发现Apache / xampp不在本地主机上运行。 在大多数情况下,这是因为IIS(Microsoft的Web服务器)默认情况下运行并占用了HTTP端口:80,Apache默认需要此端口。 有两种解决方法。

The easy way:

简单的方法:

Type services.msc in the run window.  In other words Windows Key + R and type

在运行窗口中键入services.msc。 换句话说,Windows Key + R并输入

     services.msc  

services.msc

and click OK.  Find the IIS admin in the list of services shown in the window below.  If you find its status 'started' and startup type 'automatic' then right click on IIS admin and select Properties option in the pop up screen and stop the IIS service and change its startup type to disabled from the drop down list.  And click OK.

然后单击确定。 在下面窗口中显示的服务列表中找到IIS管理员。 如果找到状态为“已启动”且启动类型为“自动”,请右键单击IIS admin,然后在弹出屏幕中选择“ 属性”选项,然后停止IIS服务,然后从下拉列表中将其启动类型更改为“禁用”。 然后单击确定。

Services

OR.... the other way

或者....另一种方式

The next way is to open 'httpd.conf' in the following location YOURDRIVE:\xampp\apache\conf It is ia simple text file.   Change 'Listen 80' to

下一步是在您的以下位置打开“ httpd.conf”:\ xampp \ apache \ co nf这是一个简单的文本文件。 将“听80”更改为

   Listen 81

听81

or Listen 8085 or the port number you wish (but don't use the reserved port numbers).  

或收听8085或您想要的端口号(但不要使用保留的端口号 )。

Httpd Configuration File

Note:

注意:

You can follow either of these two options as per your wish.  I don't recommend or insist that you choose only one of them rather than the other one.

您可以按照自己的意愿选择以下两个选项之一。 我不建议也不坚持您只选择其中之一,而不要选择另一个。

3 (3)

因此,我们已经成功安装了xampp,现在该使用PHP了。

i. Open notepad and copy paste the following PHP code into it or just use the attached file and copy it in htdocs folder inside xampp (eg:c:\\xampp\htdocs\).

一世。 打开记事本,然后将以下PHP代码复制粘贴到其中,或仅使用附件将其复制到xampp中的htdocs文件夹中(例如:c:\\ xampp \ htdocs \)。

<?php

    echo "<center><b>Kudos !!! You have successfully run your first PHP scrip on Windows</b> :-)</center>";
    echo "<br/><center><b>Welcome to <h2>PHP</h2> the language of web</b></center>";
    echo "<br/><center>For any PHP queries Contact :<a href='http://www.experts-exchange.com/M_5168010.html'>haijerome</a></center> ";

?>

ii Save the file as "haiphp.php" into htdocs folder of xampp server (eg: c:\\xampp\htdocs\) and select save as type "All Files".

ii将文件另存为“ haiphp.php”到xampp服务器的htdocs文件夹中(例如:c:\\ xampp \ htdocs \),然后选择另存为类型“ All Files”

All Files

And my kind suggestion is to use Notepad++ or if you want to be very professional then download Net Beans or buy Dream Weaver.        

我的建议是使用Notepad ++,或者如果您想变得非常专业,请下载Net Beans或购买Dream Weaver。

iii. Now type the url "http://localhost/haiphp.php" and see the PHP script running like a cake on your localhost web browser.

iii。 现在,键入URL“ http://localhost/haiphp.php ”,然后在本地主机Web浏览器上看到PHP脚本像蛋糕一样运行。

If you have followed the step ii of step 2 then type the URL like this http://localhost:81/haiphp.php assumed that your port number is 81.  If not, give the port number that you have saved as listen port number in the httpd.conf file.

如果您已按照步骤2的步骤ii进行操作,则键入如下URL :http:// localhost:81 / haiphp.php假定您的端口号是81。否则,输入保存为侦听端口号的端口号在httpd.conf文件中。

PHP script
http://localhost/xampp and conform whether you're getting the xampp home page.  If it displays the XAMPP home page then verify that you have saved your PHP file inside htdocs folder and the file name as haiphp.php and file type as 'all files'. http:// localhost / xampp并确认是否要获取xampp主页。 如果显示XAMPP主页,请确认您已将PHP文件保存在htdocs文件夹中,文件名为haiphp.php,文件类型为'all files'。

If you don't even get the xampp home page, then make sure Apache is running.  Follow the main step 2 given in the article above to get xampp or apache running on your  localhost to resolve object not found or object not found error no : 404.

如果您甚至没有获得xampp主页,请确保Apache正在运行。 按照上面文章中给出的主要步骤2,使xampp或apache在本地主机上运行,​​以解决找不到对象或找不到对象的错误,错误号:404。

I am not a professional article writer (am just a budding article writer but am a good article reader, so kindly don't mind about anything that you found very awkward or blunder in this article. If any, kindly let me know.  I hope this article is a welcome one for all the PHP beginners on windows and fortunately becomes the very first article on this zone.  Let me have your thoughts, comments, suggestions, and queries.  And if you find it useful then kindly click on the helpful YES button to vote this one. Cheers EE :-). All Glory Goes to GOD !!!

我不是专业的文章撰稿人(我只是一个崭露头角的文章撰稿人,但还是很好的文章阅读者,所以请不要介意您在本文中发现的任何尴尬或错误之处。如果有的话,请告诉我。我希望本文是Windows上所有PHP初学者的欢迎文章,幸运的是,这是该区域的第一篇文章。让我发表您的想法,评论,建议和疑问。如果您觉得有用,请单击有用的是按下按钮,即可投票给EE.-)所有的荣耀归于神!

Best Regards,

最好的祝福,

Jerome Dennis D

杰罗姆·丹尼斯D

翻译自: https://www.experts-exchange.com/articles/3931/Running-your-first-PHP-script-on-Windows-using-XAMPP-in-your-localhost.html

xampp 虚拟主机

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值