Results 1 to 9 of 9

Thread: coding php on knoppix

  1. #1
    Junior Member
    Join Date
    Jun 2005
    Posts
    6

    coding php on knoppix

    I am having trouble coding php on the knoppix live cd distro. I tried to wirte a simple php server progrm and got an error in the first line......(ie <?) saying no such file or directory. Is there some type of set up procedure that need to be done before programming php. Where do you program the php.....console? I have tried to follow some online instructions but I keep getting the error root permmissions denied...what does this mean and how do I fix it?

  2. #2
    Senior Member registered user
    Join Date
    Apr 2005
    Location
    italy
    Posts
    245
    This would be the right way to code php:
    -open root terminal and type apache to run apache
    -cd in /var/www and put in it your file.php
    -open web browser and adress to http://127.0.0.1/file.php

    have fun and let me know

  3. #3

  4. #4
    Junior Member
    Join Date
    Jun 2005
    Posts
    6
    I got appache running an got into the www directory. How do I put my .php file into that directory. Also, I dont have internet access on the pc that I am running knoppix. How can I run my code from the console? Would I be able to address from another pc using the ip address of the computer running knoppix instead of using 127.0.0.1? Also what do I need to add to the beginning of my code. #!/usr/bin/php, #!/bin/bash, etc.......What is the syntax that needs to be added to the code?

  5. #5
    Junior Member
    Join Date
    Jun 2005
    Posts
    6
    Also, do I have to be logged in as root....if so how exaclty do I do this?

  6. #6
    Senior Member registered user
    Join Date
    Apr 2005
    Location
    italy
    Posts
    245
    Once in /var/www with a simple text editor create this test file test.php:
    <?php
    phpinfo();
    ?>

    Then open an your choice browser and adress to: http://127.0.0.1/test.php
    You would see a long list of php parameters.
    127.0.0.1 is a a conventional standardized localhost ip address to referr to your current working machine and no to other networked machines (seems to me).

    >Also what do I need to add to the beginning of my code. #!/usr/bin/php, #!/bin/bash, etc.......What is the syntax that needs to be added to the code?
    Do you have this kind of dubts? It's look like you need a good online simple php tutorial, I will suggest this one to you:
    http://www.w3schools.com/php/default.asp

    bye, max

  7. #7
    Junior Member
    Join Date
    Jun 2005
    Posts
    6
    I used the following command:

    $ sudo cat > /var/www/PHPServer1.php
    <?php phpinfo(); ?>

    $ lynx http://127.0.0.1/PHPServer1.php
    and got the following errors:

    Warning: Unknown (/UNIOFS/var/www/PHPServer1.php):failed to open stream. Permission denied in unknown line 0

    Warning: (null)(): Failed opening '/UNIOFS/var/www/PHPServer1.php' for inclusion (include_path = '.:/usr/share/php : /usr/share/peak) in unknown on line 0

    I do not have internet access on the computer that I am running linux on. Do I need to get that? Is it possible to access it from a computer with internet access. Also here is the code that I am using in the mean time:

    <?
    while (1);
    //Attempt to read string from socket
    //For now let's pretend it's been read successfully
    //and is called "stuff"
    $stuff = "1,2.2,3.245,.546";

    if ($stuff != "") {
    $array_of_stuff = explode(',', $stuff); //Now it's an array
    //Display them:
    print ($array_of_stuff[0]);
    print ($array_of_stuff[1]);
    print ($array_of_stuff[2]);
    print ($array_of_stuff[3]);
    $stuff = "";
    }
    ?>


    As you can see I just defined a fixed string. What do I need to change in my code so that it accepts the dynamically changing string passed from my client as opposed to this "dummy" string that I have made up?

  8. #8
    Senior Member registered user
    Join Date
    Aug 2003
    Posts
    126
    Also, do I have to be logged in as root....if so how exaclty do I do this?
    To do this as the default user knoppix open a knoppix terminal window (console). This should give you
    knoppix@tty0[knoppix]#
    Then type
    su followed by [enter]
    There is no password required.
    The terminal should change to
    root@tty0[knoppix]#
    You are now logged in as root and can issue commands and run programs as root.

    I find writing php code in a text editor works for me.
    At the root prompt type
    nedit followed by [enter]
    Then, as previously suggested write
    Code:
    <?php phpinfo(); ?>
    and save the file in the /var/www directory as suggested by MaxIT.
    Then visit the file with a browser as he also suggests.
    Once this works you can then test out perl and bash scripts.
    Use whatever text editor you prefer out of those available (nedit, kate, kwrite, emacs and vim).
    Create a file as root with the following.
    Code:
    #!/bin/bash
    
    printf "Content-type:text/html\r\n\r\n";
    printf "<html>hello world</html>\r\n";
    This bash script should be saved as hello.cgi and saved in the /usr/lib/cgi-bin directory.
    It also needs to be made executable for all users:
    At the root prompt type
    chmod 755 /usr/lib/cgi-bin/hello.cgi
    Then visit the file with a browser e.g. mozilla
    http://127.0.0.1/cgi-bin/hello.cgi

    Once this works you can do the same for perl. This time saving the file as hello.pl
    and using the following code:
    Code:
    #!/usr/bin/perl
    
    print "Content-type:text/html\n\n";
    print "<html>hello world</html>\n";
    Once you have got these three programs going then you have a wide choice to start open source web programming under Knoppix Debian/Gnu/Linux.
    Regards,
    Mark

  9. #9
    Senior Member registered user
    Join Date
    Apr 2005
    Location
    italy
    Posts
    245
    >Warning: Unknown (/UNIOFS/var/www/PHPServer1.php):failed to open stream. Permission denied in unknown line 0

    >Warning: (null)(): Failed opening '/UNIOFS/var/www/PHPServer1.php' for inclusion (include_path = '.:/usr/share/php : /usr/share/peak) in unknown on line 0

    This would be appen maybe because of the default permission assigned to new created file only read/write (not execute), so give your file full permissions in this way : chmod 777 PHPServer1.php

    bye, max

Similar Threads

  1. How to begin coding a server in knoppix
    By mrobertson in forum General Support
    Replies: 0
    Last Post: 06-01-2005, 01:40 PM
  2. Replies: 1
    Last Post: 10-13-2004, 11:06 PM
  3. coding/programing links
    By Jared in forum The Lounge
    Replies: 6
    Last Post: 05-25-2004, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Extron RGB-160XI Analog Computer Video 60-378-01 picture

Extron RGB-160XI Analog Computer Video 60-378-01

$187.06



The analog thing modern open source, educational, low-cost analog computer picture

The analog thing modern open source, educational, low-cost analog computer

$800.00



NEW Aquarius+ Mini 8Bit Retro Computer System - Assembled PCB ONLY picture

NEW Aquarius+ Mini 8Bit Retro Computer System - Assembled PCB ONLY

$99.00



IBM Modem Saver Phone Line Tester picture

IBM Modem Saver Phone Line Tester

$7.99



FULLY RECAPPED MACINTOSH CLASSIC II 2 VINTAGE MAC APPLE COMPUTER NEW BATT WORKS picture

FULLY RECAPPED MACINTOSH CLASSIC II 2 VINTAGE MAC APPLE COMPUTER NEW BATT WORKS

$899.00



Apple Macintosh SE Completely Recapped #M5011 4Mbyte RAM, 800K Drive, 20MB HD picture

Apple Macintosh SE Completely Recapped #M5011 4Mbyte RAM, 800K Drive, 20MB HD

$500.00



Landen Computer. Circa 1898. the Rapid Computer Company.  With Original Case. picture

Landen Computer. Circa 1898. the Rapid Computer Company. With Original Case.

$425.00



Apple Macintosh Plus Completely Recapped #M0001A 4MB picture

Apple Macintosh Plus Completely Recapped #M0001A 4MB

$499.00



Macintosh Classic/Classic II Analog Board Computer 630-0395 New picture

Macintosh Classic/Classic II Analog Board Computer 630-0395 New

$278.00



ACASIS PCIE Capture Card HDMI 1.4 1080P60HZ PCIE 2.0 X4 20Gbps for Video Capture picture

ACASIS PCIE Capture Card HDMI 1.4 1080P60HZ PCIE 2.0 X4 20Gbps for Video Capture

$248.99