Tutorial: Apache 2.0.49 and PHP 4.3.7!

View Poll Results: Do games effect violence in children/society?

Voters
18. You may not vote on this poll
  • Yes

    1 5.56%
  • No

    17 94.44%
Results 1 to 4 of 4

Thread: Tutorial: Apache 2.0.49 and PHP 4.3.7!

  1. #1
    PHP/PostgreSQL guy
    Join Date
    Dec 2001
    Posts
    1,164

    Tutorial: Apache 2.0.49 and PHP 4.3.7!

    DISCLAIMER: I'm already aware that there are pages on how to install Apache and PHP together, both static binary and dynamic shared-module, but I haven't seen one here so I figured I'd put one out for those looking to get into PHP and web-serving.

    What this covers
    How to install both Apache 2.0.49 and PHP 4.3.7 with optional database configurations.

    What operating system you will need
    You will need to be running a linux distribution of sorts (Redhat, Slackware, Debian ... just to name a few). Anything up-to-date will suffice just fine and it doesn't matter that you probably will only be serving to yourself since this is a tutorial for one to learn.

    What do you mean, serving?
    When you have a service like a web server, an ftp server, a telnet server (ick ick), an ssh daemon, etc...you will need to be able to reach the outside world (internet). Most common ports are 21 for FTP, 22 for SSH, 23 for telnet, 25 for SMTP, and 80 for a web server. Chances are, one's ISP will not allow such serving from the router level however there are certain ways around that that I won't divulge here. For now, being able to see your own web page from your own intranet (not to be confused with internet), you'll be on your way to learn more about serving out.

    What if I already run apache?
    That's great because then you already have an idea of web serving, however, there are steps that have to be taken if you're trying to actually serve out dynamic pages that are based off of PHP. We'll get to that later though.

    Ok, what software do I need to get?
    For now, all you need is Apache 2.0.49 (we're going to work with the Apache 2.0.x release, not 1.3.x) and PHP 4.3.7 (the last major relase of PHP 4).


    Installing:
    You'll have to either use sudo or log in as root (sudo su -, enter password) to do the following.

    APACHE INSTALLATION/CONFIGURATION:
    $ /home/kellert > su -
    root's password entered

    # /root >tar zxvf httpd-2.0.49.tar.gz
    # /root >cd httpd-2.0.49
    # /root/httpd-2.0.49 >./configure --enable-so

    ... configuration goes along here ...

    # /root/httpd-2.0.49 >make
    # /root/httpd-2.0.49 >make install
    The above will install Apache 2.0.49 with the enable-so variable set to enabled into the default directory /usr/local/apache2.

    Continuing on, now for the installation of PHP.

    PHP INSTALLATION/CONFIGURATION:
    # /root/httpd-2.0.49 >cd ..
    # /root >cd php-4.3.7
    # /root/php-4.3.7 >./configure --with-apxs2=/usr/local/apache2/bin/apxs

    ... configuration goes along here ...

    # /root/php-4.3.7 >make
    # /root/php-4.3.7 >make install
    # /root/php-4.3.7 >[b]cp php.ini-dis /usr/local/lib/php.ini
    The above will install PHP 4.3.7 and will be set to run under Apache, using Apache 2's apxs. If you are using a database such as PostgreSQL or mySQL, you would add the option '--with-pgsql' or '--with-mysql' but that's much later on if you're just starting now. With PHP installed into /usr/local/lib/php, you now have the entire package including all of the PEAR structures.

    At this time, you now have Apache 2.0.49 and PHP 4.3.7 installed. Now all you have to do is muck with the httpd.conf configuration file and crank her up!

    # /root/php-4.3.7 >cd /usr/local/apache2/conf
    # /usr/local/apache2/conf >vi httpd.conf

    FIND:
    # LoadModule foo_module module/mod_foo.so
    Enter below:
    LoadModule php4_module modules/libphp4.so
    FIND:
    DirectoryIndex
    Enter wherever you want:
    index.php
    FIND:
    AddType application/x-gzip .gz .tgz
    Enter below:
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    At this point, your httpd.conf should be set up. If you have already changed your httpd.conf because of previous installations, etc, then you will only have to do the above otherwise if you're looking for cgi, virtual hosts, etc, that's a whole other tutorial, hehe.

    All should be good and you should only have to do the following:
    # /usr/local/apache2/conf >../bin/apachectl start
    If it's correct, you'll get nothing and be returned to the command line, otherwise it'll tell you where the errors are.

    To test your new php skillz!
    # /usr/local/apache2/conf >cd ../htdocs
    # /usr/local/apache2/htdocs >vi index.php

    In the above file, index.php, put the following:

    Code:
    <?php
    phpinfo();
    ?>
    If you're successful, you'll be able to see the PHP information page which will display a veritable plethora of information about PHP, how it was configured, the coloring scheme, etc etc and etc.

    At this point, you're ready for some tutorials and some easy programs. I recommend the following sites for php knowledge.

    www.php.net - has everything you need including tutorials and function lookups, etc.

    www.phpfreaks.com - another very good site with forums for everything from installation to advanced work to code snippets to people seeking work, etc.

    I hope this tutorial is helpful and while I'm not very adept at writing them, I did want everyone who's looking for dynamic page content to be able to learn like I did. It's a very easy step to take once you're comfortable with apache and php to get into database management and from there, your journey into real dynamic content has just begun.

    And just a shameless plug for my favorite database: long live PostgreSQL! Hee hee...

    EDIT: if there's anyone else that can offer advice to those learning PHP and Apache, I'd appreciate the input!
    We the willing, led by the unknowing, have been doing the impossible for the ungrateful. We have done so much with so little for so long that we are now qualified to do just about anything with almost nothing.

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255
    A good tutorial for sure, accurate, straight and to the point. One thing I wonder though is whether replicating documentation is really all that warranted?
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  3. #3
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    A useful tutorial, I personally read this one first:

    http://www10.brinkster.com/ssruprai/comphp.asp

    it goes into a lot more detail, but this tutorial is much more to the point.
    Paul Waring - Web site design and development.

  4. #4
    PHP/PostgreSQL guy
    Join Date
    Dec 2001
    Posts
    1,164
    Originally posted here by chsh
    A good tutorial for sure, accurate, straight and to the point. One thing I wonder though is whether replicating documentation is really all that warranted?
    That was the point of the tutorial and it was more based on my own repeated installations of PHP and Apache rather than just a blanket installation tutorial page. This site serves to give more information in easier formats because you can get questions answered in the same forum that you read a tutorial rather than looking on PHP.net's page for a tutorial and then going over to PHP Freaks to get into their boards to see if someone has a similar problem that you're having, etc. Meanwhile, you're still stuck.

    I do agree, it might be considered replicated to a degree, but I'd rather inform based on my own experience based off those tutorials rather than leave a newbie out in the cold to find their own way through a tutorial that may or may not be considered newbie-friendly.

    Future expansion on this tutorial would be simple database manipulation and examples on newly-installed server. I know php.net doesn't have those, hehe...sure, they have links to everywhere, but that's very much akin to porn sites, hehe...
    We the willing, led by the unknowing, have been doing the impossible for the ungrateful. We have done so much with so little for so long that we are now qualified to do just about anything with almost nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •