简体   繁体   English

如何从localhost运行PHP应用程序?

[英]How to run PHP application out of localhost?

I got this task form school, to make a PHP web application. 我从学校开始这个任务,制作一个PHP Web应用程序。 But I don't really understand what this requirement might mean 但我真的不明白这个要求可能意味着什么

It should be possible to run this application outside the domain root eg sample URL: http://localhost/task/ . 应该可以在域根之外运行此应用程序,例如示例URL: http:// localhost / task /

I searched a little bit on the internet but was not able to find anything that I could understand ? 我在互联网上搜索了一下但是找不到任何我能理解的东西?

I have wamp, and the folder where is my sites is wamp/www/task 我有wamp,我的网站所在的文件夹是wamp/www/task

When they say "outside of domain root" it means that you should not be forced to go to 当他们说“在域根之外”时,这意味着你不应该被迫去

http://localhost/yourfile.php

but you could put it in a subdir, like 但你可以把它放在一个子目录中,比如

http://localhost/task/yourfile.php

What they want you to do is harder to guess, but it could mean that you need to be able to run it in any subdir, so take care of you imports to be able to handle that (eg: not hardcode the dir you're working in). 他们想要你做的更难猜测,但这可能意味着你需要能够在任何子目录中运行它,所以要注意你的导入能够处理它(例如:不硬编码你的目录)在工作)。

Domain root seems to be at localhost , this just means it should be easy to rename your web application folder and make it still work at anywhere. 域根似乎是在localhost ,这只是意味着它应该很容易重命名您的Web应用程序文件夹,并使其仍然可以在任何地方工作。

# http://localhost/task
$ cd wamp/www/

# http://localhost/task2 - should be accessible without you needing to change anything
$ mv task task2

From technical point of view, you should use relative path for all your links and images as well as external resources such as javascript / css files 从技术角度来看,您应该为所有链接和图像以及外部资源(如javascript / css文件)使用相对路径

you can set vitual host for your web server & access your PHP Application likw www.oorja.local 您可以为您的Web服务器设置虚拟主机并访问您的PHP应用程序,如www.oorja.local

in the wamp server, just add below code at end of your httpd.conf file, which allow you access your PHP application without localhost, Document root and Directory have your physical pathe of your application directory. 在wamp服务器中,只需在httpd.conf文件的末尾添加以下代码,这样就可以在不使用localhost的情况下访问PHP应用程序,文档根目录和目录可以对应用程序目录进行实际操作。

ServerName oorja.local DocumentRoot E:/LAMPSYSTEM/wamp/www/oorja/public ServerName oorja.local DocumentRoot E:/ LAMPSYSTEM / wamp / www / oorja / public

      <Directory E:/LAMPSYSTEM/wamp/www/oorja/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在本地主机上运行PHP项目 - How to run a PHP project on localhost 如何导航出我的php localhost服务器项目(wamp服务器)? - How to navigate out of my php localhost server project (wamp server)? PHP如何停止从本地主机发送电子邮件 - PHP how to stop email sending out from localhost 使用 localhost 运行 PHP,它如何选择要运行的文件? - Running PHP using localhost, how does it pick which file to run? 如何在本地主机上连续运行PHP脚本? - How do I run a PHP script continuously on localhost? 如何设置cron以在Ubuntu的localhost上运行PHP文件? - How to set cron in to run PHP file on localhost in Ubuntu? 我如何使用zend服务器在本地主机上运行.php? - How do i run .php on localhost using zend server? 如何在另一台服务器上存储的本地主机上运行php脚本 - How to run php script on localhost stored on another server 在本地主机上使用数据库的亚马逊AWS服务器,我如何ssh以便我可以在localhost上运行我的php webservices? - Amazon AWS server with database on localhost, how do I ssh so that my php webservices on localhost can run on it? 为什么 Visual Studio 需要启用调试才能为 php webb 应用程序运行 localhost - Why does visual studio requires debug enabled to run localhost for php webb application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM