Apache+php+mysql Separating and building lamp

Source: Internet
Author: User
Tags configuration php fpm install php mcrypt mysql client php source code install wordpress

Apache+php+mysql Separating and building lamp


Apache and MySQL installations are not described

When layered

1. Apache Configuration file Modification

1), enable the relevant module 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_f

2), if not added in the virtual host, directly in the main configuration file to add

Proxyrequests OFF

Proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/documentroot Path/$1

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

2. Locate to DirectoryIndex index.html

Modified to:

DirectoryIndex index.php index.html

2, MySQL compilation installation is not changed note that the compilation will consume a lot of resources, please add swap memory as appropriate to deal with

MySQL needs to create a remote connection user

Mysql> GRANT all privileges on wpdb.* to ' wpuser ' @ ' percent ' identified by ' wppass ';

Mysql> CREATE DATABASE Wpdb

Mysql> Flush Privileges

3. PHP Installation

Second, compile and install php-5.6.2

1), to resolve the dependency relationship:

Execute after configuring Yum source

Desktop Platform Development

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

Libmcrypt

Libmcrypt-devel

Mhash

Mhash-devel

Recommended configuration Epel source Direct Yum Installation Libmcrypt-devel

2), compile and install php-5.6.2

Tar XF php-5.6.2

CD php-5.6.2

./configure--prefix=/usr/local/php--with-mysql=mysqlnd--with-openssl--with-mysqli=mysqlnd--with-pdo-mysql= Mysqlnd--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/php/-- WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-bz2--enable-maintainer-zts--WITH-GD


Description

Because PHP here is running in fastcgi mode does not need to compile PHP into a httpd module, so to cancel--with-apxs2 this option, If you use more than PHP5.3 version, that is, MySQL and PHP are no longer on the same host, in order to link 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 php5.3, and can be bound to it at compile time (rather than relying on a specific MySQL client binding), but it is the default setting from the beginning of the PHP5.4.

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

The result above is that MySQL, Mysqli, PDO, three operations MySQL extension, are configured to use the MYSQLND library to operate MySQL

The--with-mysql entry specifies the use of the MYSQLND client library and does not need to rely on the MySQL installation path at all. Because it is the use of PHP source code in their own library.

This library is written in a C language and is added to the PHP engine in an extended form.

This library in the PHP source code package, build their own installation, generated in their own in PHP, do not need to rely on the god horse MySQL provided by the client

So as the name implies, called native driver, local drive (operation of MySQL driver).

Make && make install

To provide a configuration file for PHP:

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


3), Configuration php-fpm

Provide 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--list PHP-FPM

Providing configuration files for PHP-FPM

#cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

To edit a php-fpm configuration file:

Vim/usr/local/php/etc/php-fpm.conf

Configure the relevant configuration options for FPM to the value you need and enable the PID file:

PID =/usr/local/php5/var/run/php-fpm.pid

PM = dynamic

Pm.max_children = 50 Maximum number of threads in the same time

Pm.start_servers = 5 Number of threads created at startup

Pm.min_spare_servers = 3 Minimum number of idle threads idle line Cheng Create thread

Pm.max_spare_servers = 5 Maximum number of idle threads idle threads larger than maximum kill idle thread

Listen = 0.0.0.0:9000 Modify 9000 ports for all network cards listening on this computer


Next, you can start PHP-FPM.

Service PHP-FPM Start

Use the following command to verify

#ps aux | grep php-fpm

By default, FPM listens on port 9000 of 127.0.0.1, or you can use the following command to verify that you are listening on the appropriate socket.

Ss-tnul | grep php-fpm

TCP LISTEN 0 *:9000 *:*

4) Create an absolute path to the DocumentRoot path on WordPress

4. Install WordPress

Upload the WordPress package to PHP-FPM and unzip it to the DocumentRoot directory.

Unzip WordPress

MV wordpress/*/var/www/html/

CP wp-config-sample.php wp-config.php

Vim wp-config.php

Modify Db_name database name Db_user user and Db_password user password

Db_host Host name, etc.

In the browser input 192.168.1.138/wp-admin/install.php

Fill in some basic information to complete the installation

Finally: First, thank Marco, MA brother I do not advertise, his video is I have seen the most in line with my thinking logic, a variety of in-depth in the shallow out. Admire admire.

Two, for a long time did not write, that is, did not watch the video is really a sin.

Three, I returned.

Four, the next write LVs


This article is from the "God of the Gods" blog, please keep this source http://lakes.blog.51cto.com/10736359/1764602

Apache+php+mysql Separating and building lamp

Related Article

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.