Click here to Skip to main content
14,421,622 members
Rate this:
Please Sign up or sign in to vote.
See more:
Sorry, I am a new in Linux and Php, so I have been struggling to run a script, mainly because all the practice I did was on a file called index.php in my var/www/html directory. I would like to run a script from a different folder, as in this one I cannot create any other files and so I can not work on my project. How am I supposed to do that and how will I be able to run the script afterwards on localhost?

What I have tried:

I tried creating a script in other directory but couldn't run it on localhost, or I just don't know how.
Posted
Updated 10-Aug-19 7:51am
Comments
Afzaal Ahmad Zeeshan 22-Jan-17 4:00am
   
You need to configure the server to load the script from another directory.
Rate this:
Please Sign up or sign in to vote.

Solution 1

If you insist not to run you script from default folder, then check this out: [^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

You have to make your var/www/html in full access
chmod 777 var/www/html
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

you can run php script even with web server "e.g in case you only need to send and receive certain input/output " just add
#!/usr/bin/php-cgi -f

in very top of your php file and change it to excitable with this command
chmode +x /yourpath/index.php

when you want to run it us it name and hit enter
/yourpath/index.php
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100