• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

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.
0
chenwei
Asked:
chenwei
  • 30
  • 24
  • 2
  • +3
1 Solution
 
us111Commented:
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
 
jasmoft146Commented:
Also php supports personal web server!
0
 
jayyCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
us111Commented:
yep
0
 
maxkirCommented:
 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
 
chenweiAuthor Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
If you have any further questions, don't hesitate to ask

David
0
 
chenweiAuthor Commented:
Thanks. I will come back again as son as possible.
0
 
chenweiAuthor Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
Open the httpd.conf file and add the 4 directives in it
don't forget to restart Apache
0
 
chenweiAuthor Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
jayyCommented:
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
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
"... /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
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
send me your httpd.conf file at rtom@free.fr
I will check, it may be more easier
0
 
chenweiAuthor Commented:
I've sent the file to you. Please check your email box.
0
 
us111Commented:
I've got it
0
 
chenweiAuthor Commented:
I've sent the file to you. Please check your email box.
0
 
us111Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
Or should I install both php3 and apache under the same hard-disk, either C or D?
0
 
chenweiAuthor Commented:
Or should I install both php3 and apache under the same hard-disk, either C or D?
0
 
us111Commented:
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
 
us111Commented:
I think remove php and Apache and install them under:
d:\programe\apache group\apache\ (by default)
and
d:\php3
0
 
us111Commented:
do you have an ICQ number ?
0
 
us111Commented:
do you have an ICQ number ?
0
 
chenweiAuthor Commented:
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
 
hkthomasCommented:
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
 
us111Commented:
yep his php.ini has : short_open_tag  =       On  
0
 
chenweiAuthor Commented:
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
 
us111Commented:
try to replace
ScriptAlias /php3/ "d:/php3/"
by
ScriptAlias /php3/ "d:\php3\"
or
ScriptAlias /php3/ "d:\php3"
0
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
yes "/" for unix and "\" fo windows

yes in the php.ini replace all / by \
0
 
chenweiAuthor Commented:
Would you mind sending me your "hp3.ini" and "httpd.conf" to me?
chenwei97@yahoo.com
0
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
Should I install the winsock32?
0
 
chenweiAuthor Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
ah  non sp4 is service pack 4
0
 
chenweiAuthor Commented:
Don't you have any idea for me, genius?  :-)
0
 
us111Commented:
Did you install service pack 5 ?
Does it work now ??
0
 
chenweiAuthor Commented:
I've installed sp5. But it doesn't work jet. :(
0
 
us111Commented:
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
 
chenweiAuthor Commented:
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
 
chenweiAuthor Commented:
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
 
us111Commented:
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
 
chenweiAuthor Commented:
Thanks a lot!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 30
  • 24
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now