Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 24, 2012, 02:45:49 AM

Pages: [1]   Go Down
  Print  
Author Topic: Installing PHP?  (Read 5211 times)
_phin
Newbie
*
Offline Offline

Posts: 1


« on: July 19, 2011, 03:05:11 AM »

Hi there,

This is more of a beginners question than a PHP one, so am posting it here.

I'm a bit of a n00b, so forgive the (maybe) silly question!

I have an index.html file for each page on my site (all are in separate directories, so they can be shown as www.domain.com/blah ) and since I'm using the same navbar for all of them, have created a separate navbar.html file to include, so I only have to make changes to one file.

I've read that the best way of including the latter in the former is by using a PHP include, like this: http://www.apaddedcell.com/how-automatically-include-your-header-navigation-and-footer-every-page

My question is this - do I need to setup or activate PHP in control panel?  I have no idea about PHP, and am kind of winging it.  Tried to search here and google but haven't found a similarly elementary post!

(Alternatively, if there is a better way of doing this then using PHP, eg. HTML5 or CSS, then please feel free to point me in another direction).

Many thanks in advance for your help Smile

Phin
Logged
wektech
Master Jedi
*****
Offline Offline

Posts: 1031



WWW
« Reply #1 on: July 19, 2011, 09:38:56 AM »

PHP is pretty much standard on all servers. You may need to tell older servers to use php5 instead of php4, which is easily done in CPANEL. In order for the server to parse the file as php, you will need to use php as the file extension. Alternately you can use .htaccess to force the server to parse html files as php.
Logged

katrina1
Guest
« Reply #2 on: July 19, 2011, 10:05:15 PM »

PHP is active on all accounts. Our LPCP servers have PHP5 while our Cpanel servers have dual PHP4/5. You can switch between them in Cpanel under PHP Configuration.

After you have done HTML includes once, they are amazingly easy to do. You basically just create a page that has the markup you want to repeat (like a menu) without the head or body tags and call the file .htm. Then you place the include statement in the page(s) you want the code to appear. An include statement looks like this:

<!--#include virtual="somefolder/somefile.htm" -->

Make certain the path is correct in the virtual area for the document you want to appear there. Now, name the page you have the include statement in with the .shtml extension.

If you go the php include route,
1) Create the include file "xxxx.inc", by cutting the html from a page that looks like you want it, and paste it into a new file. ("xxxx" is the name you assign the include file.

2) paste this in the page where you cut the html in step 1:
<?php include("xxxx.inc"); ?>
and rename html page changing the extension to ".php" instead of ".html" This tells the web server to run the page through the php compiler, which processes any php code it finds, and then hands the 100% html page back to the web server to send out to the browser. The ">?php" and "?>? are the tags to indicate to the php compiler to process code. Everything outside those tags is ignored as html to pass on.

3) Repeat step 2 for the rest of your pages (replacing the html material with the include command.

The php include is intended to plug more php code into the calling page (in other words, a "subroutine") but php works by embedding the code in html, and you can embed html in php code. So if there isn't any php code in the include file, the server's php compiler just burps it through, pasting your changable html into the calling page at the position occupied by the php include command(s).

Watch: if the include file isn't in the same directory as every page that calls it, you have to add the path info to the filename in the include command.
Also, note that the include file must end in the ".inc" extension.
Case counts, this is linux file system.
Logged
Jacobdixon
Pong! (the videogame) Master
*****
Offline Offline

Posts: 26


« Reply #3 on: October 31, 2011, 11:23:57 PM »

I am using Wamp server of PHP for its execution its quite easy, you can download it from respected site and install it by following proper instruction which will guide you further to setup php server on your computer.
Logged
whitney01
Trekkie
**
Offline Offline

Posts: 12


« Reply #4 on: November 10, 2011, 02:02:27 AM »

If your server supports PHP you don't need to do anything.

Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.

However, if your server does not support PHP, you must install PHP.

Here is a link to a good tutorial from PHP.net on how to install PHP5: http://www.php.net/manual/en/install.php


__________________________
greek clothes

Logged
doreenmakepeace156
Newbie
*
Offline Offline

Posts: 4


« Reply #5 on: April 30, 2012, 03:40:18 AM »

Yeah, I am currently researching on the net on how to install PHP easily but unfortunately, the sites I've seen are way too complicated. Do you have an easy guide on how to install PHP?

(Spam links removed - Hush)
« Last Edit: April 30, 2012, 03:44:54 AM by Hush » Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5212



« Reply #6 on: April 30, 2012, 07:05:51 AM »

What part of "PHP comes installed and activated on all servers" don't you understand?

On the other hand, if you're actually asking about installing on your own PC (as a sandbox/test site), just install any LAMPP/XAMPP package. It includes a server with PHP built in.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1]   Go Up
  Print  
 
Jump to: