Quick architecture of a complete lapm solution for separating MySQL from Apache

Source: Internet
Author: User
Tags gz file install wordpress

Quick architecture of a complete lapm solution for separating MySQL from Apache

Author: Wei Yan

 

I. Solution Analysis:

 

We have built three servers, two for the Web server and one for the Mysql Data Server. Two Web servers directly connect the received data requests to the underlying MySQL server. Store all the data on the MySQL server.

Here we use WordPress, the most popular personal blog site, as our testing website.

 

II. Implementation Method:

We adopt a practical NFS sharing mechanism to share data on the MySQL server directly to two Web servers. when data is accessed through the web server, the MySQL database on another host is automatically located in PHP.

 

Iii. Implementation Method:

1. Configure the MySQL server:

First, we need to configure the location of the yum installation source.

Then make sure that all important development kits have been successfully installed. They are:

"Developmenttools"

"Developmentlibraries"

"Legacysoftware Development"

"X softwaredevelopment"

"MySQLDatabase"

"Webserver"

Create a MySQL user and group for MySQL:

groupadd -g 3306mysqluseradd -u 3306-g mysql -M -s /sbin/nologin mysql

Do not forget to disable SELinux on any host.

serenforce 0

Create a directory for storing data and mount the configured logical volume to the top (/mydata)

And grant it MySQL permissions:

chown -R mysql:mysql /mydata

Decompress the downloaded mysql-5.5.15-linux2.6-i686.tar.gz file to/usr/local.

tarxf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local

Create a link directory to make the simple directory name our working directory:

cd /usr/local        ln -sv mysql-5.5.15-linux2.6.i686 mysql

Change the owner Group of the MySQL directory to the MySQL user and MySQL group.

cd mysql chown -R mysql:mysql .

Initialize MySQL

scripts/mysql_install_db --user=mysql--datadir=/mydata/data

MySQL cannot be started at this time.

Change owner to root user

chown -R root .        

Prepare scripts for MySQL to start the required services

cp support-files/mysql.server/etc/init.d/mysqld

Add to service queue

chkconfig --add mysqld

Start startup

chkconfig mysqld on

At this time, an error will be reported if it is started. By default, MySQL will find the data directory under its installation directory as its data directory.

Prepare the main configuration file for it

cp support-files/my-large.cnf /etc/my.cnf

Edit this file and give it a datadir directory

Vim/etc/My. CNF: datadir =/mydata/data and change thread_concurrency = to the number of your CPU cores x 2.

In this case, the instance can be started normally.

service mysqld start

If a startup error occurs, go to/mydata/data/localhost. localdomain. Err to view the error message.

At this time, we have not fully prepared mysql. We also need to prepare its library file and header file.

Import file:

Vim/etc/lD. So. conf. d/MySQL. conf:/usr/local/MySQL/lib

Ldconfig

Use ldconfig to reload

Import the header file, PATH environment variable:

Ln-SV/usr/local/MySQL/include/usr/include/mysqlvim/etc/profile write: Path = $ path:/usr/local/MySQL/bin

So far, all of our MySQL has been installed and can be officially started:

servicemysqld restart 

 

2. install Wordpress

Decompress the downloaded WordPress and place it in the relevant location:

         unzipwordpress-3.0.4-zh_CN.zip         mkdir–p /var/www/html/wordpress         mvwordpress/* /var/www/html/wordpress         rm–rf wordpress

Okay. Next, let's configure the WordPress related files.

         cd/var/www/html/wordpress         cpwp-config-sample.php wp-config.php

Modify

         define('DB_NAME','wordpress');         define('DB_USER','root');         define('DB_PASSWORD','aaa');         define('DB_HOST','192.168.0.44');

Make the configuration file corresponding to you.

Log on to the MySQL server and create a database for WordPress and the user and password for remote access.

         mysql         >CREATEDATABASE wordpress;         >GRANT ALL PRIVILEGES ON *.* TO root@'%.%.%.%' IDENTIFIED BY 'redhat';         >FLUSHPRIVILEGES;         >\q

 

3. Configure NFS for file sharing

Open/etc/exports

Add

    /var/www/html192.168.0.0/24(rw,async)  

Note that the CIDR Block corresponds to the CIDR block of your Web server.

Enable NFS service

Servicenfs start chkconfignfs on enables rpcinfo-P check on startup, and many ports are enabled.

 

 

4. Start configuring two web servers.

. Mount the NFS shared directory

Mkdir/mnt/Web # create the directory showmount-e 192.168.0.44 # this IP address is the IP address of your MySQL Server Mount-t nfs 192.168.0.44: /var/www/html/mnt/Web

4.2 install httpd

Here we use the yum source to install httpd

         yuminstall httpd -y 

4.3 install PHP and Related Programs

         yuminstall php php-mysql php-mbstring –y 

4.4 configure httpd. conf

Open/etc/httpd/CONF/httpd. conf

Modify DocumentRoot "/var/www/html" to DocumentRoot "/mnt/web/WordPress /"

Modify <directory "/var/www/html"> to <directory "/mnt/web/WordPress">

Add index. php to directoryindex.html index.html. var.

Join

        AddTypeapplication/x-httpd-php .php        AddType application/x-htppd-php-source .phps

 

4.5 restart the HTTPd service

servershttpd start

Okay. Now ~ Our web server has been fully configured. At this time, if you enter the IP address of your Web server in your browser, it will display a complete WordPress 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.