Build and install the Lamp platform environment _xcache

Source: Internet
Author: User
Tags html page zts

Build and install the lamp environment platform based on Linux, Apache, Mysql, PHP, and use XCache to accelerate PHP


Compile and install the lamp platform:

1, download the package, install the dependency package

# yum Install-y pcre-devel

2. Unpacking and installing Apache

2.1 Compiling and installing apr-1.5.0

# tar XVF apr-1.5.0.tar.bz2

# CD apr-1.5.0 &&/configure--prefix=/usr/local/apr

# Make && make install

2.2 Compiling and installing apr-util-1.5.3

# tar XVF 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

2.3 Compiling and installing httpd-2.4.9

# tar XVF httpd-2.4.9.tar.bz2

# CD httpd-2.4.9

#./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd--enable-so--enable-ssl--enable-cgi-- Enable-rewirte--with-zlib--with-pcre--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util-- Enable-moudles=most--enable-mpms-shared=all--with-mpm=event

# Make && make install

2.4 Editing the httpd startup script

# VIM/ETC/INIT.D/HTTPD

# chmod +X/ETC/INIT.D/HTTPD

# Chconfig--add httpd

3. Install MySQL (mariaDB)

3.1 Preparing the file system for data storage

# Mkdir/mydata/data

3.2 New users run processes in a secure manner

# groupadd-r MySQL

# useradd-g mysql-r-s/sbin/nologin-m-d/mydata/data MySQL

# Chown-r Mysql:mysql/mydata/data

3.3 Installing and initializing

# tar xvf mariadb-5.5.43-linux-x86_64.tar.gz-c/usr/local/

# cd/usr/local/

# ln-s mariadb-5.5.43-linux-x86_64 MySQL

# CD MySQL && chown-r mysql.mysql.

# scripts/mysql_install_db--user=mysql--datadir=/mydata/data

# Chown-r Root.

3.4 Provide the main configuration file for MySQL:

# Cd/usr/local/mysql

# CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF

Modify the following parameters to thread_concurrency the number of CPUs multiplied by 2

Thread_concurrency = 8

You also need to add a row to define where MySQL data files are stored:

Datadir=/mydata/data

3.5 SysV Service script provided for MySQL

# Cd/usr/local/mysql

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

# chmod +x/etc/rc.d/init.d/mysqld

And then you can test startup MySQL.

3.6 You can now export the MySQL man manual to the find path of the man command

# Vi/etc/man.config

Add as Downstream

Manpath/usr/local/mysql/man

3.7 Output MySQL header file to the System header file path/usr/include

Can be implemented by simply creating a link

# Ln-sv/usr/local/mysql/include/mysql/usr/include/mysql

3.8 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

# Ldconfig

3.9 Modify the PATH environment variable to allow the system to use MySQL related commands

# vi/etc/profile.d/mysqld.sh

Add as Downstream

Export Path=/usr/local/mysql/bin: $PATH

# source/etc/profile.d/mysqld.sh

4. Compile and install PHP

4.1 Installation Dependencies

# yum Groupinstall-y "Desktop Platform Development"

# yum Install-y bzip2-devel Libmcrypt-devel

Note: Libmcrypt-devel needs Epel source

4.2 Compiling and installing php-5.6.9

# tar XVF php-5.6.9.tar.bz2

# CD php-5.6.9

#./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-jepg-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 work and event two mpm, compile with the--ENABLE-MAINTAINER-ZTS option

2, if the use of php5.3 above, in order to connect to the MySQL database, you can specify MYSQLND, so that the local computer does not need to install the MySQL or MySQL development package 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 starting with PHP 5.4.

#./configure--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd


# Make && make install

Provide a configuration file for PHP

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

4.3 edit apache config file httpd.conf to Apache support PHP

1. # vim/etc/httpd/httpd.conf

Add the following two lines

AddType application/x-httpd-php. php

AddType Application/x-httpd-php-source. Phps

2, positioning DirectoryIndex index.html modified to:

DirectoryIndex index.html index.php

Restart httpd or let it reload the configuration file to test if PHP is already working

Test page:

# vi/usr/local/apache/htdoc/index.php

<?php

$link = mysql_connect (' 127.0.01 ', ' root ', ');

if ($link)

Echo ' Success ... ';

Else

Echo ' Failure ... ';

Mysql_close ();

?>


5, install XCache, for PHP acceleration:

5.1 Installation

# tar ZXVF xcache-3.2.0.tar.gz

# CD xcache-3.2.0

#/usr/local/php/bin/phpize

#./configure--enable-xcache--with-php-config=/usr/local/php/bin/php-config

# Make && make install

Installation ends with the following tips

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

5.2 Editing php.ini, integrating PHP and XCache

# MKDIR/ETC/PHP.D

# CP XCACHE.INI/ETC/PHP.D

Note:

Xcache.ini files in the source directory of XCache

# Vi/etc/php.d/xcache.ini

Modify extension to the following content

Extension =/usr/local/php/lib/php/extensions/no-debug-zts-20131226/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

6. Enable Server Status

The Mod_status module allows the administrator to view the execution status of the server, and he displays the current server statistics through an HTML page that typically includes, but is not limited to:

(1) Number of worker processes at work;

(2) Number of worker processes in idle state;

(3) The state of each worker, including the number of requests that the worker has responded to, and the number of bytes of content sent by the worker;

(4) The total number of bytes sent by the current server;

(5) The current length of the server since it was last started or rebooted;

(6) The average number of requests per second, the average number of bytes per second sent, and the average number of bytes of content requested by each request;

The way to enable a page is simple, just add the following to the main profile:

<Location/server-status>

SetHandler Server-status

Require all granted

</Location>

You can also use require IP 192.168.1.0/24 to restrict only hosts that specify network segments from viewing this page.

eg

<Location/server-status>

SetHandler Server-status

Require IP 192.168.1.0/24

</Location>


This article comes from "a little progress every day ..." Blog, be sure to keep this source http://wzgl08.blog.51cto.com/668144/1661430

Build and install the Lamp platform environment _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.