Compile and install Lamp,xcache test

Source: Internet
Author: User
Tags bz2 configuration php mcrypt zts administrator password phpmyadmin

Compile and install lamp combinations:
There are two ways to integrate httpd+php:
1.modules: Compile PHP into HTTPD's DSO object;
Prefork:libphp5
Event, Worker:libphp5-zts
--enable-maintainer-zts
2.FPM (fastcgi): PHP as a standalone service
HTTPD support for the FASTCGI protocol:
httpd-2.2: Additional installation of fcgi module is required;
httpd-2.4: Comes with fcgi module;
Installation Order:
httpd2.4, MariaDB5, PHP5

Note: httpd relies on apr-1.4+, apr-util-1.4+, [Apr-icon]
Apr:apache Portable Runtime: Equivalent to the compatibility layer between Apache and the system, enabling the same httpd software to run on multiple platforms without providing a program for each platform
centos6 Default: apr-1.3.9, apr-util-1.3.9-------> Install apr-1.4+ prior to installing httpd2.4,

Apr-util-1.4+,[apr-icon], otherwise incompatible, but try not to overwrite the original 1.3 version, will destroy other programs

For CENTOS6, the development pack group needs to be installed before installation

Yum Group install "Development Tools" "Server Platform Development"

HTTPD related bundles need to be installed: Yum install Pcre-devel lets applications support regular expression extension libraries

1. Download the package:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/1C/wKiom1YT6wrBgunmAAEH2y-eRb8794.jpg "title=" 1.png " alt= "Wkiom1yt6wrbgunmaaeh2y-erb8794.jpg"/>

(1) Compile and install Apr
# Tar XF apr-1.5.0.tar.bz2
# CD apr-1.5.0
#./configure--PREFIX=/USR/LOCAL/APR
# Make && make install
(2) Compile and install Apr-util
# Tar XF apr-util-1.5.3.tar.bz2
# CD apr-util-1.5.3
#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR
# Make && make install

(3) # tar XF httpd-2.4.9.tar.bz2
# CD httpd-2.4.9
#./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd24--enable-so--enable-ssl--enable-cgi-- Enable-rewrite--with-zlib
--with-pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--enable-modules=most-- Enable-mpms-shared=all--with-mpm=event
# Make && make install

Explain:

--ENABLE-SO: Support dynamic module loading mechanism

--enable-rewrite: Just URL rewrite

--with-zlib: Compression Algorithm Library

--with-pcre:perl Extension Package

--enable-mpms-shared: Support MPM sharing module mechanism

--WITH-MPM: What type of MPM is used by default

Add:
One, build mpm as static module
In all platforms, MPM can be built as a static module. Select a mpm at build time, linked to the server. If you want to change MPM, you must rebuild it. In order to use the specified MPM, use the parameter--with-mpm=name when executing the Configure script. Name is the specified MPM name. After the compilation is complete, you can use./httpd-l to determine the selected MPM. This command lists all modules that are compiled into the server program, including MPM.
Second, build MPM as dynamic module
In UNIX or similar platforms, MPM can be built as a dynamic module and loaded at run time as with other dynamic modules. Building MPM as a dynamic module allows you to change the MPM by modifying the contents of the LoadModule directive without rebuilding the server program. Use the--enable-mpms-shared option to enable this feature when you execute a configure script. All MPM modules supported by this platform will be installed when the given parameter is all. You can also give a list of modules in the parameters. The default MPM, which can be automatically selected or specified by the--WITH-MPM option when the Configure script is executed, then appears in the generated server configuration file. Edit the loadmodule instruction content to select a different mpm.

To edit the/etc/httpd/httpd.conf, add the following line:
Pidfile "/var/run/httpd/httpd24.pid" here should be in the same location as the PID file indicated by the service script below

(4) Provide service script:

Cp/etc/rc.d/init.d/httpd/etc/rc.d/init.d/httpd24

Edit the Httpd24 file to the following line

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/1C/wKiom1YTt-eiDm1OAACIgRC9thg835.jpg "style=" float: none; "title=" 2.png "alt=" Wkiom1ytt-eidm1oaacigrc9thg835.jpg "/>

The PID position should be in the same location as the PID file indicated in the httpd.conf configuration file above

chmod +x/etc/rc.d/init.d/httpd24

Import the httpd binary path of the compiled installation into the environment variable, and remember to use hash-r to empty the hash cache

vim/etc/profile.d/httpd.sh

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/19/wKioL1YTt_yRFHwNAAAbPDeaoj0566.jpg "style=" float: none; "title=" 3.png "alt=" Wkiol1ytt_yrfhwnaaabpdeaoj0566.jpg "/>

. /etc/profile.d/httpd.sh

Hash-r

Boot start:

Chkconfig--add httpd24 && chkconfig httpd24 on


2. Universal Binary Installation MARIADB:

Create a mariadb working directory #mkdir-pv/mydata/data

# groupadd-r MySQL
# useradd-g mysql-r-s/sbin/nologin-m-d/mydata/data MySQL
# Chown-r Mysql:mysql/mydata/data

TAR-XF mariadb-5.5.43-linux-x86_64.tar.gz-c/usr/local/

Cd/usr/local

LN-SV Mariadb-5.5.43-linux-x86_64/mysql

CD MySQL

Chown-r root.mysql./*
scripts/mysql_install_db--datadir=/mydata/data/--user=mysql

Cd/usr/local/mysql

CP support-files/my-large.cnf/etc/mysql/my.cnf and edit:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/1C/wKiom1YTvhvjaprJAAAtZnFGiVY438.jpg "title=" 10.png "alt=" Wkiom1ytvhvjaprjaaatznfgivy438.jpg "/>

To provide a service script:

CP Support-files/mysql.server/etc/rc.d/init.d/mysqld

Boot up

Chkconfig--add mysqld && chkconfig mysqld on

This MySQL Client interface program is/USR/LOCAL/MYSQL/BIN/MYSQL and can be called directly by modifying the path variable as above


3. Compile and install PHP as a module

Requires two packages: Yum-y install bzip2-devel libmcrypt-devel libxml2-devel, note libmcrypt-devel in Epel source, provide encryption and decryption library

# Tar XF php-5.4.26.tar.bz2
# CD php-5.4.26
#./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
--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS enable httpd to load PHP (PHP as Apache module)

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

Make-j 2 && make install


To provide a configuration file for PHP:
# CP Php.ini-production/etc/php.ini
Edit Apache config file httpd.conf to Apache support PHP
# vim/etc/httpd24/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

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

Reboot found PHP module loaded

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/19/wKioL1YTz5OBfyVsAACB7cinqUA052.jpg "title=" 4.png " alt= "Wkiol1ytz5obfyvsaacb7cinqua052.jpg"/>

Test code: Compile the installed httpd default page in the/usr/local/apache/htdocs directory, create index.php and test

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/1C/wKiom1YTzyag-1vIAAA7gZ7_2wY449.jpg "style=" float: none; "title=" 5.png "alt=" Wkiom1ytzyag-1viaaa7gz7_2wy449.jpg "/>

PHP Normal, database connection OK

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/19/wKioL1YTzzvB0wnWAAHgCWDfSng234.jpg "style=" float: none; "title=" 6.png "alt=" Wkiol1ytzzvb0wnwaahgcwdfsng234.jpg "/>

4. Installing Php-myadmin

Unzip phpMyAdmin with unzip

MV PHPMYADMIN-4.3.5-ALL-LANGUAGES/USR/LOCAL/APACHE/HTDOCS/PMA

CP config.sample.inc.php config.inc.php Edit:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/1C/wKiom1YT0ibC_lRAAABDrFc1oKU246.jpg "style=" float: none; "title=" 7.png "alt=" Wkiom1yt0ibc_lraaabdrfc1oku246.jpg "/>

To set the administrator password:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/19/wKioL1YT0jvCCsFpAAGBqZYAIxA443.jpg "style=" float: none; "title=" 8.png "alt=" Wkiol1yt0jvccsfpaagbqzyaixa443.jpg "/>

Reread Authorization form:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/1C/wKiom1YT0ibBne5CAAAqfnotKdM146.jpg "style=" float: none; "title=" 9.png "alt=" Wkiom1yt0ibbne5caaaqfnotkdm146.jpg "/>

Login test:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/19/wKioL1YT0jzDwHqvAANs4kxUd74092.jpg "style=" float: none; "title=" 10.png "alt=" Wkiol1yt0jzdwhqvaans4kxud74092.jpg "/>

Install XCache:

# Tar XF xcache-3.0.3.tar.gz
# CD xcache-3.0.3
#/usr/local/php/bin/phpize
#./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/

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/19/wKioL1YT2lmTICp0AABjZHDN4HA694.jpg "style=" float: none; "title=" 11.png "alt=" Wkiol1yt2lmticp0aabjzhdn4ha694.jpg "/>

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 zend_extension, and modify it to the following line:
Zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
Note: If you have more than one zend_extension line in the php.ini file, make sure that this new row is ranked first.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/1C/wKiom1YT2kXyP8HCAAGRcsqrwvg411.jpg "style=" float: none; "title=" 12.png "alt=" Wkiom1yt2kxyp8hcaagrcsqrwvg411.jpg "/>

Note that the last xcache_size is a cache that is saved for opcode, and often needs to be adjusted

Heavy Duty HTTPD24 Service

XCache appears after the test page refreshes:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/1C/wKiom1YT2w-hZy3fAAIbu-VBF70681.jpg "title=" 13.png "alt=" Wkiom1yt2w-hzy3faaibu-vbf70681.jpg "/>

Pre-XCache pressure test: Process 10.73 Requests per second

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/19/wKioL1YT2_3QFYBNAAGgpXBGomA128.jpg "style=" float: none; "title=" 14.png "alt=" Wkiol1yt2_3qfybnaaggpxbgoma128.jpg "/>

After installing XCache, 62.43 per second

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/1C/wKiom1YT2-mRO_sRAAG1MWRSf6I521.jpg "style=" float: none; "title=" 15.png "alt=" Wkiom1yt2-mro_sraag1mwrsf6i521.jpg "/>


Configuring the apache-2.4.9 php-5.4.26 in FPM mode

If you want the compiled PHP to support the mcrypt extension, you need to download

libmcrypt-2.5.7-5.el5.i386.rpm
libmcrypt-devel-2.5.7-5.el5.i386.rpm
mhash-0.9.9-1.el5.centos.i386.rpm
mhash-devel-0.9.9-1.el5.centos.i386.rpm

Note that this installation avoids a directory that has just been installed by PHP in a modular manner

Tar XF php-5.4.26.tar.bz2
# CD php-5.4.26
#./configure--prefix=/usr/local/php5 --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
--ENABLE-FPM--with-mcrypt--with-config-file-path=/etc/php5 --with-config-file-scan-dir=/etc/php5.d --with-bz2

Make && make install


3, Configuration php-fpm
Provide the SYSV init script for php-fpm and add it to the list of services:
# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM
# chmod +X/ETC/RC.D/INIT.D/PHP-FPM
# chkconfig--add php-fpm
# Chkconfig PHP-FPM on

To provide a configuration file for php-fpm:
# cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/1C/wKiom1YT4ijhyhYyAAEUXTZok08620.jpg "style=" float: none; "title=" 16.png "alt=" Wkiom1yt4ijhyhyyaaeuxtzok08620.jpg "/>

To edit a php-fpm configuration file:
# vim/usr/local/php5/etc/php-fpm.conf
Configure the relevant options for FPM to the value you need and enable the PID file (the last line below):
Pm.max_children = 50
Pm.start_servers = 5
Pm.min_spare_servers = 2
Pm.max_spare_servers = 8
PID =/usr/local/php5/var/run/php-fpm.pid

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/19/wKioL1YT4j3TNx8DAABWmFk6MIo965.jpg "style=" float: none; "title=" 17.png "alt=" Wkiol1yt4j3tnx8daabwmfk6mio965.jpg "/>

The next step is to start php-fpm:
# service PHP-FPM Start

By default, FPM listens on port 9000 of 127.0.0.1, and can also use the following command to verify that it is already listening on the appropriate socket.
# NETSTAT-TNLP | grep php-fpm
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 689/php-fpm

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/1C/wKiom1YT4inz69sAAAFXemxkjDQ327.jpg "style=" float: none; "title=" 18.png "alt=" Wkiom1yt4inz69saaafxemxkjdq327.jpg "/>

Enabling the relevant modules for httpd
After Apache HTTPD 2.4 has a module specifically for the implementation of the FASTCGI, this module is mod_proxy_fcgi.so, it is actually as an extension of the mod_proxy.so module, so the two modules are loaded
LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_fcgi_module modules/mod_proxy_fcgi.so

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/1C/wKiom1YT5NigFn5RAACgsUh_mIA580.jpg "style=" float: none; "title=" 19.png "alt=" Wkiom1yt5nigfn5raacgsuh_mia580.jpg "/>

2, configure the host to support the use of fcgi
Add two lines similar to the following in the corresponding virtual host.
Proxyrequests OFF
Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/path/to/document_root/$1

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/1C/wKiom1YT5NmwUaxCAAA6tadXt-Y393.jpg "style=" float: none; "title=" 21.png "alt=" Wkiom1yt5nmwuaxcaaa6tadxt-y393.jpg "/>

If it is a virtual host:

http://www.lee.com/admin/index.php
/web/host1/admin/index.php
fcgi://127.0.0.1:9000/web/hosts/admin/index.php
For example:
<virtualhost *:80>
DocumentRoot "/www/lee.com"
ServerName lee.com
Serveralias www.lee.com
Proxyrequests OFF
Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/www/lee.com/$1
<directory "/www/lee.com" >
Options None
allowoverride None
Require all granted
</Directory>
</VirtualHost>
Proxyrequests off: Turn off the forward proxy
Proxypassmatch: Send a file request ending in. php to the PHP-FPM process, php-fpm need to know at least the directory and URI that is running, so this is where the two parameters are indicated directly after the fcgi://127.0.0.1:9000. The delivery of other parameters has been encapsulated by mod_proxy_fcgi.so and does not need to be specified manually.

3, edit Apache configuration file httpd.conf, let Apache can recognize PHP format page, and support the PHP format of the home page
# vim/etc/httpd/httpd.conf
1, add the following two lines
AddType application/x-httpd-php. php
AddType Application/x-httpd-php-source. Phps

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/1A/wKioL1YT5O2zjP6OAAA0TIik7Yc426.jpg "style=" float: none; "title=" 20.png "alt=" Wkiol1yt5o2zjp6oaaa0tiik7yc426.jpg "/>

2. Locate to DirectoryIndex index.html
Modified to:
DirectoryIndex index.php index.html
Add: Apache httpd 2.4 Previous versions, either run PHP as an Apache module or add a third-party module to support the PHP-FPM implementation.





This article is from the "After Tomorrow" blog, please be sure to keep this source http://leeyan.blog.51cto.com/8379003/1700541

Compiling and installing Lamp,xcache tests

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.