Compiling and installing PHP5.4.41

Source: Internet
Author: User

First, the deployment lamp environment, installation sequence

Second, compile, install PHP

Third, install XCache, for php (opcode) acceleration

Iv. Other

First, the deployment lamp environment, installation sequence

Compiling and installing the lamp environment, installation sequence

1. Compile and install apache,http://64314491.blog.51cto.com/2784219/1652948

2. Compile and install mysql,http://64314491.blog.51cto.com/2784219/1652999

3. Compile and install PHP

Second, compile, install PHP

1. Download PHP and Unzip

[[email protected] downloads]# wget http://cn2.php.net/distributions/php-5.4.41.tar.bz2[[email protected] downloads] # Tar XF php-5.4.41.tar.bz2

2, pre-compilation preparation work

(1), compile options

./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

(2), direct compilation, there will be the following reminders, so you need to prepare in advance

1, configure:error:xml2-config not found. Please check your libxml2 installation.2, configure:error:Please Reinstall the BZIP2 Distribution3, configure:error:mcry Pt.h not found.    Please reinstall Libmcrypt.4, configure:error:Cannot find MySQL header files Under/usr/local/mysql. #这个问题就需要先安装mysql后, compile PHP again, so it's best to follow the steps apache-->mysql-->php

So you need to install a dependent environment before compiling

1, # yum-y install libxml2 libxml2-devel2, # yum-y install bzip2-devel download Libmcrypt libmcrypt-devel, and install # wget Http://mirro rs.sohu.com/fedora-epel/6server/x86_64/libmcrypt-2.5.8-9.el6.x86_64.rpm# wget http://mirrors.sohu.com/ FEDORA-EPEL/6SERVER/X86_64/LIBMCRYPT-DEVEL-2.5.8-9.EL6.X86_64.RPM3, # RPM-IVH libmcrypt-2.5.8-9.el6.x86_64.rpm # RPM-IVH libmcrypt-devel-2.5.8-9.el6.x86_64.rpm

3. Compiling and installing PHP

#./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# make && make install

Note: You need to use this option when compiling the module worker, event--enable-maintainer-zts

4. Edit/etc/httpd/httpd.conf

(1), AddType application/x-gzip. GZ tgz Post-cotton Add the following information to enable HTTPD to identify pages in PHP format

AddType application/x-httpd-php. Phpaddtype application/x-httpd-php-source. Phps

(2), add default start Page file name

DirectoryIndex index.php

<ifmodule dir_module> DirectoryIndex index.php index.html</ifmodule>

After the configuration is complete, the overloaded configuration

[Email protected] ~]# service httpd Graceful

(3), to provide a configuration file for PHP, in our extracted source directory, there are two sample configuration files

[[email protected] ~]# cd/root/downloads/php-5.4.41[[email protected] php-5.4.41]# ls |grep php.iniphp.ini-development #适用于开发环境php. Ini-production #适用于生产环境

When compiling the installation, we specified the configuration file directory for PHP/etc, where we copied the configuration file for the production environment.

[email protected] php-5.4.41]# CP Php.ini-production/etc/php.ini

(4), test

Before compiling the installation of Apache, the configuration file, the default Web site root directory is DocumentRoot "/usr/local/apache/htdocs"
Create a new test page on the path index.php, as follows

Enter the host address test in the browser, as shown in the instructions for installation, configuration success

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/6D/13/wKioL1VcB93jMNdpAAFDVsv19kM062.jpg "height=" 276 "/>

(5), test connection MySQL

/usr/local/apache/htdocs Create a new test page on the path pcmysql.php, as follows

And then use the browser to access this page, the following message shows that PHP successfully connected to MySQL

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6C/F4/wKioL1VYwB7z3y6TAAASSTnwtyo345.jpg "width=" 190 " height= "alt=" Wkiol1vywb7z3y6taaasstnwtyo345.jpg "/>


Third, install XCache, for php (opcode) acceleration

1. Download XCache

wget http://xcache.lighttpd.net/pub/Releases/3.1.2/xcache-3.1.2.tar.gz

2. Add XCache for PHP

[Email protected] downloads]# tar xf xcache-3.1.2.tar.gz [[email protected] downloads]# CD Xcache-3.1.2[[email protected ] xcache-3.1.2]#/usr/local/php/bin/phpizeconfiguring for:php API version:20100412zend Module API no:201005 25Zend Extension Api no:220100525

3. Compile and install XCache

[Email protected] xcache-3.1.2]#/configure--enable-xcache--with-php-config=/usr/local/php/bin/php-config[[ Email protected] xcache-3.1.2]# make && make install

Installation complete, prompt for module installation location

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20100525/

4. Copy the XCache configuration file to the PHP configuration file directory

[[email protected] xcache-3.1.2]# Mkdir/etc/php.d[[email protected] xcache-3.1.2]# CP Xcache.ini/etc/php.d[[email Protected] xcache-3.1.2]# Vim/etc/php.d/xcache.ini[[email protected] xcache-3.1.2]# service httpd Graceful #重载配置

New test page, access the test page in the browser, display the following screen, indicating that the module load normally

vim/usr/local/apache/htdocs/test.php Edit the following content <?php phpinfo ();? >

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/6D/13/wKioL1VcB92DLEwPAAGUhKfTobA179.jpg "height=" 387 "/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;margin:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/6D/13/wKioL1VcB96gPeRZAAAsFCLQIio309.jpg "height="/> #配置文件已经载入

If XCache is not working properly, try editing xcache.ini, edit extension = xcache.so, modify to full path

Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

Iv. Other

Configuration file/etc/php.ini,/etc/php.d/Directory *.ini

PHP.ini Official documents:

Configuration parameters: http://www.php.net/manual/zh/ini.list.php
Core configuration parameters in detail: http://www.php.net/manual/zh/ini.core.php

This article is from the "Arvin Lau" blog, be sure to keep this source http://64314491.blog.51cto.com/2784219/1653102

Compiling and installing PHP5.4.41

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.