Install apache and php in linux

Source: Internet
Author: User
Install apache and php in linux-Linux Enterprise Application-Linux server application information. For more information, see. 1. apache

Download the source code package of apache for Linux on the following page

Http://www.apache.org/dist/httpd /;

Save 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;

Save to/home/wj directory

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.

# Same as above

# Options FollowSymLinks MultiViews for security reasons, remove "Indexes"

#

# DirectoryIndex default. php default. phtml default. php3 default.html default.htm

#

# Set the default file name order of apache

# AddType application/x-httpd-php. php. phtml. php3. inc

# 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:

<〈? Php

Phpinfo ();

?>

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.