[英]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.