CENTOS6 Install lamp and perform xcache acceleration

Source: Internet
Author: User
Tags bz2 php script what is lamp zend

One, LAMP1. What is lamp

L:linux is free open source software, which means that the source code is available for the operating system.
A:apache (httpd) is one of the most popular open source web server software in use
M:mysql, MARIADB is a multi-threaded and multiuser SQL database management system.
p:php, Perl, Pyth is a programming language originally designed to produce dynamic Web sites. PHP is primarily used for server-side application software. Perl and Python are similar
Often used to build dynamic Web site or server open source software, itself is a separate program, but because it is often used together, has a higher degree of compatibility, together constitute a powerful Web application platform.
From the website traffic, more than 70% of the traffic is lamp to provide, lamp is the most powerful website solution.

2.LAMP Architecture and working principle


The browser sends an HTTP request to the server, the server (Apache) accepts the request, and if it is a static resource it is called directly, and if it is a dynamic resource, the PHP processing module is invoked to connect to the MySQL database for PHP script processing. After the script has been processed, the result is converted to a static resource, which is sent by Apache to the browser through HTTP protocol, browser parsing, rendering and so on, rendering the entire Web page after a series of operations.

3.CGI

Cgi:common Gateway Interface
You can have a client, from a Web browser through an HTTP server, to execute the
A program on a network server transmits data; CGI describes the client and server processes
A standard for transferring between sequences

Second, build lamp software preparation

Apr-1.6.2.tar.gz
Apr-util-1.6.0.tar.gz
httpd-2.4.29.tar.bz2
We are ready to compile and install httpd, so we need to prepare the APR package (note the version, if there is too much difference may be error)
Mariadb-5.5.60-linux-x86_64.tar.gz
Database Binary installation package
Php-5.6.36.tar.xz
xcache-3.2.0.tar.bz2
PHP and PHP Accelerators (note xcache version and PHP version)

1. Compile and install httpd2.4

[[Email protected] src]# tar xvf apr-1.6.2.tar.gz; tar xvf apr-util-1.6.0.tar.gz; tar xvf httpd-2.4.29.tar.bz2 (#解压缩数据包)

[Email protected] src]# cp-r apr-1.6.2 httpd-2.4.29/srclib/apr
[Email protected] src]# cp-r apr-util-1.6.0 httpd-2.4.29/srclib/apr-util (#将apr拷贝到httpd指定目录下)
[Email protected] httpd-2.4.29]#/configure--prefix=/app/httpd24--sysconfdir=/etc/httpd24/conf--enable-so-- Enable-ssl--enable-rewrite--with-zlib--with-pcre--with-included-apr--enable-modules=most--enable-mpms-shared= All--with-mpm=prefork
[[email protected] httpd-2.4.29]# make-j 4 && make install (#编译安装)
[Email protected] httpd-2.4.29]# vim/etc/profile.d/env.sh (#将httpd启动项加入到全局配置文件里)

    • Export Path=/app/httpd24/bin: $PATH

[Email protected] httpd-2.4.29]# source/etc/profile.d/env.sh (#重读配置文件)
[Email protected] httpd-2.4.29]# useradd-r-m-d/var/www-u 48-s/sbin/nologin Apache (#创建apache用户)
[[email protected] ~]# vim/etc/init.d/httpd (#修改启动项文件, if there is no copy from another machine or a rpm2cpio instruction from the httpd RPM package to copy a copy)
Apachectl=/app/httpd24/bin/apachectl
HTTPD=${HTTPD-/APP/HTTPD24/BIN/HTTPD}
Prog=httpd
Pidfile=${pidfile-/app/httpd24/logs/httpd.pid}
LOCKFILE=${LOCKFILE-/VAR/LOCK/SUBSYS/HTTPD24}
[Email protected] ~]# chkconfig--add httpd24 (#将httpd加入到系统服务)
[[email protected] ~]# chkconfig httpd24 on (#设定 rating is on)
[Email protected] ~]# vim/etc/httpd24/conf/httpd.conf (#配置httpd配置文件)

    • ServerName lamp.centos6.com:80
    • DocumentRoot "/var/www/html"
    • <directory "/var/www/html" >
    • User Apache
    • Group Apache

[Email protected] ~]# vim/var/www/html/index.html (#编写网页内容)

[[email protected] ~]#/etc/init.d/httpd24 Restart (Start (restart) service)
stopping httpd: [OK]
Starting httpd: [OK]

2. Binary installation mariadb

[Email protected] src]# tar xvf mari ' adb-5.5.60-linux-x86_64.tar.gz-c/usr/local/(#解压安装包并指定目录)
[Email protected] src]# cd/usr/local/
[Email protected] local]# ln-s mariadb-5.5.60-linux-x86_64/mysql (#创建软链接)
[Email protected] httpd-2.4.29]# vim/etc/profile.d/env.sh (#添加启动项到全局文件)

    • Export path=/app/httpd24/bin:/usr/local/mysql/bin: $PATH

      [[email protected] local]# source/ Etc/profile.d/env.sh (#重读全局配置文件)
      [[email protected] local]# cd mysql/
      [[email protected] mysql]# Useradd-m-r-d/app/mysqldb-u 27-s/sbin/nologin MySQL (#创建mysql系统用户)
      [[email protected] mysql]# Scripts/mysql _install_db--datadir=/app/mysqldb--user=mysql
      [[email protected] mysql]# mkdir/etc/mysql (#编译安装)
      [[ Email protected] mysql]# cp support-files/my-huge.cnf/etc/mysql/my.cnf
      [[email protected] mysql]# vim/ ETC/MYSQL/MY.CNF (#更改配置文件)

    • [mysqld]
    • datadir =/app/mysqldb
    • innodb_file_per_table = on
    • skip_name_resolve = on

[Email protected] mysql]# setfacl-m u:mysql:rwx/var/log (#给mysql用户写日志权限)
[[Email protected] mysql]# service mysqld restart (#启动mysql数据库)
[Email protected] mysql]# mysql_secure_installation (#修改密码配置等)
[Email protected] mysql]# Mysql-uroot-pcentos

MariaDB [(None)]> CREATE Database wpdb; (#创建目录)
Query OK, 1 row Affected (0.00 sec)

MariaDB [(None)]> grant all on wpdb.* to [email protected] '% ' identified by ' CentOS '; (#创建用户 )
Query OK, 0 rows affected (0.01 sec)

3. Source code Compilation installation PHP5

[Email protected] src]# tar xvf php-5.6.36.tar.xz (#解压安装包)
[Email protected] php-5.6.36]#/configure \ (#自己按需求配置)
>--prefix=/app/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=/app/httpd24/bin/apxs\
>--with-mcrypt \
>--WITH-CONFIG-FILE-PATH=/ETC \
>--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D \
>--with-bz2

[[email protected] php-5.6.36]# make-j 2 && make install (#编译安装)
[email protected] php-5.6.36]# CP Php.ini-production/etc/php.ini
[[email protected] php-5.6.36]# vim/etc/httpd24/conf/httpd.conf (#修改httpd配置文件, add PHP format)

    • <ifmodule dir_module>
    • DirectoryIndex index.php index.html
    • </IfModule>
    • AddType application/x-httpd-php. php
    • AddType Application/x-httpd-php-source. Phps

[[email protected] ~]# vim/var/www/html/index.php (#编写网页内容, and test whether the MySQL database can be successfully connected to PHP to connect to the httpd and MySQL database)

    • <?php
    • $mysqli =new mysqli ("localhost", "root", "CentOS");
    • if (Mysqli_connect_errno ()) {
    • echo "Connection database failed!";
    • $mysqli =null;
    • Exit
    • }
    • echo "Connect database successfully!";
    • $mysqli->close ();
    • $link =
    • mysql_connect (' localhost ', ' root ', ' CentOS ');
    • if ($link)
    • echo "Success ...";
    • Else
    • echo "Failure ...";
    • Mysql_close ();
    • Phpinfo ();
    • ?>
4. Compile for Php-xcache acceleration

[Email protected] src]# tar xvf xcache-3.2.0.tar.bz2 (#解压安装包)
[Email protected] ~]# vim/etc/profile.d/env.sh (#添加至全局文件并刷新)

    • Export Path=/app/php/bin:/app/httpd24/bin:/usr/local/mysql/bin: $PATH

[Email protected] ~]# source/etc/profile.d/env.sh
[Email protected] src]# CD xcache-3.2.0
[Email protected] xcache-3.2.0]# phpize (#自动创建文件)
Configuring for:
PHP Api version:20131106
Zend Module Api no:20131226
Zend Extension Api no:220131226
[Email protected] xcache-3.2.0]#/configure--enable-xcache--with-php-config=/app/php/bin/php-config
[[email protected] xcache-3.2.0]# make && make install (#编译安装)
[Email protected] xcache-3.2.0]# MKDIR/ETC/PHP.D
[email protected] xcache-3.2.0]# CP xcache.ini/etc/php.d/
[[email protected] xcache-3.2.0]# Vim/etc/php.d/xcache.ini (#在php扩展配置目录下编写配置文件, enable the XCache module)
*extension =/app/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so
[[Email protected] xcache-3.2.0]# service httpd24 restart (#重启httpd服务)
stopping httpd: [OK]
Starting httpd: [OK]

Complete the installation

Centos6 install lamp and make xcache acceleration

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.