Run php program from /var/www folder

I have lampp server and UBUNTU OS, when I use my command line I write,

sudo /opt/lampp/lampp start

for starting my xampp server on linux. Now I can able to run my php code written in /opt/lampp/htdocs directly by calling,

localhost/myphpcode.php

And it works well.

But I want to run my php code from folder /var/www which is in root. How can I run my php folder using this path?

Answers


Edit httpd.conf file and add DocumentRoot "/var/www" for modifying root directory, put your file there and restart server


You can keep your php files in apache2 DocumentRoot i.e /var/www/html by default and start apache2 service provided it has php supported modules. You would be able to open the page on browser by localhost and also by ipaddress of the linux ubuntu box.

https://help.ubuntu.com/community/ApacheMySQLPHP -> This link would be helpful.

Thanks & Regards, Alok Thaker


Make sure that you have Apache configured to serve PHP pages and that Apache config is setup correctly.

What happens when you hit localhost/file.php ? Does anything happen, or does it download the file?


Need Your Help

if(condition fails in jascript)

javascript jquery ajax

I have following code which is working in localhost in windows. But in the server same code fails.