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![]()
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?
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![]()
http://www.knoppix.net/forum/viewtop...105&highlight=
http://www.knoppix.net/forum/viewtop...851&highlight=
http://www.knoppix.net/forum/viewtop...303&highlight=
http://www.knoppix.net/forum/viewtop...375&highlight=
Are a few links that should help you out.
Regards,
Mark
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?
Also, do I have to be logged in as root....if so how exaclty do I do this?
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
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?
To do this as the default user knoppix open a knoppix terminal window (console). This should give youAlso, do I have to be logged in as root....if so how exaclty do I do this?
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
and save the file in the /var/www directory as suggested by MaxIT.Code:<?php phpinfo(); ?>
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.
This bash script should be saved as hello.cgi and saved in the /usr/lib/cgi-bin directory.Code:#!/bin/bash printf "Content-type:text/html\r\n\r\n"; printf "<html>hello world</html>\r\n";
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:
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.Code:#!/usr/bin/perl print "Content-type:text/html\n\n"; print "<html>hello world</html>\n";
Regards,
Mark
>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

GIGABYTE A520M DS3H AC AMD AM4 Motherboard mATX
$59.99
GIGABYTE Z790 AORUS ELITE AX LGA 1700 Intel Z790 ATX Motherboard with DDR5
$189.99
Intel H310 LGA1151 8-9th Gen DDR4 M.2 NVMe mATX Motherboard IO Shield Battery
$54.99
ASUS PRIME Z490-V Motherboard Intel Z490 10th gen DDR4 LGA 1200 ATX w/ IO Shield
$84.99
GIGABYTE B365 HD3 LGA1151 Intel 9th Gen motherboard
$59.99
Intel H81 Motherboard M.2 NVMe LGA 1150 mATX w/ IO Shield (Random Slot Color)
$29.90
ASUS PRIME B360M-C MicroATX Intel LGA1151 DDR4 HDMI VGA USB RJ-45 Audio
$34.99
ASUS PRIME Z370-A II LGA 1151 Intel Z370 DDR4 DIMM USB3.1 DVI ATX RGB
$69.99
ASUS PRIME Z890-P WIFI Z890 LGA 1851 ATX motherboard, Intel® Core™ Ultra Series
$235.99
Dell XPS 8940 Desktop Motherboard Intel H470 LGA1200 DDR4 K3CM7 KV3RP 427JK
$154.99