WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this Article to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES SUBMIT AN ARTICLE PRINT
Title : Setup and Install Apache with PHP4 as a Dynamic Module (DSO)
Categories : PHP, PHP Configuration, Apache Picture not available
Meloni Julie
Date : 2000-06-17
Grade : 0 of 5 (graded 0 times)
Viewed : 10718
Search : More Articles by Meloni Julie
Action : Grade This Article
Tools : My Favotite Articles


Submit your own code examples 
 


First things first - what's a dynamic module? Basically, when you create PHP as a dynamic module for Apache, you're creating an element that you can upgrade/recompile and use, without recompiling your Web server, too. When PHP (or something else) is a static module, that means its compiled in a big lump into Apache; if you needed to add some functionality to PHP, you would have to re-build PHP and then re-build Apache so that all of the changes took effect. With PHP as a dynamic module, you're telling Apache to go load that module when it's started; if the PHP module changes, Apache never really knows or cares - as long as it can, at startup, load the module.



For instance, take the PHP configuration for this tutorial: it'll enable just MySQL support. Say a week from now I want to add mcrypt and mhash support, maybe ftp support and image creation functions. All I'd need to do is re-compile PHP using a new configuration. The installation procedure will dump a new Apache module into the proper place, and Apache will just need to be restarted, not recompiled! Very handy.



So, on to this fresh installation process, starting with Apache.



  1. Go to http://www.apache.org/dist/ and grab the latest version of the source code (a *.tar.Z or *.tar.gz file). Currently, it's version 1.3.12.
  2. Put this file somewhere logical, like /usr/local/ or /opt/ or...wherever.
  3. gunzip or uncompress the file, so that you're left with the *.tar file.
  4. type this to un-tar the file into a directory called apache_1.3.12: tar -xvf apache_1.3.12.tar
  5. cd into /usr/local/apache_1.3.12 (or wherever you put it)
  6. type the following to prepare for building:




During the installation process, a default set of configuration files will be placed in the "conf" directory, under the installation directory (i.e. "/usr/local/apache_1.3.12/conf/" or some such). Time to make just a few minor housekeeping modifications:



  1. In httpd.conf, find a line starting with ServerAdmin, and change it to real values, such as ServerAdmin joe@schmo.com
  2. Next, find a line starting with ServerName, and change it to real values, such as ServerName localhost

    Or, if you have a real machine name, like gambit.yourdomain.com, go ahead and use it.


Save the file, then go back up a directory (cd ..) and type the following:



./bin/apachectl start

Hopefully, Apache will start. I'll assume it did. Type http://127.0.0.1/ or http://localhost/ to see the default installation page, containing links to the Apache web site and the Apache manual. If your installation fails at any point, read the Apache documentation and the Apache FAQ to attempt to pinpoint your problem, then try again.



Now let's get PHP4 hooked in there...



  1. Go to http://www.php.net/, go to the "Downloads" area, and select the link for the source files.
  2. Put this file somewhere logical, like /usr/local/ or /opt/ or...wherever.
  3. gunzip or uncompress the file, so that you're left with the *.tar file.
  4. type this to un-tar the file into a directory called php-4.0.0: tar -xvf php-4.0.0
  5. cd into /usr/local/php-4.0.0 (or wherever you put it)
  6. type the following to prepare for building:

    ./configure --with-mysql=/[path to mysql] --with-apxs=/[path to apxs]

    Replace "[path to mysql]" with your own path, such as /usr/local/mysql

    Replace "[path to apxs]" with your own path, such as /usr/local/apache_1.3.12/bin/apxs

  7. The configuration script will do its thing, then put you back at the prompt. If you had no fatal errors, type: make
  8. A lot of things will happen, hopefully without fatal errors. When you're back at the prompt, type: make install
  9. Again, lots of things will happen, and at the end of it all, the PHP installation process will have dumped a module into the proper place in the Apache directory structure, and made some modifications to the httpd.conf file.

Let's go make one more modification to the Apache configuration files, and run a vanilla version of Apache + PHP4. Using a text editor, open the httpd.conf file again. We need to tell Apache what to do with *.php or *.phtml files.



Find a section that looks like the following (This is the area where you say "for all files ending with [whatever], consider them to be of [whatever] type."):


# And for PHP 4.x, use:
#
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps


Just take away the "#" before the two AdType lines, and add ".phtml" on the line with ".php". If you want to create your own file extension for PHP files, like .joe (really, you can...), add .joe after the .php and .phtml in the first AddType line.



Alrighty then...save that file, and go up a directory (cd ..). Let's try to start Apache again. If it's still running, type this:



./bin/apachectl restart

Or, if it's not still running, type:

./bin/apachectl start

Provided there are no issues on startup, let's test that installation. Open a text editor and type this:

<? phpinfo() ?>

Save this file as phpinfo.php, and put it in the document root of Apache (in the htdocs directory within your installation directory.).

Fire up your Web browser and go to http://localhost/phpinfo.php -- you should see a page that starts out like this:



PHP info




If you don't, then something has gone awry, and let me know.



So what is all this stuff? It's "info"...and a ton of it! The phpinfo() function produces this page that shows you what sorts of things are installed, your environment, your settings, and so on.



A lot of configuration options can be controlled by modifying the php.ini file, usually located in /usr/local/lib (the phpinfo() results will tell you the path). Take a gander through it, and be aware that while you can turn anything on and off to your heart's content, I rarely do, so don't fell like you're missing something if you don't ever touch it.



Given the large amount of things you can compile-in to PHP at build-time, sometime go back to your PHP installation directory and type this:


./configure --help


This will give you a list of all of the configuration options available to you. Feel free to re-configure and re-build the PHP DSO as many times as you want. Try adding things..then taking things away until you find the perfect combination. Follow the instructions in the configuration section of the PHP Manual to make sure that your configuration option paths are pointing to the right place. If you have issues, send a messages to one of the mailing lists -- people are there to help you. Remember, you don't have to re-compile Apache, just restart it!



That's really all there is to it; if anything blows up in your face or doesn't match what I've said, just let me know -- this has all worked for me about a zillion times now, but everybody's machine is different, especially in the Linux/Unix world, with slightly different flavors of operating systems and compilers.









Setup and Install Apache and PHP4 on Windows
Categories : PHP, PHP Configuration, Apache, Windows 2000
Custom Error Messages When Using $PHP_SELF as Form Action
Categories : PHP, PHP Configuration
Apache, PHP, and PostgreSQL on RedHat Linux
Categories : Apache, PHP, Databases, PostgreSQL, Linux
How TO Install PHP, Apache and MySQL on Linux or Unix
Categories : PHP, MySQL, Apache, Installation, Beginner Guides
User Authentication With Apache and PHP
Categories : PHP, Web Servers, Apache, Authentication
Installing Apache Web Server and PHP 4 on Linux
Categories : PHP, Web Browsers, Apache, Linux
Saving Images in MySQL
Categories : MySQL, PHP, Graphics, Databases
Protecting PHP Scripts with HTTP Authorization
Categories : PHP, HTTP, Security, Authentication
Honey, I Shrunk My Website
Categories : PHP, PHP options/info, Site Planning, Other
PHP 101 Part 8 of 15 : Databases and Other Animals
Categories : PHP, Beginner Guides, Databases
Simple PHP Templates With PatTemplate
Categories : PHP, Templates
Authentication 101
Categories : Apache, Web Servers, Authentication
Simple Connection to Oracle with PHP
Categories : PHP, Oracle, Databases
Making PHP Forms Object-Oriented
Categories : PHP, HTML and PHP, Object Oriented
Introduction to using PHP 5.0 and SQLite
Categories : PHP, SQLite, Databases
Anonymous wrote : 162
I don`t understand what should happen after step 6 in the
Apache setup. Could something be missing ?
Any help is appreciated.

Thanx
Anonymous wrote : 269
What is the ./configure command for apache?
Anonymous wrote : 298
But with informix and odbc ... Sorry but I`m portuguese.