Linux: install Apache and PHP
1. Apache
Download the source package of Apache for Linux from the following page: http://www.apache.org/dist/httpd/; save it to the/home/XX directory. XX is a self-built folder. I created a WJ folder.
Command list:
CD/home/WJ
Tar-zxvf httpd-2.0.54.tar.gz
Music httpd-2.0.54 Apache
CD Apache
./Configure -- prefix =/usr/local/apache2 -- enable-module = so
Make
Make install
Install Apache to/usr/local/Apache and configure Apache to support DSO
2. php
Download the PHP for Linux source code package on the following page: http://www.php.net/downloads.php.pdf to the /home/wjdirectory.
Command list:
CD/home/WJ
Tar-zxvf php-5.0.4.tar.gz
Music php-5.0.4 PHP
CD PHP
./Configure -- prefix =/usr/local/PhP5
-- With-apxs2 =/usr/local/apache2/bin/apxs
-- With-config-file-Path =/usr/local/lib
-- Enable-track-vars
-- With-XML
-- With-MySQL
Make
Make install
Here, Apache and MySQL are changed based on the directory name you installed. my options are =/usr/local/apache2/bin/apxs and MySQL.
Cp php. ini-Dist/usr/local/lib/PHP. ini
Install PHP in DSO mode to/usr/local/PHP and set the configuration file directory to/usr/local/lib to enable mysql. xml supports
3. Configuration
VI/usr/local/Apache/CONF/httpd. conf
Configure Apache as follows:
# Change the serveradmin mailto: linux@linuxidc.com line to your mailbox address
# DocumentRoot "/home/httpd/html/" is the main directory of the HTML file.
Options followsymlinks Multiviews for security, remove "indexes"
Directoryindex default. php default. phtml default. php3 default.html default.htm
Addtype application/X-httpd-PHP. php. phtml. php3. inc # Set the default file name order of Apache
Addtype application/X-httpd-PHP-source. PHPs # Set the PHP file suffix
Save disk and exit
VI/usr/local/lib/PHP. ini
# Register-golbals = on
Save disk and exit
4. Start the service
/Usr/local/Apache/bin/apachectl start
5. Test
Then write a PHP test page info. php: The content is as follows:
<〈? Phpphpinfo ();?>
If it is normal, you should be able to see the PHP information. Congratulations on your Apche + MySQL + PHP installation.
6. Apache Automatic startup --
The following uses self-starting Apache as an example;
Self-starting script:
/Usr/local/Apache/bin/apachectl start
The file is located under/etc/rc. d/init. d and is named apached. It must be executable.
# Chmod + x/etc/rc. d/init. d/apached // set the file attributes to executable.
# Ln-S/etc/rc. d/init. d/apached/etc/rc3.d/s90apache // create a soft connection and a shortcut
# Ln-S/etc/rc. d/init. d/apached/etc/rc0.d/k20apache