CentOS 6 compiled lamp for dual-machine fastcgi

Source: Internet
Author: User
Tags wordpress database

Demand:


Cenos 6 platform to build lamp, where PHP works as a standalone service

(1) The three are separated from two main units

(2) A virtual host is used to provide phpmyadmin; Another virtual host provides WordPress

(3) Install the cache to provide acceleration for PHP

(4) MPM for prefork model


Attention:

(1) Since httpd is CPU intensive, PHP is IO intensive, while mariadb is CPU intensive and IO intensive. So we put httpd and PHP on a single host, mariadb on one host

(2) as the CentOS 6 platform only provides MySQL RPM package, here we use MARIADB Binary installation package installation

(3) Because PHP runs as a separate service process, the PHP-FPM feature is enabled when compiling PHP

(4) because the version of RPM installation package for each application provided by CentOS 6 is old, we need to install it by compiling the source code.

(5) httpd and PHP need to be connected through the FASTCGI protocol, httpd in fact, as a reverse proxy to work, compile httpd need to enable Proxy and proxy_cgi features

(6) If asked MPM to ask Oh the event model, while PHP as httpd module work, because the event is the threading model, so PHP must enable thread safety features--enable-maintainer-zts


Environment:

Close Iptables and SELinux

Host1: As a front-end Web server ip:10.0.0.61

Host2: As a back-end DB server ip:10.0.0.62

Linux Modify/etc/hosts/

Windows Modify C:\Windows\System32\drivers\etc

10.0.0.61 www.wordpress.com

10.0.0.61 www.phpadmin.com


Configuration:


Host2:


Installing the binary mariadb

#  Add a System user mysql[[email protected] ~]# useradd -r mysql#  unzip the binary installation package placed in '/usr/ local/' directory [[email protected] ~]# tar -xf mariadb-5.5.46-linux-x86_64.tar.gz -c  /usr/local/[[email protected] ~]# cd /usr/local/#  link to ' mysql ' directory [[email  Protected] local]# ln -sv mariadb-5.5.46-linux-x86_64/ mysql ' MySQL '  ->  ' mariadb-5.5.46-linux-x86_64/' #  modify its owner and owner Group [[Email protected] local]# chown -r root: mysql mysql/#  CREATE database to store directory '/data/mysql ' [[email protected] local]# mkdir -pv / data/mysqlmkdir: created directory  '/data ' mkdir: created directory  '/data/mysql ' The #  modifies its owner and owner group. [[email protected] local]# chown -r mysql:mysql /data/mysql/#  installation [[email  protected] local]# cd mysql/[[email protected] mysql]# scripts/mysql_ Install_db --user=mysql --datadir=/data/mysql/#  Copy Service startup script to '/etc/rc.d/init.d ' directory [[email protected]  Mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld


Copy the configuration files and configure them

# CP support-files/my-large.cnf/etc/my.cnf# Vim/etc/my.cnf[client]default-character-set=utf8[mysql] Default-character-set=utf8[mysqld]datadir=/data/mysqlcharacter-set-server=utf8collation-server=utf8_general_ Cidefault-storage-engine=innodbinnodb-file-per-table=trueskip-name-resolve=true


Initialization of the database:

# Start the database [[email protected] mysql]#/etc/init.d/mysqld startstarting MySQL. success! [Email protected] mysql]# SS-TUNL | grep 3306tcp LISTEN 0 *:3306 *:* # Export '/usr/local/mysql/bin/' directory to ' PATH ' system environment variables [[email protected] mysql]# export path=/usr/local/mysql/bin/: $PATH # database initialization settings [[email protected] mysql]# Mysql_ Secure_installation


Authorized:

[[email protected] ~]# Mysql-u root-p# authorized root to operate all databases from a host in the 10.0.0.0/8 network segment. MariaDB [(None)]> grant all privileges on * * to ' root ' @ ' 10.0.0.% ' identified by ' 123456 '; # Create data wpdb for WordPress. MariaDB [(None)]> CREATE database wordpress;# to wordpress creating user WordPress. MariaDB [(None)]> create user ' wordpress ' @ ' 172.18.71.% ' identified by ' WordPress '; # licensed WordPress available from 10.0.0.0/ 8 The host login operation within the network segment WordPress database. MariaDB [(None)]> grant all privileges on wpdb.* to ' WordPress ' @ ' 10.0.0.% ' identified by ' WordPress '; # Overloaded permissions table MariaDB [(n One)]> flush privileges;


Host1


To test whether a database server can be linked

# because CENTOS-6 does not provide mariadb, so install the MySQL client. [[email protected] ~]# Yum install-y mysql# Test Connection HOSTB database [[email protected] ~]# mysql-u root-h 10.0.0.62-p


Add a System User

# Useradd-r Apache


Preparing the development environment

# yum Groupinstall-y "Development tools" "Server Platform Development" # Yum install-y pcre-devel libxml2-devel Libmcryp T-devel Bzip2-devel Libcurl-devel


Prepare the source package:

apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.10.tar.bz2 php-5.4.40.tar.bz2 xcache-3.2.0.tar.bz2


Compile and install Apr:

# Tar XF apr-1.5.0.tar.bz2# cd apr-1.5.0#./configure--prefix=/usr/lcoal/apr# make && make install


Compiling and installing Apr-util

# Tar XF 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


Compiling and installing httpd-2.4.9

# TAR-XF httpd-2.4.10.tar.bz2# cd httpd-2.4.10#./configure--prefix=/usr/local/apache2--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=all--enable-proxy-- enable-proxy-fcgi--with-mpm=prefork[[email protected] httpd-2.4.10]# make && make install


Compile and install PHP, enable FPM feature--ENABLE-FPM

# TAR-XF php-5.4.40.tar.bz2# cd php-5.4.40#./configure--prefix=/usr/local/php--with-config-file-path=/etc-- WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-libxml-dir=/usr--with-mysql--with-mysqli--with-openssl--with-mcrypt --with-png-dir--with-jpeg-dir--with-freetype-dir--with-zlib--with-bz2--with-curl--enable-zip--enable-fpm-- With-fpm-user=apache--with-fpm-group=apache--enable-mbstring--enable-xml--enable-sockets # make && make Test && make Install


Cond...





CentOS 6 compiled lamp for dual-machine fastcgi

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.