Link to home
Start Free TrialLog in
Avatar of chenwei
chenwei

asked on

How can begin with PhP?

I am a beginer and going to learn PHP. I have the following questions:
1.
What I need for using PHP? I've heard I need apache as well. If yes, what's apache?
2.
Should I be a server? I've heard the PHP is a server-side language.
3.
Is it difficult to install the PHP (apache as well if needed)? I've heard it's not so easy to install the PHP.
Avatar of us111
us111
Flag of Luxembourg image

1. You need a web server (Apache), last version 1.3.12 www.apache.org

2. you need to be a server.
Download the Apache and PHP (www.php.net) source, follow the installation documentation. Php is a server side language, the html page which contains the Php code is 'interpreted by the web server' and send to your browser.

3. it's really easy to install PHP (more easier on NT than Unix). Just follow the installation file.
For unix, you can install the linux RedHat or Mandrake, mysql, php and Apache are in this distribution.
Avatar of jasmoft146
jasmoft146

Also php supports personal web server!
If you get stuck installing check out the question us111 and I have just sorted out...Called PHP3 Installation/Configuration...This will tell you how to get it up and running for developing your scripts...
yep
 Everything was said.
  IMO, first aim for you is not to study PHP language, but study web-scritping ideas et all. First, just setup web server (Apache or
OmniHTTPD or Personal web server for Win 32 platform). Study, how
it works. What is CGI, SSI. How it works. IMO only after that you can go with PHP with better understandind what is it and how you can use it.
good luck,
maxkir
Avatar of chenwei

ASKER

To us111:

I am not a server. I just want to learn php at home. If I've installed the apache, can I be the server?
yep, when you install Apache, your computer will be a web server.
And then it's really easy to learn PHP :)) Do you use unix or Windows at home (windows I think) ??
Avatar of chenwei

ASKER

YOu guess right. I use Winodws at home. I am going to install the apache and php now. When I am succedded, I will come back and locate the points.
If you have any further questions, don't hesitate to ask

David
Avatar of chenwei

ASKER

Thanks. I will come back again as son as possible.
Avatar of chenwei

ASKER

I've read the "Installation on Windows 95/98/NT systems" by http://www.php.net/manual/html/install-windows95-nt.html. But I can't understand what the following mean. I mean which file I should edit.
"
Windows 9x/NT and Apache 1.3.x

You must edit your srm.conf or httpd.conf to configure Apache to work with the PHP CGI binary.

Although there can be a few variations of configuring PHP under Apache, this one is simple enough to be used by the newcomer. Please consult the Apache Docs
for further configuration directives.

     ScriptAlias /php3/ "c:/path-to-php-dir/"

     AddType application/x-httpd-php3 .php3

     AddType application/x-httpd-php3 .phtml

     Action application/x-httpd-php3 "/php3/php.exe"
"
ok
I if you have followed the Default Apache Installation,
- go to c:\program files\Apache Group\Apache\conf folder
- edit the srm.conf file

you must replace c:/path-to-php-dir/ by the directory where php has been
installed

ScriptAlias /php3/ "c:/path-to-php-dir/"

AddType application/x-httpd-php3 .php3

AddType application/x-httpd-php3 .phtml

Action application/x-httpd-php3 "/php3/php.exe"

- restart Apache
Avatar of chenwei

ASKER

To us111:

But as I opened the file "srm.conf", it has nothing but just a few lines of comment as follow:
"
#
# This is the default file for the ResourceConfig directive in httpd.conf.
# It is processed after httpd.conf but before access.conf.
#
# To avoid confusion, it is recommended that you put all of your
# Apache server directives into the httpd.conf file and leave this
# one essentially empty.
#
"

How can I edit the file? Maybe I should edit the "httd.conf" instead?
Open the httpd.conf file and add the 4 directives in it
don't forget to restart Apache
Avatar of chenwei

ASKER

I've add the 4 lines into "httpd.conf" and restarted the apache. But as I opened my html file with simple php3 codes, it is a blank pageand I can see nothing. The source code of my html file is very simple as follow:

myphp.html
"
<html>
<BODY>
<?
  print("Hello World");
?>
</BODY>
</HTML>
"

Why?
if your page is called myphp.html, it doesn't work,
you must call it myphp.php3 or myphp.phtml

You have defined that in the httpd.conf file with these directives:
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml

 
Avatar of chenwei

ASKER

I've add the 4 lines into "httpd.conf" and restarted the apache. But as I opened my html file with simple php3 codes, it is a blank pageand I can see nothing. The source code of my html file is very simple as follow:

myphp.html
"
<html>
<BODY>
<?
  print("Hello World");
?>
</BODY>
</HTML>
"

Why?
Hi chenwei,

Here you go try this

<html>
<body>
<?php

phpinfo();

?>

</body>
</html>

Save the file as sv.php3, and open it in your browser.

There is no problem with your code you just need to change the filename to myphp.php3 all php files need to have the php3 or phtml extension, this way the apache knows that it needs to be processed.
 
....Happy Coding...
jayy
Avatar of chenwei

ASKER

I did what you told me but I can't see anything even though. I don't know what's wrong.

Besides, as I start the apache, a DOS-window is shown and tells:
"... /programs/apache group/apache/logs/httpd.pid overwritten -- unclean shutdown of previous Apache run?
Apache/1.3.11 <Win32> running..."

Is it correct?
Avatar of chenwei

ASKER

I've restarted the computer and started the apache again. Now it shows:"Apache/1.3.11 >Win32> running...".

I think this time the apache is started correctly. But I can't see anything, though.
"... /programs/apache group/apache/logs/httpd.pid overwritten -- unclean shutdown of previous Apache run?

means that the old process of Apache is overwritten. Apache has been previously stopped without the Apache stop command.  It's not an error

you can see anything: have a look at your source code in your browser.
Tell me what you see.

if you see something like the following
<html>
<BODY>
<?
   print("Hello World");
?>
</BODY>
</HTML>
Apache configuration isn't quite good
Avatar of chenwei

ASKER

1.
I restarted the comperter again. As I start the Apache this time, it tells:
"Apache/1.3.11 <Win32> running..."
 I think this time the apache is started correctly.

2.
As I view the source code in my browser, I see the source code as follow:
"
<html>
<BODY>
<?
    print("Hello World");
?>
</BODY>
</HTML>

What's wrong?
Avatar of chenwei

ASKER

1.
I restarted the comperter again. As I start the Apache this time, it tells:
"Apache/1.3.11 <Win32> running..."
 I think this time the apache is started correctly.

2.
As I view the source code in my browser, I see the source code as follow:
"
<html>
<BODY>
<?
    print("Hello World");
?>
</BODY>
</HTML>

What's wrong?
send me your httpd.conf file at rtom@free.fr
I will check, it may be more easier
Avatar of chenwei

ASKER

I've sent the file to you. Please check your email box.
I've got it
Avatar of chenwei

ASKER

I've sent the file to you. Please check your email box.
well, it works for me.
Do you have the good extension for your php file test ?
Do you setup the php.ini file ?

ok, send your php example file, and your php.ini (must be located in c:\windows or c:\winnt) at rtom@free.fr
well, it works for me.
Do you have the good extension for your php file test ?
Do you setup the php.ini file ?

ok, send your php example file, and your php.ini (must be located in c:\windows or c:\winnt) at rtom@free.fr
Avatar of chenwei

ASKER

I've sent two files to you. One is my php example and the other is the "php3.ini".

I have two OS on my computer. One is Windows98, installed in C, and the other is WinNT4, installed in D. I installed the php3 under C and Apache under D. I copy the php3.ini to the D:\winnt.

Is it ok?
Avatar of chenwei

ASKER

Or should I install both php3 and apache under the same hard-disk, either C or D?
Avatar of chenwei

ASKER

Or should I install both php3 and apache under the same hard-disk, either C or D?
I think I've got it
in your php.ini you have
doc_root            =  c:\apache\htdocs      ;
and Apache is installed in d:\programe\Apache Group\Apache
so try to replace
doc_root            =  c:\apache\htdocs      ;
by
doc_root            =  d:\programe\Apache Group\Apachehtdocs      ;

I think the best solution is to install apache and PHP under the same harddisk on winnt (better I guess).
Besides on NT you can install Apache as a service
I think remove php and Apache and install them under:
d:\programe\apache group\apache\ (by default)
and
d:\php3
do you have an ICQ number ?
do you have an ICQ number ?
Avatar of chenwei

ASKER

1.
Thanks for your great help. I will try to reinstall the php under the same hard disk as apache. I will tell you the result tomorrow. I have o take part in a Roadshow of Sun this afternon.

2.
I haven't installed ICQ.

See you later.
Did you check from your php3.ini that :

short_open_tag  =       On      ;

if this is off, you have to use :
<?php ....
or
<script> tags ...

Hope it helps ..
yep his php.ini has : short_open_tag  =       On  
Avatar of chenwei

ASKER

I've re-installed the php3 to hard disc D. But I failed again to see the php3 page.  I would say it's relatively easy to install the Apache but a little bit inconvenient to install the php3.

I didi so:
1.
download the apache and install it to d:\programme. Very simple.
2.
download the php3 1.3.15.
3.
I unzip the php3 package under D:\php3. Unname the php3.ini-dist to php3.ini and copy it to d:\winnt.
4.
I add the following 4 lines to the httpd.conf:
ScriptAlias /php3/ "d:/php3/"
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml
Action application/x-httpd-php3 "/php3/php.exe"
5.
I edit the php3.ini file:
a) extension_dir=    d:\php3;
b) doc_root=d:\programme\apache group\apache\htdocs;

Then I start the apache from Start->Apache Web Server->Start Apache. And I load the .php3 file with the Netscape Browser.

That's all.  But I can't see anything.
try to replace
ScriptAlias /php3/ "d:/php3/"
by
ScriptAlias /php3/ "d:\php3\"
or
ScriptAlias /php3/ "d:\php3"
Avatar of chenwei

ASKER

I've re-installed the php3 to hard disc D. But I failed again to see the php3 page.  I would say it's relatively easy to install the Apache but a little bit inconvenient to install the php3.

I didi so:
1.
download the apache and install it to d:\programme. Very simple.
2.
download the php3 1.3.15.
3.
I unzip the php3 package under D:\php3. Unname the php3.ini-dist to php3.ini and copy it to d:\winnt.
4.
I add the following 4 lines to the httpd.conf:
ScriptAlias /php3/ "d:/php3/"
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3 .phtml
Action application/x-httpd-php3 "/php3/php.exe"
5.
I edit the php3.ini file:
a) extension_dir=    d:\php3;
b) doc_root=d:\programme\apache group\apache\htdocs;

Then I start the apache from Start->Apache Web Server->Start Apache. And I load the .php3 file with the Netscape Browser.

That's all.  But I can't see anything.
Avatar of chenwei

ASKER

I see what you mean since "/" is for unix and "\" for windows. Right? If so, I see there many directories in "httpd.conf" using "/", such as:
ServerRoot "D:/Programme/Apache Group/Apache"

Should I change them as well?
yes "/" for unix and "\" fo windows

yes in the php.ini replace all / by \
Avatar of chenwei

ASKER

Would you mind sending me your "hp3.ini" and "httpd.conf" to me?
chenwei97@yahoo.com
Avatar of chenwei

ASKER

I got your two files. But as I opened your "httpd.conf", I find you use the "/" as well. Why it runs by you but not by me?

Besides, I've change the "/"s to "\"s. But it doesn't run, though.
Avatar of chenwei

ASKER

Should I install the winsock32?
Avatar of chenwei

ASKER

I've downloaded the lates version of apache 1.3.12 and have installed it. But it doesn't run even though.

Besides, I read from the a help file that if I use php on WinNT4, I should install the NT service pack 2. I've installed NT service pack 5. I think the 5 contains 2 already. Right?
yep, service Pack 5 contains service pack 2.
After it should work, it's incredible :))

I have NT 4, sp4, php3, Apache 1.3.12 and it works without any problem :)
Tell me.
Avatar of chenwei

ASKER

I envy you really. I really don't understand why it doesn't wok by me. I've never met such a small thing causing me so much trouble. I have simply no idea. :-)

What's sp4? Do I need it to run php?
ah  non sp4 is service pack 4
Avatar of chenwei

ASKER

Don't you have any idea for me, genius?  :-)
Did you install service pack 5 ?
Does it work now ??
Avatar of chenwei

ASKER

I've installed sp5. But it doesn't work jet. :(
Maybe have a look at php.exe permissions. Apache doesn't have the right permissions to execute php (maybe)

If not, send me your computer :)))

Well I don't think I can find out a solution now :(
Avatar of chenwei

ASKER

Ok, I am going to find a way to send you my computer via email. :)))

By the way, could you please lock the question so I can give you the point? Though my problem isn't solved, you gave me quite a lot of usful help.

Avatar of chenwei

ASKER

Hi us111,

I strongly hope you can lock my question. First I will give you the points since you have given me so much help. Second, if you don't lock my question, I can't give the point and I will be asked to delete my question and this is absolutely what I don't like since I want to let my question in the history so I can read it again later.

Please do me a favour and lock the question.

ASKER CERTIFIED SOLUTION
Avatar of us111
us111
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chenwei

ASKER

Thanks a lot!