Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a PHP file on my computer that is outside the htdocs directory?

I just installed Apache and PHP on my computer to be able to run PHP files locally.

I can run a PHP file if it is located in Apache2.2\htdocs directory.

Is that possible to run PHP files outside this directory ?

I'm looking to a simple solution, because all I need is to write a small PHP code and try it locally.

I would like to be able to run the PHP file by right clicking it -> Open with Firefox

like image 944
Misha Moroshko Avatar asked Feb 26 '23 21:02

Misha Moroshko


1 Answers

You can run a PHP script from anywhere using the command line:

php yourscript.php
like image 179
thetaiko Avatar answered Mar 09 '23 00:03

thetaiko