Lamp+event+xcache Compiling and installing

Source: Internet
Author: User
Tags configuration php fpm install php mcrypt mysql client zts

Tag: lamp compile and install    event   xcache   php-fpm   

The first part: Apache, MySQL, PHP installation one, compile and install apache1, resolve dependencies httpd-2.4.4 need a newer version of APR and Apr-util, so you need to upgrade it beforehand. There are two ways to upgrade, one is to compile the installation through source code, and the other is to upgrade the RPM package directly. Here you choose the way to compile the source code. (1)   Compile and install apr# tar xf apr-1.4.6.tar.bz2# cd apr-1.4.6# ./configure -- Prefix=/usr/local/apr# make && make install (2)   Compile and install APR-UTIL#&NBSP;TAR&NBSP;XF  apr-util-1.5.2.tar.bz2# cd apr-util-1.5.2# ./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr# make && make install (3)   The httpd-2.4.4 compilation process also relies on the Pcre-devel software package, which needs to be installed beforehand. This package system CD comes with, so, find and install can 2, compile and install httpd-2.4.4 first download httpd-2.4.4 to local, and then execute the following command to compile the installation process: (the MPM module selected here is the event, do not select Prefork and worker) # tar xf httpd-2.4.4.tar.bz2# cd httpd-2.4.4# ./configure --prefix=/usr/ local/apache --sysconfdir=/etc/httpd --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=most --with-mpm= Event# make && make install3, modify the httpd master profile, set its PID file path edit/etc/httpd/ httpd.conf, add the following line can:pidfile   "/var/run/httpd.pid" 4, provide SYSV service script/ETC/RC.D/INIT.D/HTTPD, the contents are as follows: #!/bin/bash# # httpd        startup script for the apache  http server## chkconfig: - 85 15# description: apache is a  World Wide Web server.  It is used to serve #        HTML files and CGI.# processname: httpd#  config: /etc/httpd/conf/httpd.conf# config: /etc/sysconfig/httpd# pidfile: /var/run/ Httpd.pid# source function library.  /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then&Nbsp;       . /etc/sysconfig/httpdfi# start httpd in  the c locale by default. httpd_lang=${httpd_lang-"C"}# this will prevent initlog from swallowing up  a pass-phrase prompt if# mod_ssl needs a pass-phrase from  The user. Initlog_args= "" # set httpd=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use  a server# with the thread-based  "Worker"  MPM; BE WARNED  That some modules may not# work correctly with a thread-based  MPM; notably PHP will refuse to start.# Path to the  Apachectl script, server binary, and short-form for messages.apachectl=/usr /local/apache/bin/apachectlhttpd=${httpd-/usr/local/apache/bin/httpd}pRog=httpdpidfile=${pidfile-/var/run/httpd.pid}lockfile=${lockfile-/var/lock/subsys/httpd}retval=0start ()   {        echo -n $ "starting  $prog: "          lang= $HTTPD _lang daemon --pidfile=${pidfile}  $httpd  $ options        retval=$?         echo        [  $RETVAL  = 0 ] &&  touch ${lockfile}        return  $RETVAL}stop ()  { echo -n $ "stopping  $prog: " killproc -p ${pidfile} -d 10 $ httpdretval=$?echo[  $RETVAL  = 0 ] && rm -f ${lockfile} ${ Pidfile}}reload ()  {    echo -n $ "reloading  $prog: "      if ! lang= $HTTPD _lang  $httpd   $OPTIONS  -t >&/dev/null; then         retval=$?        echo $ "not  Reloading due to configuration syntax error "         failure $ "not reloading  $httpd  due to configuration syntax  error "    else        killproc -p  ${pidfile}  $httpd  -HUP        RETVAL=$?     fi    echo}# See how we were called.case  "$"  in   start) Start;   stop) stop;;   status)         status -p ${pidfile} $ Httpdretval=$?;;   restart) Stopstart;;   condrestart) If [ -f ${pidfile} ] ; thenstopstartfi;;   reload)         reload;;   graceful|help|configtest|fullstatus) $apachectl  [email protected]RETVAL=$?;;   *) echo $ "usage:  $prog  {start|stop|restart|condrestart|reload|status|fullstatus| Graceful|help|configtest} "exit 1esacexit  $RETVAL then give execute permission for this script: # chmod +x /etc/rc.d/ INIT.D/HTTPD Join the Service list: # chkconfig --add httpd The next step is to start the service and test it. Second, install mysql-5.5.281, new user to run the process in a safe way: # groupadd -r mysql# useradd -g mysql -r  -s /sbin/nologin -m -d /mydata/data mysql# chown -r mysql:mysql &NBSP;/MYDATA/DATA2, install and initialize mysql-5.5.28 first download the MySQL version of the platform to local, here is the 32-bit platform, so the choice is mysql-5.5.28-linux2.6-i686.tar.gz. # tar xf mysql-5.5.28-linux2.6-i686.tar.gz -c /usr/local# cd /usr/local/#  ln -sv mysql-5.5.28-linux2.6-i686  mysql#  cd mysql # chown -r mysql:mysql  .# scripts/mysql_install_db -- User=mysql --datadir=/mydata/data# chown -r root  .3, Provide master profile for MySQL: (select Master profile and thread based on server's memory and CPU) # cd /usr/local/mysql# cp support-files/my-large.cnf &NBSP;&NBSP;/ETC/MY.CNF and modify the value of thread_concurrency in this file to multiply your number of CPUs by 2, for example using the following line:thread_concurrency =  2 You also need to add the following line to specify the location of the MySQL data file: datadir = /mydata/data4, providing MySQL with sysv service script: # cd /usr/local/mysql # cp support-files/mysql.server  /etc/rc.d/init.d/mysqld# chmod +x /etc/ Rc.d/init.d/mysqld Add to Service list:# chkconfig --add mysqld# chkconfig mysqld  On and then you can start the service test using. In order to use MySQL installation to conform to the system usage specification, and to export its development components to the system use, here also need to do the following steps: 5, output MySQL man manual to the man command find path:  edit/etc/ Man.config, add the following line: manpath  /usr/local/mysql/man6, output the MySQL header file to the System header file path/usr/include: This can be achieved by simply creating a link: #  ln -sv /usr/local/mysql/include  /usr/inCLUDE/MYSQL7, output MySQL library file to the system library to find the path:# echo  '/usr/local/mysql/lib '  > /etc/ld.so.conf.d/ Mysql.conf then let the system reload the system library: # ldconfig8, modify the PATH environment variable, so that the system can directly use the relevant commands of MySQL. The concrete implementation process is no longer given here. Third, compile and install php-5.4.131, resolve dependencies: Please configure the Yum source (can be the Local system CD) after executing the following command:# yum -y groupinstall  "X software  development "  If you want to have the compiled PHP support MCrypt extension, The following two RPM packages are installed: LIBMCRYPT-2.5.7-5.EL5.I386.RPMLIBMCRYPT-DEVEL-2.5.7-5.EL5.I386.RPM2, 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, here in order to support the Apache worker or event two mpm, compile using the--ENABLE-MAINTAINER-ZTS option. 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 from the php 5.4. # ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd#  Make# make test# make intall provides a configuration file for PHP: # cp php.ini-production /etc/ Php.ini3,   Edit Apache configuration file httpd.conf, with Apache 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, positioning 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. Iv. installing XCache for PHP Acceleration: 1, installation (note that XCache is an extension of PHP, so choose to install into the PHP folder) # tar xf xcache-3.0.1.tar.gz# cd xcache-3.0.1# /usr/local/php/bin/phpize# ./ configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config# make &&  make install installation ends, a line similar to the following will appear: installing shared extensions:     / USR/LOCAL/PHP/LIB/PHP/EXTENSIONS/NO-DEBUG-ZTS-20100525/2, Edit PHP.ini, integrate PHP and XCache: (Zend Engine) First import the sample configuration provided by XCache Php.ini# mkdir /etc/php.d# cp xcache.ini &NBSP;/ETC/PHP.D Description: 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 there are multiple zend_extension command lines in the php.ini file, make sure that this new row is ranked first. Five, enable the server state Mod_status module allows the administrator to view the server's execution status, it shows the current server statistics through an HTML page. These data typically include, but are not limited to: (1)   Number of worker processes in the working state, (2) The number of worker processes in the   idle state, and (3)   The status of each worker, including the number of requests that the worker has responded to, And the number of bytes sent by the worker, (4)   The total number of bytes sent by the current server, (5)   The current length of time since the server was last started or restarted, (6)   The average number of requests per second, the average number of bytes sent per second, average perThe number of bytes requested by the request, and the way to enable the status page is simply to add the following to the main profile:<location /server-status>     Sethandler server-status    require all granted</location> need to be reminded that The status information here should not be accessible to everyone at will, so you should restrict the only clients that are allowed to be viewed by certain addresses. For example, use REQUIRE&NBSP;IP&NBSP;172.16.0.0/16 to restrict only hosts that specify network segments from viewing this page. The second part, configuration apache-2.4.4 and FPM mode php-5.4.13 (This chapter PHP uses FASTCGI manager fpm, do not compile maintainer-zts and APXS) one, Apache, MySQL installation is the same as the previous part , install according to it, compile and install php-5.4.131, resolve dependencies: If you want the compiled PHP to support MCrypt extensions, The following two RPM packages and installed: Libmcrypt-2.5.7-5.el5.i386.rpmlibmcrypt-devel-2.5.7-5.el5.i386.rpmmhash-0.9.9-1.el5.centos.i386.rpmmhash-dev EL-0.9.9-1.EL5.CENTOS.I386.RPM2, compile and install php-5.4.13 first download the source package to the local directory. # 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 --enable-fpm --with-mcrypt  -- with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d -- WITH-BZ2 Note: If you use PHP5.3 or above, in order to link to the MySQL database, you can specify MYSQLND, so that you do not need to install the MySQL or MySQL development package in this machine first. 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 from the php 5.4. # ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd#  Make# make intall provides a configuration file for PHP: # cp php.ini-production /etc/php.ini3, configuration php-fpm  Provide a 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 provides configuration files for php-fpm: # cp /usr/local/php/etc/php-fpm.conf.default /usr/ local/php/etc/php-fpm.conf  Edit php-fpm configuration file: # vim /usr/local/php/etc/ Php-fpm.conf configure FPM with the relevant options for the value you need and enable the PID file (e.g.Next last line): Pm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 2pm.max_ spare_servers = 8pid = /usr/local/php/var/run/php-fpm.pid   can then start the PHP-FPM: #  service php-fpm start uses the following command (if the command output has several PHP-FPM processes to indicate that the boot was successful):# ps aux |  GREP&NBSP;PHP-FPM by default, FPM listens on port 9000 of 127.0.0.1, and can use the following command to verify that it is already listening on the appropriate socket. # netstat -tnlp | grep php-fpmtcp        0       0 127.0.0.1:9000               0.0.0.0:*           &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;LISTEN&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;689/PHP-FPM Three, Configuring httpd-2.4.41, enabling HTTPD related modules after apache httpd 2.4 has been dedicated to a module for the implementation of FASTCGI, this module is mod_proxy_fcgi.so, it is actually as Mod_ The proxy.so module is expanded so that all two modules are loaded loadmodule proxy_module modules/mOD_PROXY.SOLOADMODULE&NBSP;PROXY_FCGI_MODULE&NBSP;MODULES/MOD_PROXY_FCGI.SO2, configure the virtual host to support the use of fcgi to add similar to the following two lines in the corresponding virtual host. proxyrequests offproxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/path/to/document_root/$1 For example: <VirtualHost *:80>    DocumentRoot  "/www/xx.com"      Servername xx.com    serveralias www.xx.comproxyrequests offproxypassmatch  ^/(. *\.php) $ fcgi://127.0.0.1:9000/www/xx.com/$1    <directory  "/www/ Xx.com ">        Options none         allowoverride none        require all  granted    </Directory></VirtualHost>ProxyRequests  OFF: Turn off 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 directly in the fcgi:// After 127.0.0.1:9000, the two parameters are indicated, and the other parameters have been encapsulated by the mod_proxy_fcgi.so, without the need to manually refer to theAvailability 3, edit Apache configuration file httpd.conf, let Apache can recognize PHP format page, and support PHP format home   # 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, positioning to directoryindex index.html      Modified to:     directoryindex  index.php  index.html supplement: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.


Lamp+event+xcache Compiling and installing

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.