How to install Apache and PHP in centos

Source: Internet
Author: User
Tags php write

Centos configuration Apache + PHP files are commonly used system files, so I have studied the installation of centos configuration for Apache + PHP. Here I will share my personal understanding about centos configuration and installation.

Configure Apache + PHP in centos

First;

Download software;

Apachehttp: // apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

PHP: http://cn.php.net/distributions/php-5.2.6.tar.gz

MySQL: http://mysql.ntu.edu.tw/Downloads/MySQL-5.0/mysql-5.0.51a-linux-i686-glibc23.tar.gz

First

[Root @ localhost] # wget http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

-- 00:47:30 -- http://apache.mirror.phpchina.com/httpd/httpd-2.2.9.tar.gz

Resolving apache.mirror.phpchina.com... 221.194.139.225

Connecting to apache.mirror.phpchina.com | 221.194.139.225 |: 80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 6396996 (6.1 m) [application/X-gzip]

Saving to: 'httpd-2.2.9.tar.gz. 1'

0% [] 36,300 41.3 K/s

[Root @ localhost] Tar zxvf httpd-2.2.9.tar.gz

Decompress the package below

Httpd-2.2.9/srclib/APR-util/test/abts_tests.h

Httpd-2.2.9/srclib/APR-util/test/data/

Httpd-2.2.9/srclib/APR-util/test/DBD. c

Httpd-2.2.9/srclib/APR-util/test/makefile. In

Httpd-2.2.9/srclib/APR-util/test/makefile. Win

Httpd-2.2.9/srclib/APR-util/test/nw_misc.c

Httpd-2.2.9/srclib/APR-util/test/nwgnuaputest

N characters are omitted here.

Go

[Root @ localhost ~] Compile Apache under Cd httpd-2.2.9

[Root @ localhost httpd-2.2.9]. /configure -- prefix =/usr/local/Apache -- enable-track-vars -- enable-CGI -- With-config-file-Path =/usr/local/Apache/Conf

It may take some time to compile centos configuration below.

The following describes how to compile centos configurations,

Prefix = // usr/local/MySQL/Apache specify to install apahce to the // usr/local/MySQL/Apache directory;

Enable-CGI supports CGI;

With-config-file-Path = // usr/local/MySQL/Apache/conf specify to put the Apache preparation file in // usr/local/MySQL/Apache/conf; for example, httpd. the confcentos configuration file is in this directory;

Enable-track-vars enables Cookie get/post and other tracing functions

Almost compiled. A prompt is displayed, indicating that Apache is successfully installed,

[Root @ localhost] Make; make install // then input the compile command, which is simple: Make; make install!

Then enter enable apache service.

[Root @ localhost] Server httpd restart

Apache is successfully installed.

Delete lifecycle page

Rm-F/usr/local/Apache/CONF. d/welcome. conf to see the cute 403 error!

Install PHP in centos configuration;
[Root @ localhost ~] # Tar zxvf php-5.2.6.tar.gz // extract PHP File

[Root @ localhost ~] # Cd php-5.2.6 // go to the PHP installation directory

[Root @ localhost php-5.2.6] #. /configure -- prefix = // usr/local/MySQL/PHP -- With-mysql = // usr/local/MySQL -- with-apxs2 = // usr/local/MySQL/Apache /bin/apxs -- enable-track-vars -- enable-force-CGI-redirect -- With-config-file-Path = // usr/local/MySQL/PHP/etc // compile PHP

Install: [root @ localhost php-5.2.6] # Make

[Root @ localhost php-5.2.6] # make install

Copy PHP. ini-Dist to PhP. ini and put it in the/usr/local/PHP Directory!

[Root @ localhost php-5.2.6] # cp PHP. ini-Dist/usr/local/PHP. ini

Edit the/usr/local/PHP. ini file and find the following line:

; Default_charset = "iso-8859-1"

Add a line below this line

Default_charset = "gb2312

// Combine Apache + PHP

Find the line # addtype application/X-tar. tgz and add a line below. Do not add the # sign before.

Addtype application/X-httpd-PHP. php

Find the following line and add index. php. This indicates that the website's homepage can also be index. php.

Directoryindex index.html. var index. php

Let's take a look at the PHP testing page.

Edit VI/usr/www/html/test. php write

Echo >><? Phpinfo ();?> /Usr/www/html/test. php. The PHP + Apache installation is successful here.

The above describes how to configure Apache + PHP installation in centos.

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.