简体   繁体   English

从/ var / www文件夹运行php程序

[英]Run php program from /var/www folder

I have lampp server and UBUNTU OS, when I use my command line I write, 我有lampp服务器和UBUNTU OS,当我使用命令行编写时,

sudo /opt/lampp/lampp start

for starting my xampp server on linux. 在Linux上启动我的xampp服务器。 Now I can able to run my php code written in /opt/lampp/htdocs directly by calling, 现在,我可以通过调用直接运行以/ opt / lampp / htdocs编写的php代码,

localhost/myphpcode.php

And it works well. 而且效果很好。

But I want to run my php code from folder /var/www which is in root. 但是我想从根目录下的/ var / www文件夹运行我的php代码。 How can I run my php folder using this path? 如何使用此路径运行php文件夹?

编辑httpd.conf文件并添加DocumentRoot "/var/www"来修改根目录,将文件放在此处并重新启动服务器

Make sure that you have Apache configured to serve PHP pages and that Apache config is setup correctly. 确保已将Apache配置为提供PHP页面,并且Apache配置正确设置。

What happens when you hit localhost/file.php ? 当您点击localhost / file.php时会发生什么? Does anything happen, or does it download the file? 有什么事情发生,还是下载了文件?

You can keep your php files in apache2 DocumentRoot ie /var/www/html by default and start apache2 service provided it has php supported modules. 您可以将您的php文件默认保存在apache2 DocumentRoot中,即/ var / www / html,并启动apache2服务,前提是它具有php支持的模块。 You would be able to open the page on browser by localhost and also by ipaddress of the linux ubuntu box. 您将能够通过本地主机以及linux ubuntu框的ipaddress在浏览器上打开页面。

https://help.ubuntu.com/community/ApacheMySQLPHP -> This link would be helpful. https://help.ubuntu.com/community/ApacheMySQLPHP- >此链接将很有帮助。

Thanks & Regards, 感谢和问候,
Alok Thaker 阿洛·萨克(Alok Thaker)

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

相关问题 无法从file.php在/ Var / www / html中创建文件夹 - Failing to create folder in /Var/www/html from file.php 无法从var文件夹运行php文件 - Cant run a php file from var folder 如何从/ etc / crontab在/ var / www /中运行PHP页面? - How to run PHP page in /var/www/ from /etc/crontab? PHP项目的/ var / www /文件夹结构 - /var/www/ folder structure for PHP project 如何用www文件夹中的密码保护php程序文件夹 - How to protect php program folder with password in www folder 在/ var / www外部创建文件夹 - Creating folder outside /var/www 从EC2实例移到GCE实例后php程序中的错误=无法访问文件:/ var / www / html / - Error in php program after moving from EC2 instance to GCE instance = Could not access file: /var/www/html/ 如何在apache /var/www/demo.html中的html java脚本中从php-url运行json解析 - how to run json parsing from php-url in html java script in apache /var/www/demo.html 如何从 Apache/Php 使用 Wine? - '/var/www' 不属于你 - How to use Wine from Apache/Php? - '/var/www' is not owned by you => 错误 [8/9] 在 dockerfile symfony php 项目中运行 cd /var/www && composer install && npm install && npm run build - => ERROR [8/9] RUN cd /var/www && composer install && npm install && npm run build in a dockerfile symfony php project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM