|
|
|
|
|
|
| |
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. |
|
- 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.
- Put this file somewhere logical, like /usr/local/ or /opt/ or...wherever.
- gunzip or uncompress the file, so that you're left with the *.tar file.
- type this to un-tar the file into a directory called apache_1.3.12: tar -xvf apache_1.3.12.tar
- cd into /usr/local/apache_1.3.12 (or wherever you put it)
- 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: |
|
- In httpd.conf, find a line starting with ServerAdmin, and change it to real values, such as ServerAdmin joe@schmo.com
- 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... |
|
- Go to http://www.php.net/, go to the "Downloads" area, and select the link for the source files.
- Put this file somewhere logical, like /usr/local/ or /opt/ or...wherever.
- gunzip or uncompress the file, so that you're left with the *.tar file.
- type this to un-tar the file into a directory called php-4.0.0: tar -xvf php-4.0.0
- cd into /usr/local/php-4.0.0 (or wherever you put it)
- 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
- The configuration script will do its thing, then put you back at the prompt. If you had no fatal errors, type: make
- A lot of things will happen, hopefully without fatal errors. When you're back at the prompt, type: make install
- 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:
|
|
 |
|
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: |
| |
|
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 | | | 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 | | | 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 | | | Making Sense Of PHP Errors Categories : PHP, Errors and Logging | | | PHP 101 Part 5 of 15 : Rank And File Categories : PHP, Beginner Guides, Filesystem | | | Writing Your Own Template Caching Class In PHP Categories : PHP, Cache, Templates | | | Who's Linking? Categories : PHP, Beginner Guides, To PHP | | | Building a Counter Categories : PHP, Cookies | | | PHP for Beginners by a Beginner: Simple Login, Logout, and Session Handling Categories : PHP, Sessions, Authentication | | | 10 PHP Functions I Bet You Didn`t Know About Categories : PHP, PHP Functions, Filesystem, Arrays, Errors and Logging | | | Sending Form Data in EMail Categories : PHP, Email, HTML and PHP | | | Object Oriented Programming in PHP Categories : PHP, Object Oriented | |
| | | 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.
| |
|
|
|