Compile and install lamp php-5.4.13 and XCache

Source: Internet
Author: User
Tags mcrypt zts

Compiling and installing php-5.4.13 and XCache

As we talked about in the previous space, there are three main ways that Apache interacts with PHP, and the way we use it is to compile PHP into a module of Apache so that the Apache-PHP interaction runs directly inside Apache without the need to create additional processes.

1. Resolve dependencies before compiling

Install the following software

# yum-y Groupinstall "X Software Development"

If you want PHP to support the MCrypt extension feature. Also need to install the following two RPM packages

libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm

2. Compile and install php-5.4.13
# Tar XF php-5.4.13.tar.bz2
# CD php-5.4.13
#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-openssl--with-mysqli=/usr/local/mysql/ Bin/mysql_config--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir= /usr--enable-xml--enable-sockets--with-apxs2=/usr/local/apache/bin/apxs--with-mcrypt--with-config-file-path=/ etc--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-bz2--enable-maintainer-zts

Description

1. In order to support the two mpm of the Apache worker or event, the--ENABLE-MAINTAINER-ZTS option is used at compile time.

2, if you use PHP5.3 or above, in order to link the MySQL database, you can specify MYSQLND, so you do not need to install the MySQL or MySQL development package. MYSQLND is available from PHP 5.3 and can be bound to it at compile time (instead of relying on the specific MySQL client library bindings), but it is the default setting starting with PHP 5.4.
#./configure--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd

# make
# Make Test
# Make Intall

3. Provide configuration files for PHP

# CP Php.ini-production/etc/php.ini

4. Edit Apache config file httpd.conf to enable Apache to support PHP

# vim/etc/httpd/httpd.conf
1, add the following two lines
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps

2. Locate to DirectoryIndex index.html
Modified to:
DirectoryIndex index.php index.html

You can then test whether the installation was successful by creating the index.php file in the/usr/local/apache/htdocs directory.

Here I wrote a PHP script

<?php
$conn =mysql_connect (' localhost ', ' root ', ');
if ($conn)
echo "Success ...";
Else
echo "Failure ...";

Echo Phpinfo ();
?>

This script can test whether PHP is connected successfully, or whether MySQL is connected.

Then restart httpd, or let it reload the configuration file to test if PHP is already working.

Compile and install XCache for PHP acceleration:

1. Compile and install XCache

1. Installation
# Tar XF xcache-3.0.1.tar.gz
# CD xcache-3.0.1
#/usr/local/php/bin/phpize

(upstream command mainly executes script file, let PHP support extension function)
#./configure--enable-xcache--with-php-config=/usr/local/php/bin/php-config
# Make && make install


At the end of the installation, a line similar to the following appears:
Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20100525/

#注意这一行非常关键, especially the following string, which he wants to add to a file.

2, edit php.ini, integrate PHP and XCache:
The sample configuration provided by XCache is first imported into the php.ini
# MKDIR/ETC/PHP.D
# CP XCACHE.INI/ETC/PHP.D

Description: The Xcache.ini file is in the XCache source directory.

Next edit/etc/php.d/xcache.ini, locate the line that begins with extension, and modify it to the following line:
Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so


Note: If you have more than one extension line in the php.ini file, make sure that this new row is ranked first.

After the installation is complete, you can see the XCache feature when you restart the HTTPD service and then use your browser to access the index.php file.

This article from the "Linux Learning Path" blog, declined reprint!

Compile and install lamp php-5.4.13 and XCache

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.