LAMP-based AMP separation + XCache Acceleration

Source: Internet
Author: User
Tags php server

LAMP-based AMP separation + XCache Acceleration

Lab requirements

  • To build a LAMP platform, apache, php, and MariaDB are required to separate dynamic and static data on different servers;
  • Build blogs and forums on the LAMP platform. The blogs and forums are located on different hosts;
  • In addition to httpd, Internet users cannot access any server on the Intranet;
  • After the deployment is complete, use the AB command for stress testing, and deploy Xcache to provide acceleration for php.
The environment topology is as follows:

Deployment idea network environment:

The Apache server uses a dual Nic. One Nic listens to user requests from the Internet, and one Nic communicates with the Intranet service area. The apache Intranet Nic is connected to other servers using a vswitch.

Interaction between Apache and php:

There are three ways for Apache to interact with php: cgi, module, and fcgi. However, cgi and fcgi can access php servers across hosts. Therefore, apache and php servers can only interact with each other using fcgi.

Interaction between php and MariaDB:

When installing bbs and blog, you are required to provide information such as MariaDB database and user password. Therefore, you only need to create relevant databases and users in MariaDB data, and then ensure that the php server can be accessed.

Bbs and blog installation problems:
  1. The installed package must exist on both apache and php servers. apache provides static page access while php provides dynamic page access. synchronization is not considered.

  2. If you require write permission on the program, the static server sets daemon to writable files for apache service users, and the dynamic server sets the php-fpm service user nobody to writable files.

Lab Environment

System Version

Host Name

IP address

Apache

CentOS 6.6 64-bit

Web-01

Internet: eth0: 1.1.1.1

Intranet: eth1: 172.16.4.100

Forum

Centos 6.6 64-bit

Bbs-01

Intranet: eth0: 172.16.4.101

Blog

Centos 6.6 64-bit

Blog-01

Intranet: eth0: 172.16.4.102

Database

Centos 6.6 64-bit

MariaDB-01

Intranet: eth0: 172.16.4.136

Use software
apr-1.5.0.tar.bz2apr-util-1.5.3.tar.bz2httpd-2.4.10.tar.bz2mariadb-5.5.43-linux-x86_64.tar.gzphp-5.4.40.tar.bz2wordpress-3.3.1-zh_CN.zipxcache-3.2.0.tar.bz2Discuz_7.2_FULL_SC_UTF8.zip

------------------------------------ Split line ------------------------------------

CentOS 6.5 system installation and configuration LAMP (Apache + PHP5 + MySQL) server environment

Configure the LAMP + phpMyAdmin PHP (5.5.9) development environment in Ubuntu 14.04

Ubuntu 14.10 text tutorial on hard drive installation in Windows 7

Install Ubuntu 14.10 on a USB flash drive

Official release and download of Ubuntu 14.10

How to upgrade Ubuntu 14.04 LTS to Ubuntu 14.10

Install LAMP in Ubuntu 14.10

------------------------------------ Split line ------------------------------------


Apache configuration

Resolve Dependencies

yum -y groupinstall "Development tools""Desktop Platform Development"yum -y install pcre-devel openssl-devel tar xf apr-1.5.0.tar.bz2cd apr-1.5.0./configure --prefix=/usr/local/aprmake && make installcd .. tar xf apr-util-1.5.3.tar.bz2cd apr-util-1.5.3./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/aprmake && make installcd ..

Compile and install httpd

tar xf httpd-2.4.10.tar.bz2cd httpd-2.4.10./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24--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 --with-mpm=eventmake && make install

Modify the PATH variable so that the system can directly find the http command PATH

[root@web-01 httpd-2.4.10]# vim/etc/profile.d/httpd.shexport PATH=/usr/local/acaphe/bin:$PATH[root@web-01 httpd-2.4.10]# ./etc/profile.d/httpd.sh[root@web-01 httpd-2.4.10]# which httpd/usr/local/apache/bin/httpd

Set the Startup Script

[Root @ web-01 httpd-2.4.10] # cp/usr/local/apache/bin/apachectl/etc/init. d/httpd24 [root @ web-01 httpd-2.4.10] # vim/etc/init. d/httpd24 #! /Bin/sh # chkconfig: 35 85 15 # Set service identification parameters, Level 3 and Level 5 startup, startup sequence 85, closing sequence 15 # description: apache # service description [root @ web-01 ~] # Chkconfig -- add httpd24 [root @ web-01 ~] # Chkconfig -- level 35 httpd24 on [root @ web-01 ~] # Chkconfig -- list httpd24httpd24 0: off 1: off 2: off 3: on 4: off 5: on 6: off

Modify the httpd configuration file to set the listening port

[root@web01 ~]# vim /etc/httpd24/httpd.confListen 1.1.1.1:80Listen 172.16.4.100:80

Start the service and access Verification

[root@web01 ~]# service httpd24 start[root@web01 ~]# netstat -lnt | grep 80tcp       0      0 172.16.4.100:80             0.0.0.0:*                   LISTEN     tcp       0      0 1.1.1.1:80                  0.0.0.0:*                   LISTE

Virtual Host Configuration

Edit the master configuration file, comment the center host, and enable the VM option.

[root@web01 ~]# vim /etc/httpd24/httpd.conf#DocumentRoot "/usr/local/apache/htdocs"  Include /etc/httpd24/extra/httpd-vhosts.conf

Set VM

[root@web01 ~]# vim/etc/httpd24/extra/httpd-vhosts.conf<VirtualHost *:80>ServerName bbs.discuz.comDocumentRoot "/www/bbs"<Directory "/www/bbs">Options noneAllowOverride noneRequire all granted</Directory> ErrorLog"/var/log/httpd/bbs-error-log" CustomLog"/var/log/httpd/bbs-access-log" common</VirtualHost><VirtualHost *:80>ServerName blog.wordpress.comDocumentRoot "/www/blog"<Directory "/www/blog">Options noneAllowOverride noneRequire all granted</Directory> ErrorLog"/var/log/httpd/blog-error-log" CustomLog"/var/log/httpd/blog-access-log" common</VirtualHost>

Set the virtual host directory

[root@web01 ~]# mkdir -p /www/{bbs,blog}[root@web01 ~]# echo bbs > /www/bbs/index.html[root@web01 ~]# echo blog > /www/blog/index.html

Access test Vm

MariaDB Configuration

Configure/dev/sda3 as lvm Partition

[root@MariaDB-01 ~]# fdisk -l /dev/sda Disk /dev/sda: 128.8 GB, 128849018880 bytes255 heads, 63 sectors/track, 15665 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000471dd    DeviceBoot      Start         End      Blocks  Id  System/dev/sda1  *           1          26      204800  83  LinuxPartition 1 does not end on cylinder boundary./dev/sda2              26        7859   62914560   8e  Linux LVM/dev/sda3           7859       11775    31462303+ 8e  Linux LVM

Create logical volume

[root@MariaDB-01 ~]# lvcreate /dev/sda3[root@MariaDB-01 ~]# vgcreate myvg /dev/sda3[root@MariaDB-01 ~]# lvcreate -L 15G -n mydata myvg[root@MariaDB-01 ~]# lvs  LV     VG  Attr       LSize  Pool Origin Data%  Meta% Move Log Cpy%Sync Convert  mydata myvg-wi-a----- 15.00g                                                     root   vg0 -wi-ao---- 20.00g                                                     swap   vg0 -wi-ao----  2.00g                                                     usr    vg0 -wi-ao---- 10.00g                                                     var    vg0 -wi-ao---- 20.00g

Format and Mount

[root@MariaDB-01 ~]# mkfs.ext4 /dev/myvg/mydata[root@MariaDB-01 ~]# vim /etc/fstab/dev/myvg/mydata        /mydata                 ext4    defaults        0 0[root@MariaDB-01 ~]# mkdir /mydata[root@MariaDB-01 ~]# mount -a

Create a MariaDB service user and set the owner Group of the data directory as the service user.

[root@MariaDB-01 ~]# groupadd -r mysql[root@MariaDB-01 ~]# useradd -g mysql -r -s/sbin/nologin -M mysql[root@MariaDB-01 ~]# mkdir /mydata/data[root@MariaDB-01 ~]# chown -R mysql:mysql/mydata/data/

Install MariaDB and initialize

tar xf mariadb-5.5.43-linux-x86_64.tar.gz -C/usr/local/cd /usr/local/ln -sv mariadb-5.5.43-linux-x86_64/ mysqlcd mysql/chown -R mysql:mysql .scripts/mysql_install_db --user=mysql--datadir=/mydata/data/

Provide the main configuration file for MariaDB

[Root @ MariaDB-01 mysql] # cpsupport-files/my-large.cnf/etc/my. cnf [root @ MariaDB-01 mysql] # vim/etc/my. cnfthread_concurrency = 2 # set the number of CPU cores multiplied by 2 datadir =/mydata/data # Set the data file directory innodb_file_per_table = 1 # Use the inoodb engine, each table has one table File

Provide a STARTUP script for MariaDB

[root@MariaDB-01 mysql]# cpsupport-files/mysql.server /etc/rc.d/init.d/mysqld[root@MariaDB-01 mysql]# chkconfig --add mysqld[root@MariaDB-01 mysql]# chkconfig mysqld on[root@MariaDB-01 mysql]# chkconfig --list mysqldmysqld           0:off  1:off  2:on   3:on   4:on   5:on   6:off

Modify the PATH environment variable so that the system can directly use MariaDB-related commands.

[root@MariaDB-01 ~]# vim /etc/profile.d/mysql.shexport PATH=/usr/local/mysql/bin:$PATH[root@MariaDB-01 ~]# . /etc/profile.d/mysql.sh

Start test

[root@MariaDB-01 ~]# service mysqld startStarting MySQL...                                         [  OK  ][root@MariaDB-01 ~]# mysqlWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 2Server version: 5.5.43-MariaDB-log MariaDB Server Copyright (c) 2000, 2015, Oracle, MariaDBCorporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement. MariaDB [(none)]> 

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Next Page

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.