How to run php programs on local computer?

joe at actionline.com joe at actionline.com
Wed Jul 3 13:39:07 MST 2013


== Joe asked:
>> What do I need to do to be able to run php programs
>> on my local linux computer?
>> It's a nuisance to have to upload programs to my
>> web host to test small changes.

== kitepilot replied: If they are WEB:
Install Apache in your box and run from http://localhost/
If they are 'shell', make sure that the first line is:
#!/bin/php (whatever 'which php' resolves to...)

== J: Sorry I'm so lame, but I don't understand this.

== Keith replied: If you are doing any data stuff,
you will have to pull in MySql as well.

== J: I hope to avoid MySql, keep it simple and just use text files.

== Matt replied: Search the Net for "$DISTRO apache php setup"
There are (usually) default configurations in distro
packages that make running a simple setup easy.
- Once done, put PHP code within .php files in some dir
under /var/www/localhost/ .  Then go to
http://localhost/myfile.php in a browser should execute
that PHP code and display the results in that browser.

- (example) On CentOS/RHEL, you would do:
yum install httpd php53 php53-mysql
/etc/init.d/httpd start
# optional, but makes apache always starts on boot
chkconfig httpd on

== J: Thanks for all the replies. Matt, you always provide
especially valuable guidance.  Simple setup is what I need ;)
Which is optional? '/etc/init.d/httpd start' or 'chkconfig'?
I find no man entry for 'chkconfig'

I've been searching the 'net and trying to read and learn
how PHP works, but I still don't understand how to put
the php and html components together; or if they should
be in separate files or integrated into one.





More information about the PLUG-discuss mailing list