Lamp platform Construction and its principle explanation

Source: Internet
Author: User
Tags mcrypt zts


Lamp platform Construction and its principle explanation

Lamp Platform Building Foundation Concept                                                       

lamp: Mentioned lamp Many people will think that lamp is Linux, apache,mysql,php. But with the continuous development of technology, today's lamp, is not only so simple, here our p in addition to PHP actually includes: Phython,perl. and M is not only referring to MySQL, but also to mariadb.

The lamp platform as its name implies is Linux,apache,mysql (mariadb), PHP (Phython,perl) combination. Depending on how they are combined, they can be broadly divided into three categories:

PHP combines Apache and MySQL in a modular format

PHP unifies Apache and MySQL in CGI form

PHP combines Apache and MySQL in the form of fastcgi.

Dynamic and static of Web resources

Static Content Service: The client initiates a resource request and the server sends the requested resource to the client intact. Dynamic resources: The server executes the client-initiated resource first, performs some processing, and returns it to the client.

Lamp Platform Process principle                                                        

Lamp is a multi-c/S architecture platform, the most basic for Web clients based on TCP/IP transmission through the HTTP protocol, the request may be dynamic, or may be static. So the Web server is judged by initiating the suffix of the request, if the static resource is handled by the Web server itself, and then the resource is sent to the client. If it is dynamic then the Web server will be launched to PHP via the CGI (Common Gateway Interface) protocol. Here, however, if PHP is contacting the Web server in the form of a module. Then they are sharing memory through the internal way. If PHP is placed separately from a single server, then they are communicating through the sockets socket listener (This is also a C/s architecture). At this point, PHP will execute a program, if you are executing the program, you need to use the data. Then PHP will be sent to MySQL server via MySQL protocol (also can be regarded as a C/s architecture). Processed by the MySQL server to supply the data to the PHP program. Approximate process

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/3A/wKiom1SVOpXDCG3qAADXWXHFEkc057.jpg "title=" Lamp.png "alt=" Wkiom1svopxdcg3qaadxwxhfekc057.jpg "/>



build and install the lamp platform                                                              

Since the previous blog has been installed with the httpd-2.4 version, this is done using version 2.2.

A. httpd-2.2 version of the installation.

First, download the source package to httpd. Then prepare the build environment : The source packages we need to install here are: "Devellopmnet Tools", "Server platform development" , and " Pcre-devel "Apr-devel", "Apr-util-devel".

    NOTE: The packages we rely on here are all development packages, but the httpd-2.2 version of the package pair "apr-devel "," Apr-util-devel "depends on the version is not high, we can use Yum to install:

#yum Install "Apr-devel"-y #yum Install "Apr-utill"-y #yum Install "pcre-devel"-y #cd/usr/local/#./confi Gure--prefix=/usr/local/apache22--sysconfdir=/etc/httpd22--enable-so--enable-ssl--enable-cgi--enable-rewrite-- With-zlib--with-pcre--enable-mpms-shared=all #make && make install #注意: Compile here if there is a problem, it is generally missing a development package, follow the prompts to install the appropriate package-D Evel.

When you're done here, take a look at whether Port 80 is occupied. If no occupancy can be attempted to start.

#netstat-TUNLP | grep #/usr/local/apache22/bin/apachectl start #netstat-TUNLP | grep 80

Note: There is no configuration service that can be combined with PHP until the PHP installation is complete.


Two. Installing mariadb-5.5.36

Since the MARIADB installation source package needs to be compiled with CMake, I use a binary version to install it, which is roughly the same process. Just a lack of source code package CMake three steps.

Idea: Install mariadb is used to do database storage and management, so this is a service also need a lot of storage data. So we create a separate partition to make logical volumes for the purpose of placing the data. To ensure security, we create a system startup user.

1. Preparing the file system for data storage

    # fdisk /dev/sda      # //here to create a partition based on your size needs.     # n\np\n  "First cylinderirst" \ n "Last cylinderirst" \nw     # partx -a /dev/sda    # pvcreate /dev/sda#     # vgcreate myvg /dev/sda#    # lvcreate -l  10g -n mylv myvg  //size According to your needs     # mkfs -t  xfs /dev/myvg/mylv    //We store large file systems here we recommend using XFS. I     # //here to/etc/fstab  to carry out the mount to enable automatic mount. or write to/etc/rc.d/rc.local under     # mkdir /mydata/mysql    #  chown -r mysql:mysql /mydata/data    # mount /dev/myvg/mylv   /mydata/mysql 

2. Create a MySQL user so that he is a system user.

Groupadd-r MySQL useradd-g mysql-r-s/sbin/nologin-m MySQL

3. Install and initialize the mariadb-5.5.36

# tar-zxf Mariadb-5.5.36-linux2.6-i686.tar.gz-c/usr/local # cd/usr/local/# LN-SV mysql-5.5.33-linux2.6-i68    6 MySQL # cd MySQL # chown-r mysql:mysql. # scripts/mysql_install_db--user=mysql--datadir=/mydata/mysql # chown-r root.

4. Provide the main configuration file for mariadb:

# cd/usr/local/mysql # CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF


Note: And modify the value of thread_concurrency in this file by multiplying the number of your CPUs by 2, for example using the following line:

Thread_concurrency = 2, also add the following line to specify the location of the MySQL data file: DataDir =/mydata/data

5. Provide service scripts 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

6. Add to the list of services:

# chkconfig--add mysqld # chkconfig mysqld on start-up service

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/57/38/wKioL1SVS_-SC9PSAAG9d0gJcg0451.jpg "title=" Mysql.png "alt=" Wkiol1svs_-sc9psaag9d0gjcg0451.jpg "/>

Three. Compile and install php-5.4.26

1. Resolve dependencies: The same configuration is good for the compilation environment.

# yum-y Install Bzip2-devel|libmcrypt-devel|openssl-devel|libxml2-devel and so on.

2. Compile and install php-5.4.26

# 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

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/57/3B/wKiom1SVT9GD3AtaAAHzU-SBhUk559.jpg "title=" Haole.png "alt=" Wkiom1svt9gd3ataaahzu-sbhuk559.jpg "/>

Explain:

A. These focus options, when used in addition, are found in the./configure--help.

--with-mysql=/usr/local/mysql indicates the mysql-devel location of the installation. But here we are binary version MySQL already contains mysql-devel.

--with-openssl indicates that the OpenSSL feature is enabled.

--with-mysqli=/usr/local/mysql/bin/mysql_config indicates another program entry for MySQL.

--enable-mbstring Multi-character processing

--with-jpeg-dir JPEG image format processing

--with-png-dir PNG image format processing

--with-zlib zlib Compression

--WITH-LIBXML-DIR=/USR indicates the directory of Libxml

--enable-sockets Support sockets

--with-apxs2=/usr/local/apache/bin/apxs This is an important option to compile PHP into a httpd module.

--with-mcrypt encryption

--WITH-CONFIG-FILE-PATH=/ETC indicates the configuration file placement path

--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D indicates the scan path

--enable-maintainer-zts



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

C. If you are using PHP5.3 or above, you can specify MYSQLND to link to the MySQL database so that you do 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 # do test # Make I Ntall


Here is a configuration file for PHP:

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

3, edit Apache configuration file httpd.conf, with Apache support PHP

# vim/etc/httpd22/httpd.conf//Find AddType application/x add AddType application/x-httpd-php below. php AddType Applica Tion/x-httpd-php-source. Phps directoryindex index.php index.html/Find DirectoryIndex index.html add index.php

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

4. Test whether the lamp platform we built is successful

     #mv  /usr/local/apache22/htdocs/index.html /usr/local/apache22/htdocs/ index.php     #vim  /usr/local/apache22/htdocs/index.html    < html>    <body>    

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/57/39/wKioL1SVU7yCJ6A2AABfg7Wsda8787.jpg "title=" 111111111.png "alt=" Wkiol1svu7ycj6a2aabfg7wsda8787.jpg "/>















This article is from the "I and Linux years" blog, please be sure to keep this source http://guanqianjian.blog.51cto.com/9652236/1592051

Lamp platform Construction and its principle explanation

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.