Solved

How can begin with PhP?

Posted on 2000-03-17
59
267 Views
Last Modified: 2008-03-06
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.
0
Comment
Question by:chenwei
  • 30
  • 24
  • 2
  • +3
59 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2627796
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.
0
 
LVL 1

Expert Comment

by:jasmoft146
ID: 2628532
Also php supports personal web server!
0
 

Expert Comment

by:jayy
ID: 2630456
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...
0
 
LVL 8

Expert Comment

by:us111
ID: 2630999
yep
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2631400
 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
0
 

Author Comment

by:chenwei
ID: 2635826
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2635987
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) ??
0
 

Author Comment

by:chenwei
ID: 2636062
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.
0
 
LVL 8

Expert Comment

by:us111
ID: 2636171
If you have any further questions, don't hesitate to ask

David
0
 

Author Comment

by:chenwei
ID: 2636211
Thanks. I will come back again as son as possible.
0
 

Author Comment

by:chenwei
ID: 2636760
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"
"
0
 
LVL 8

Expert Comment

by:us111
ID: 2636818
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
0
 

Author Comment

by:chenwei
ID: 2639049
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2639240
Open the httpd.conf file and add the 4 directives in it
don't forget to restart Apache
0
 

Author Comment

by:chenwei
ID: 2639337
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2639395
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

 
0
 

Author Comment

by:chenwei
ID: 2639410
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?
0
 

Expert Comment

by:jayy
ID: 2642082
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
0
 

Author Comment

by:chenwei
ID: 2643467
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?
0
 

Author Comment

by:chenwei
ID: 2643477
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.
0
 
LVL 8

Expert Comment

by:us111
ID: 2643563
"... /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
0
 

Author Comment

by:chenwei
ID: 2643625
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?
0
 

Author Comment

by:chenwei
ID: 2643638
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2643733
send me your httpd.conf file at rtom@free.fr
I will check, it may be more easier
0
 

Author Comment

by:chenwei
ID: 2643811
I've sent the file to you. Please check your email box.
0
 
LVL 8

Expert Comment

by:us111
ID: 2643837
I've got it
0
 

Author Comment

by:chenwei
ID: 2643841
I've sent the file to you. Please check your email box.
0
 
LVL 8

Expert Comment

by:us111
ID: 2643876
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
0
 
LVL 8

Expert Comment

by:us111
ID: 2643920
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
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:chenwei
ID: 2643923
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?
0
 

Author Comment

by:chenwei
ID: 2643928
Or should I install both php3 and apache under the same hard-disk, either C or D?
0
 

Author Comment

by:chenwei
ID: 2643935
Or should I install both php3 and apache under the same hard-disk, either C or D?
0
 
LVL 8

Expert Comment

by:us111
ID: 2643960
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
0
 
LVL 8

Expert Comment

by:us111
ID: 2643972
I think remove php and Apache and install them under:
d:\programe\apache group\apache\ (by default)
and
d:\php3
0
 
LVL 8

Expert Comment

by:us111
ID: 2643974
do you have an ICQ number ?
0
 
LVL 8

Expert Comment

by:us111
ID: 2643984
do you have an ICQ number ?
0
 

Author Comment

by:chenwei
ID: 2644059
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.
0
 

Expert Comment

by:hkthomas
ID: 2646080
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 ..
0
 
LVL 8

Expert Comment

by:us111
ID: 2648031
yep his php.ini has : short_open_tag  =       On  
0
 

Author Comment

by:chenwei
ID: 2648599
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.
0
 
LVL 8

Expert Comment

by:us111
ID: 2648664
try to replace
ScriptAlias /php3/ "d:/php3/"
by
ScriptAlias /php3/ "d:\php3\"
or
ScriptAlias /php3/ "d:\php3"
0
 

Author Comment

by:chenwei
ID: 2648838
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.
0
 

Author Comment

by:chenwei
ID: 2648865
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2649035
yes "/" for unix and "\" fo windows

yes in the php.ini replace all / by \
0
 

Author Comment

by:chenwei
ID: 2649117
Would you mind sending me your "hp3.ini" and "httpd.conf" to me?
chenwei97@yahoo.com
0
 

Author Comment

by:chenwei
ID: 2649394
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.
0
 

Author Comment

by:chenwei
ID: 2649402
Should I install the winsock32?
0
 

Author Comment

by:chenwei
ID: 2652775
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2652838
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.
0
 

Author Comment

by:chenwei
ID: 2652982
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?
0
 
LVL 8

Expert Comment

by:us111
ID: 2653106
ah  non sp4 is service pack 4
0
 

Author Comment

by:chenwei
ID: 2653305
Don't you have any idea for me, genius?  :-)
0
 
LVL 8

Expert Comment

by:us111
ID: 2653372
Did you install service pack 5 ?
Does it work now ??
0
 

Author Comment

by:chenwei
ID: 2653437
I've installed sp5. But it doesn't work jet. :(
0
 
LVL 8

Expert Comment

by:us111
ID: 2656453
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 :(
0
 

Author Comment

by:chenwei
ID: 2656920
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.

0
 

Author Comment

by:chenwei
ID: 2675536
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.

0
 
LVL 8

Accepted Solution

by:
us111 earned 50 total points
ID: 2675798
I think I locked the question last week but expert-exchange had a problem last week.

Now I'm gonna lock the question :))
Otherwise; try to install service Pack 4 before 5 or 6

0
 

Author Comment

by:chenwei
ID: 2676422
Thanks a lot!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now