没有网络服务器的情况下如何运行php? [英] How can I run a php without a web server?

查看:165
本文介绍了没有网络服务器的情况下如何运行php?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下我是否可以在未安装Web服务器的情况下运行php.我是否必须像CGI一样使用php并通过命令行运行我的页面?如果是这样,我必须通过安装php选择哪些步骤?我的意思是偏好设置为CGI以及该步骤之后的组件?

I would like to ask if I can run a php without having installed a web server. Do I have to use the php like CGI and run my page via command line? And if so, what are the steps that I do I have to choose through the installation of php? I mean the preferences as CGI and the components after that step?

我安装了php 5.3.3,但似乎无法正常工作,我收到几条消息,提示缺少php5ts.dll,当我将该文件放入ext文件夹时,出现其他错误消息.是否需要使用任何配置文件或步骤? (php 5.3.3是否适合做这样的事情?)

I installed the php 5.3.3 but is seems not working, I get several message that the php5ts.dll is missing and when I put that file in my ext folder other error messages appear. Are there any configuration files or steps that I have to use? (is php 5.3.3 suitable for doing something like this?)

如果必须安装Web服务器,如何通过命令行运行php代码?

If I have to have a web server installed how can I run my php code through the command line?

推荐答案

通常,只需运行以下命令,即可正常运行php文件(成功安装后):

You should normally be able to run a php file (after a successful installation) just by running this command:

$ /path/to/php myfile.php // unix way
C:\php\php.exe myfile.php // windows way

您可以在此处了解更多有关在CLI模式下运行PHP的信息. >.

You can read more about running PHP in CLI mode here.

值得补充的是,从5.4版开始的PHP能够独立运行Web服务器.您可以通过在要提供以下页面的文件夹中运行此代码来做到这一点:

It's worth adding that PHP from version 5.4 onwards is able to run a web server on its own. You can do it by running this code in a folder which you want to serve the pages from:

$ php -S localhost:8000

您可以在此处上阅读有关在Web服务器模式下运行PHP的更多信息. a>.

You can read more about running a PHP in a Web Server mode here.

这篇关于没有网络服务器的情况下如何运行php?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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