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
  •  


Dell Poweredge R730xd 3.5 2x E5-2690 v3 2.6ghz 64gb H730 14x Trays 2x 1100w picture

Dell Poweredge R730xd 3.5 2x E5-2690 v3 2.6ghz 64gb H730 14x Trays 2x 1100w

$489.99



Dell PowerEdge R620 Server 2x E5-2660 v2 2.2GHz 20 Cores 256GB RAM 1x 480GB SSD picture

Dell PowerEdge R620 Server 2x E5-2660 v2 2.2GHz 20 Cores 256GB RAM 1x 480GB SSD

$139.99



Dell PowerEdge R620 Server - 256GB RAM, 2x8cCPU, 120Gb SSD/3x900Gb SAS, Proxmox picture

Dell PowerEdge R620 Server - 256GB RAM, 2x8cCPU, 120Gb SSD/3x900Gb SAS, Proxmox

$320.00



R630 DELL 8 x 2.5'' POWEREDGE 2X E5-2680V4 32GB RAM IDRAC ENT & NDC 2X 495W PSU picture

R630 DELL 8 x 2.5'' POWEREDGE 2X E5-2680V4 32GB RAM IDRAC ENT & NDC 2X 495W PSU

$169.95



R630 DELL OEM 10X2.5'' 2X E5-2660V3 32GB RAM 2X750W PSU SERVER POWEREDGE picture

R630 DELL OEM 10X2.5'' 2X E5-2660V3 32GB RAM 2X750W PSU SERVER POWEREDGE

$159.95



Dell PowerEdge R730xd 12LFF 2xE5-2660v4=28Core 64/128GB 6x 2TB/4TB Flex 1.2TB HD picture

Dell PowerEdge R730xd 12LFF 2xE5-2660v4=28Core 64/128GB 6x 2TB/4TB Flex 1.2TB HD

$379.99



Dell PowerEdge (072WKY) Boss Card With 2x 240gb SSDs picture

Dell PowerEdge (072WKY) Boss Card With 2x 240gb SSDs

$115.00



Dell PowerEdge R630 Server 2x E5-2640 V4= 20 Cores | S130 | 32GB RAM | 480GB SSD picture

Dell PowerEdge R630 Server 2x E5-2640 V4= 20 Cores | S130 | 32GB RAM | 480GB SSD

$310.99



Dell Poweredge R620 8-Bay 2x E5-2695v2 2.4ghz 24-Cores  512gb   H710p  8x Trays picture

Dell Poweredge R620 8-Bay 2x E5-2695v2 2.4ghz 24-Cores 512gb H710p 8x Trays

$349.99



Dell Desktop Quad Core i5 8400 500GB SSD + 2TB HDD 32GB RAM Window Server 2022 picture

Dell Desktop Quad Core i5 8400 500GB SSD + 2TB HDD 32GB RAM Window Server 2022

$320.99