PDA

View Full Version : [ubuntu] Download webpage written in PHP



flylehe
July 23rd, 2009, 04:15 PM
Hi,
I just saved a webpage written in PHP. Now I am not sure how to open the .php file so that I can read the content as I browsed the webpage. Open it in Firefox directly seems not work. Or how to save webpage written in PHP correctly?
Thanks and regards!

bertwagner
July 23rd, 2009, 04:29 PM
Hi,
I just saved a webpage written in PHP. Now I am not sure how to open the .php file so that I can read the content as I browsed the webpage. Open it in Firefox directly seems not work. Or how to save webpage written in PHP correctly?
Thanks and regards!

In order for the PHP code to be shown properly it needs to be rendered by a server that has PHP installed. You can install an Apache server with PHP on your own Ubuntu machine, here's more information on how to do it:
https://help.ubuntu.com/community/ApacheMySQLPHP

wojox
July 23rd, 2009, 04:33 PM
Rename the extension to htm or html

masux594
July 23rd, 2009, 04:35 PM
Php is a server side language.. When u request the page, the php page were elaborated from the php engine and then send to u.. So, for "Dowloading a php file".. Or u zip the page, so you save the file, extract and u have your page.. Or put php in another file named ".txt" .. Maybe a solution?

Sysc, A

flylehe
July 23rd, 2009, 04:50 PM
Thanks!
Will an Apache server with PHP take a lot of space on my laptop?
Is it possible to save a webpage written in PHP as HTML file?

wojox
July 23rd, 2009, 04:53 PM
Yes you can save it as html.

Here is a link to Apache2

https://help.ubuntu.com/community/ApacheMySQLPHP

But you don't need to go to all that trouble to view a page you saved written in php. Just change the file extension.

bertwagner
July 23rd, 2009, 04:57 PM
Thanks!
Will an Apache server with PHP take a lot of space on my laptop?
Is it possible to save a webpage written in PHP as HTML file?

I don't know about the installation size of Apache with PHP but I can help with the second question:

If you save a webpage written in PHP as HTML, only the parts outside of any PHP tags (<?php and ?>) will be rendered by a browser, making any dynamic PHP content you may have be ignored and not be displayed. If you have content that needs to be within PHP tags, then it will have to be done using PHP.

Cheesemill
July 23rd, 2009, 05:09 PM
You can find out how much room a LAMP install would take up on your laptop by doing:

sudo apt-get install lamp-server^This will tell you how much space will be used, just hit n to cancel the installation.

Viva
July 23rd, 2009, 05:11 PM
If you want to view a saved php page, just change the extension to html. You don't need to install a server unless you downloaded a backend php script(which is most likely not the case here).

mcduck
July 23rd, 2009, 05:12 PM
Thanks!
Will an Apache server with PHP take a lot of space on my laptop?
Is it possible to save a webpage written in PHP as HTML file?

no, it's rather small size.

And every time you access the page you are actually downloading HTML file (generated by the server based on the PHP file).

credobyte
July 23rd, 2009, 05:31 PM
PHP is ~ 10Mb in size ( not to mention Apache - only a few megabytes ).
Instead of installing the whole LAMP package ( which includes MySQL, etc. ), try installing only Apache and PHP :

sudo apt-get install apache2 php5 libapache2-mod-php5
Then, place your PHP file into /var/www/ and you are ready to go ( http://localhost/index.php ) :)