0

I am new to HTML and PHP.

All I want to do is that I made a HTML file and a PHP file and now I want to test it on my local server i.e. my own computer. My HTML file includes the following code:

<html>
   <head>
      <link rel="stylesheet" href="stylesheet.css" />
      <title>Codecademy Languages</title>
   </head>
   <body>
     <h1>Languages you can learn:</h1>
     <div class="wrapper">
       <ul>
       <?php include 'Test001.php'; ?>
       </ul>
     </div>
   </body>
</html>

and my PHP file named as Test001.php includes the following:

  <?php
      $langs = array("JavaScript",
      "HTML/CSS", "PHP",
      "Python", "Ruby");

      foreach ($langs as $lang) {
          echo "<li>$lang</li>";
      }

      unset($lang);
    ?>

How can I test the whole thing in my web browser? I am using Linux Ubuntu

Many Thanks

Jatin
  • 3,065
  • 6
  • 28
  • 42
user3461530
  • 13
  • 1
  • 2
  • 3
    You need to install apache web server with PHP module :) This must help you https://help.ubuntu.com/community/ApacheMySQLPHP – Itsmeromka Mar 25 '14 at 20:29
  • I have installed it but I am still confused about how can I see my PHP file in the web browser. – user3461530 Mar 25 '14 at 20:37
  • @user3461530 How are you opening the file? – Daedalus Mar 25 '14 at 20:39
  • Just follow the tutorial I found https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts – boreq Mar 25 '14 at 20:41
  • I am just opening the ".html" file in a browser, and when I try to open the ".php" file, it open in a text editor – user3461530 Mar 25 '14 at 20:41
  • This question appears to be off-topic because it is a substitute for reading installation instructions – Ken Mar 25 '14 at 20:49

2 Answers2

1

if you installed apache then go to /var/www directory. create a folder there . then paste your code files there . then open a terminel .. and change the permission of folder. for your local project i suggest to give full permission as you are starter .. command is

chmod 777 -R /var/www/your_folder_name  // use sudo in start if user not root

then open up a browser then go for link ...

localhost/your_folder_name/Test001.php

your must see output for your php file

Fisherman
  • 5,949
  • 1
  • 29
  • 35
  • This one worked perfectly. Thanks. Only another question is that if I have a ".css" file as will so shall i put it in the same folder and run PHP file or there is some other way to test the css? – user3461530 Mar 25 '14 at 20:59
  • no matter where you put it should be in your server i mean public folder and you properly link it to your files – Fisherman Mar 25 '14 at 21:19
0

First you have to install some software, there is a software named "LAMP".

Here you can see the official ubuntu tutorial -> Tutorial click here

What is LAMP? LAMP is a box that contain some little software :

 - Server (apache2) : Entity that discuss with your browser
 - PHP5             : Install the langage
 - MySql            : Install the langage Mysql used to interact with BDD

Second you have to go into your brower and type "localhost" into http:// input.

Third if you want to access to your html file, put it into /var/www directory (in your computer) and access it using http:// input.

Example :

 - Name of the file is '*toto.html*'
 - Type '*localhost/toto.html*' into *http://* input

If you have any questions about that, you are welcome buddy :)

Orelsanpls
  • 22,456
  • 6
  • 42
  • 69