Click here to Skip to main content
15,884,018 members
Please Sign up or sign in to vote.
2.00/5 (1 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 6:51am
Comments
Afzaal Ahmad Zeeshan 22-Jan-17 4:00am    
You need to configure the server to load the script from another directory.

If you insist not to run you script from default folder, then check this out: [^]
 
Share this answer
 
You have to make your var/www/html in full access
chmod 777 var/www/html
 
Share this answer
 
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
CSS
#!/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
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900