How to run php programs on local computer?
Brian Cluff
brian at snaptek.com
Wed Jul 3 14:12:24 MST 2013
Here's the Debian/Ubuntu/etc counterpart to the CentOS/RHEL instructions.
sudo apt-get install apache2 php5
It should be ready to go as soon as that is installed.
As for how php works. The php files are just plain html files with
areas of php that start with <?php and end with ?>
<html>
<head><title>Normal Title</title></head>
<body>
<b>This will show up like any other html and not be processed as PHP</b>
<?php
print "<b>This will be processed as PHP and generate text that will be
processed as html by the browser</b>";
?>
<b>This will also show up like any other html and not be processed as
PHP</b>
</body>
</html>
If you paste the above code into a file named /var/www/index.php you
will see the result. Just point your web browser at
http://127.0.0.1/index.php
Brian Cluff
On 07/03/2013 01:39 PM, joe at actionline.com wrote:
> == 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.
>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
More information about the PLUG-discuss
mailing list