Lamp Simple Architecture Experiment: apache+nfs+mysql

Source: Internet
Author: User
Tags create directory openssl php server php and mysql

Experimental requirements

    1. Two Web servers, apache-2.4[compilation] + php-5.6.14[compilation];

    2. Database server, mariadb-5.4.46[Universal binary];

    3. NFS server, storing web page files;

    4. DNS do round-robin, pointing to the two Web servers, the role of load balancing, of course, can also do a single point of failure to switch;

    5. Set up is the DZ Forum, requires the implementation of load balancing, to ensure consistent data, that is, through WEB1 access to the Forum data and web2 consistent;

The topology is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/1E/wKioL1YzFBzx8zlMAA3cwI7OQDQ648.bmp "title=" Drawing1.bmp "alt=" Wkiol1yzfbzx8zlmaa3cwi7oqdq648.bmp "/>


Experiment Step 1. Deploy WEB1

1.1 Installing the compiled development environment

Yum Groupinstall "Development Tools" "Server Platform Development"-Y

1.2 Compile and install Apr-1.5"because Apache2.4 relies on 1.4 or more versions of APR and Apr-util"

./configure--prefix=/usr/local/aprmake && make install

An error has been encountered here:

Error : Rm:cannot remove ' libtoolt ': No such file or directory

FIX: Edit directory under Configure file, watch out # $RM "$cfgfile"

1.3 Compiling and installing Apr-util

./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/aprmake && make install

1.4 Compiling and installing Apache-2.4

Specify APR, Apr-util path, otherwise it will be automatically found if there are 1.4 versions of APR on the system may be wrong!

./configure--prefix=/usr/local/apache--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--with-mpm=prefork

1.5 Create Apache user, run for httpd2.4 process

Groupadd-r-G apacheuseradd-r-U 48-g Apache

1.6 Edit Apache config file, run Web process as Apache user

vi/etc/httpd/httpd.conf164 line User apache165 line Group Apache

1.7 Preparing the PHP installation environment

Yum-y install zlib zlib-devel bzip2 bzip2-devel freetype freetype-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel L Ibxslt libxslt-devel libpng libpng-devel libjpeg-turbo libjpeg-turbo-devel Curl libcurl-devel gd-devel OpenSSL

Careful you must find that the package is mostly in pairs appear, please note that the General-devel package is not installed, Devel package needs to specify Epel source, anyway I use Aliyun epel source http://mirrors.aliyun.com/repo/

Perhaps some special CMS need special PHP library support, can be through the PHP phpize post-Convenient compilation after the call.


1.8 Compiling and installing Libiconv

wget./configure--prefix=/usr/local/libiconvmake && make install

1.9 Compiling and installing PHP

./configure--prefix=/usr/local/php--with-config-file-path=/etc/php/php.ini--with-config-file-scan-dir=/etc/ php.d/--with-apxs2=/usr/local/apache/bin/apxs--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir --with-zlib--with-bz2--enable-xml--with-xsl--with-libxml-dir--with-mcrypt--with-openssl--with-curl--with-iconv =/usr/local/libiconv--enable-sockets--enable-short-tags--enable-static--enable-gd-native-ttf--enable-ftp-- Enable-maintainer-zts--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd

For PHP and MySQL connection driver issues, you can refer to my blog "


1.10 Editing a PHP configuration file

Mkdir/etc/php/cp/download/php-5.6.14/php.ini-production/etc/php/php.inivim/ect/php/php.inidata.timezone = "Asia/ Shanghai "Modify time zone

1.11 Editing the Apache master configuration file

Vim/etc/httpd/httpd.confloadmodule php5_module modules/libphp5.soaddtype application/x-httpd-php. php. PhtmlAddType Application/x-httpd-php-source. Phps<ifmodule Dir_module>directoryindex index.php Index.html</IfModule >

Note that due to the relative path used by the loaded libphp5.so, and/usr/local/apache is not written to the environment variable, there may be a problem. Suggested Export Path=/usr/local/apache:/usr/local/apache/bin: $PATH


1.12 Edit a test page to see if the test was successful!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/22/wKiom1YzGrCx5vVvABNDZGqK5DE548.bmp "title=" Baidushurufa_2015-10-30_15-21-58.bmp "alt=" Wkiom1yzgrcx5vvvabndzgqk5de548.bmp "/>


At this point, the Web server side has been installed! The Web1 and WEB2 installation steps are the same.


Lab Step 2. Deploying MARIADB Server

2.1 Universal Binary Installation MARIADB

Before successfully deploying MARIADB Server, please refer to my blog "MARIADB Universal Binary Deployment Manual"


2.2 Creating a Database

In the schema, MARIADDB server is independent of the Web server, so the PHP engine on the Web server connects to MARIADB server via the Php-mysql driver is a remote connection based on the TCP/IP protocol stack, which requires authorization on the database server

CREATE DATABASE bbs;grant all privileges in bbs.* to ' BBS ' @ ' 10.134.140.% ' identified by ' zxczxc ' with GRANT OPTION; FLUSH privileges;

2.3 Viewing Database authorization information

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/20/wKioL1YzHYqyvHT2AAZAkCKk770108.bmp "title=" Baidushurufa_2015-10-30_15-31-42.bmp "alt=" Wkiol1yzhyqyvht2aazakckk770108.bmp "/>

At this point, the database server has been built!


Lab Step 3. Deploying NFS Server

NFS server in the architecture assumes the function of storing Web page data, to be able to read and write to the front-end WEB1 server and WEB2 server properly!

3.1 Create directory, unzip DZ BBS

Mkdir/wwwroot && Cd/wwwrootwget Unzip Discuz_x3.2_sc_utf8.zip

3.2 Creating a user

This user wants to be the same as the UID, GID of the Apache user on the front-end Web server, which is to ensure that the front-end Web server mounts the NFS read-write permission effectively and securely

Groupadd-r-G apacheuseradd-r-u 48-g apachesetfacl-r-M u:apache:rwx/wwwroot/

3.3 Editing an NFS configuration file

Vi/etc/exports/wwwroot 10.134.140.63 (rw,async,all_squash,anonuid=48,anongid=48) 10.134.140.64 (Rw,async,all_ SQUASH,ANONUID=48,ANONGID=48) Service NFS Start

At this point, the NFS server is set up, all Web content is stored under/wwwroot/bbs, only allow 10.134.140.63/64 mount the directory, and the use of the directory is mapped to an Apache User on NFS server, and the Apache user wwwroot/permission is rwx


Experiment Step 4. Mount NFS, configure the primary site

4.1 Mount the remote wwwroot on the Web server

Mkdir/wwwroot/setfacl-r-M u:apache:rwx/wwwroot/mount-t NFS 10.134.140.66:/wwwroot//wwwroot/

4.2 Editing the primary site configuration file

Vi/etc/httpd/httpd.confdocumentroot "/wwwroot/bbs" <directory "/wwwroot/bbs" >....</Directory>

4.3 mount the same on the Web Server2! Modify the primary site configuration file.

At this point, all configurations are ready to be tested after all services are properly started!


Experiment Step 5. Test architecture

5.1 Accessing the Web Server1 for the initial installation of the DZ Forum

Check the environment, you can see the support of the various components, very lucky, all satisfied!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/75/23/wKiom1YzIziiOIBlABIq-PRJsJg603.bmp "title=" 1.bmp " alt= "Wkiom1yziziioiblabiq-prjsjg603.bmp"/>



5.2 Setting up the operating environment

[Skip, no impact, is set DZ Forum cluster]


5.3 Creating a Database

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/23/wKiom1YzJK6glOh0ABK8WNm-VGI952.bmp "title=" 2.bmp " alt= "Wkiom1yzjk6gloh0abk8wnm-vgi952.bmp"/>

After the next step, wait for the installation to complete! Can successfully visit the DZ Forum!


5.4 Posting via WEB1 server

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/23/wKiom1YzJZLAS4kuABDjiE-3QOw242.bmp "title=" 3.bmp " alt= "Wkiom1yzjzlas4kuabdjie-3qow242.bmp"/>


5.5 Validation with WEB2 server

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/75/21/wKioL1YzJevBeK9dABTH7ENfU6Y595.bmp "title=" 4.bmp " alt= "Wkiol1yzjevbek9dabth7enfu6y595.bmp"/>


The architecture experiment is almost complete!


Some summary

    1. Front-end DNS server limited to space I did not do, directly using 63/64 address access effect consistent ~ lazy;

    2. The installation of the DZ Forum in the experiment found the hint "database connection error", and finally found that the iptables rule caused, empty OK;

    3. Most of the time, the compilation installation prompted a package XX did not install, and they did pretend, this is generally due to xx-devel attached package, the designation of a good EPEL source, installation can be;

    4. The common components have been pre-compiled at PHP compile time, if some CMS needs special components, without recompiling,phpize can dynamically compile the new build, and then modify php.ini to call the so;

    5. The vast majority of server startup failures, No 3 reasons:

      1. Not enough permissions for a specific directory!

      2. The installation or startup script uses a relative path, and the environment variable is not written!

      3. There is a problem with the configuration file!

I hope this can help you, of course, the above architecture can also be PHP and Apache split, front-end Apache response to static content, through fastcgi php dynamic request to PHP server!

This article is from the "Blue Warehouse" blog, be sure to keep this source http://bluebox.blog.51cto.com/8852456/1708108

Lamp Simple Architecture Experiment: apache+nfs+mysql

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.