Configure the environment
Operating System: RedHat Enterprise as 4
Installed packages: httpd2.0.4, mysql4.1, libxml2.6.16, zlib1.2.1.2, gd2.0.28, libpng1.2.7
Note: Various installation instructions on the Internet do not provide a good description of the reason for configuring parameters. This article will try to indicate the necessity of each step. the installation package is not required. MySQL can be installed independently, while httpd in RPM package form is not installed in mod-So form. If you want to support PHP or other modules, force remove to reinstall the encoding version. # rpm -- nodeps -- Erase httpd
Functions of other modules required by PHP:
Libxml2: XML Parsing Library
Zlib: open-source compression library
GD: Graphics Library
Libpng: library used to process PNG image format files
FreeType: TrueType font Drawing Engine
Zendoptimizer:
JPEG Library:
Download the MySQL, Apache, and PHP files. Download the corresponding software at the following URL.
Http://www.apache.org
Http://www.php.net
Http://www.mysql.com
Step 1: install Apache
Go to the installation directory and execute the following commands in sequence:
Decompress the source package
# Tar-zxf httpd-2.0.55.tar.gz
Go to the installation directory
# Cd httpd-2.0.55
Configure the Apache installation information, configure the directory after installation, and dynamically configure the module. You can rewrite the configuration again.
#./Configure -- prefix =/usr/local/Apache -- enable-modules = so -- enable-Rewrite
Execute make to install
# Make; make install
Step 2: Configure Apache
Modify the httpd. conf file
// Modify the host name in servername. If no DNS exists, replace it with an IP address.
Servername 192.168.36.163: 80
// Modify the document path of DocumentRoot, which is the place where the target webpage is to be placed.
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
// Modify the default homepage name using directoryindex
Directoryindex index.html index. php index.htm
Step 3: install PHP
Go to the installation directory and execute the following commands in sequence:
Decompress the source package
# Tar-zxf php-5.0.5.tar.gz
Go to the installation directory
# Cd php-5.05
Configure the PHP installation information, configure the directory after installation, and dynamically configure the module, allowing Reconfiguration
#. /Configure -- prefix =/usr/local/PHP -- with-apxs2 =/usr/local/Apache/bin/apxs -- With-mysql =/usr/local/MySQL/-- With-curl =/usr/local/curl -- enable-FTP -- With-libxml-Dir =/usr/local/libxml2 -- With-expat-Dir =/usr/lib -- enable-soap -- with-XSL =/usr/local/libxslt -- enable-XSLT -- With-Gd =/usr/local/GD2/-- With-JPEG-Dir =/usr/local/defaults 6/ -- With-zlib-Dir =/usr/lib -- With-PNG -- With-FreeType-Dir =/usr/local/FreeType -- enable-mbstring
The./configure
-- Prefix =/usr/local/PHP
-- With-apxs2 =/usr/local/Apache/bin/apxs
-- With-mysql =/usr/local/MySQL/
-- With-libxml-Dir
-- Enable-mbstring
Is a required Option
-- With-Gd =/usr/local/GD2/
-- With-JPEG-Dir =/usr/local/defaults 6/
-- With-PNG
-- With-zlib-Dir =/usr/lib
-- With-FreeType-Dir =/usr/local/FreeType
This is the configuration option for PHP to support the GD library
Execute make to install
# Make; make install
Step 4: Configure httpd. conf to enable Apache to support PHP
# Vi/usr/local/Apache/CONF/httpd. conf
After PHP is installed, the following line is automatically added to httpd. conf (if not, add it manually ):
Loadmodule php5_module modules/libphp5.so
Find addtype application/X-gzip. GZ. tgz and add the following content under it:
Addtype application/X-httpd-PHP. php
Addtype application/X-httpd-PHP-source. PHPs
Restart Apache
#/Usr/local/Apache/bin/apachectl restart
Appendix: important configuration options of Apache
1 directory
<Directory/>
Options followsymlinks
AllowOverride none
Order deny, allow # indicates that Denny is executed before allow.
Allow from all # Allow access from all addresses, where you can set access permissions for specific IP addresses
</Directory>
2 ScriptAlias/cgi-bin/"/var/www/cgi-bin/" # script path
3 redirects (HTTP return status code)
Errordocument 500 "the server made a boo ."
Errordocument 404/missing.html
Errordocument 404 "/cgi-bin/missing_handler.pl"
Errordocument 402 http://www.example.com/subscription_info.html
References:
Http://blog.csdn.net/shfabjc/archive/2007/07/03/1676375.aspx