LAMP combines NFS to build a small blog site

Source: Internet
Author: User
Tags mysql host php server wordpress database wordpress blog

LAMP combines NFS to build a small blog site

Network File System (NFS) is a distributed File System protocol, initially developed by Sun Microsystems and released in 1984 [1. This function allows the client host to access server files over the network just like accessing local storage. Like many other protocols, NFS is based on the Open Network Computing Remote Procedure Call (onc rpc) protocol. NFS is an open and standard protocol in RFCs. Anyone or organization can implement it according to the standard.

In fact, NFS shares files through Remote Procedure Call. We all know that if a process wants to use a certain file, the same system call is required to apply to the kernel, and RPC is the call request to convert this system call to send files to another remote host through the network, in this way, the file system can be shared. Of course, this will also cause many problems. What should I do if the storage formats between the Client and NFS Server are not compatible, how should I authenticate users, and how should I limit user permissions.

To solve the format incompatibility, we use semi-structured data. Such data can fully describe the meaning of its own data without being parsed by the other party, such as XML, JSON, RESTful transmission is based on http. For user authentication, we used NIS (Network Information System, 2049/tcp, 2049/udp) earlier. This Protocol transfers user authentication to a remote server instead of a local server. However, this authentication method is not encrypted and is easy to form a single point of failure, so it is not common now. We now use two processes, idmapd and mountd, on the NFS server.

Idmapd: Maps Remote users to the local nfsnobody.

Mountd: user verification is performed before nfs access. After verification, a token is provided to the user. The user obtains the token and then performs data access. The port is random.

 

We have a simple understanding of NFS here. The topic of this article is to use LAMP to build a simple blog site with NFS, in the construction process, we will detail how to set up NFS. Let's take a look at the physical topology:

This topology is planned as follows: the client uses DNS rotation scheduling to allow users to access two web servers for load balancing, while the dynamic content on the web page is processed by the PHP Server, user blog account information is stored on MariaDB Server, and page files are stored through the file system shared by NFS Server.

Okay. Let's build this topology step by step. We can see that there are six servers in the figure. I use virtual machines and only three servers, so I will compress this topology:

DNS Server & Web1: IP à 192. 168.23.132

PHP Server & Web2: IP à 192. 168.23.130, 192.168.80.129

NFS Server & MariaDB Server: IP à 192. 168.80.130


I have already debugged the network, and each IP can be pinged to each other.

1. the DNS Server has been created and can be used to schedule two web sites:

2

2. Configure Web1/Web2 sites

Compile and install httpd-2.4 I talked about in the previous blog, it is no longer a detailed explanation, just look at the configuration just fine.

I am not using a VM anymore to save time. As for PHP server compilation and installation, it will be fine after it is started. There is no additional configuration. If you are not clear about it, you can go to my previous blog

Vim/etc/httpd24/httpd. conf

216 DocumentRoot "/web/blog"

217 ProxyRequests Off

218 ProxyPassMatch ^/(. * \. php) $ fcgi: // 192.168.23.130: 9000/web/blog/$1

219 <Directory "/web/blog">

251 <IfModule dir_module>

252 DirectoryIndex index. php index.html

253 </IfModule>

381 AddType application/x-httpd-php. php

382 AddType application/x-httpd-php-source. phps

115 LoadModule proxy_module modules/mod_proxy.so

119 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so


3. Configure NFS

Yum install nfs-utils

[Root @ db ~] # Vim/etc/exports

/Web/blog 192.168.23.132 (rw, async, no_root_squash) 192.168.23.130 (rw, async, no_root_squash) 192.168.80.129 (rw, async, no_root_squash)

# No_root_squash here can be left blank, because I have been trying to write permission on the client during my experiments.

# Another reminder is that we can create a user with the same user name and ID number as the httpd process started on the web server, and then set facl for it, or the starting user of the httpd process is nobody.

Setfacl-R-m u: http: rwx/web/blog

Tar xf/root/wordpress-4.2.2-zh_CN.tar.gz-C/web/

Mv wordpress blog

Cp wp-config-sample.php wp-config.php

Vim wp-config.php.

17/** WordPress database name */

18 define ('db _ name', 'blog ');

19

20/** MySQL database username */

21 define ('db _ user', 'buser ');

22

23/** MySQL Database Password */

24 define ('db _ password', 'bpass ');

25

26/** MySQL host */

27 define ('db _ host', '192. 168.80.130 ');


4. Configure MariaDB

Cat ~ /. Mysql_history # view mysql History commands

Create database blog;

Grant user buser @ '192. 192. %. % 'identified by 'bpass ';

Create user buser @ '192. 192. %. % 'identified by 'bpass ';

Grant all on blog. * to buser @ '192. 192. %. % ';

Flush privileges;

# Here, because I used to build a blog experiment, a lot of data is left over and a bunch of problems are generated, So I deleted a lot of tables, which reflects the ease of use of phpMyadmin.

5. mount NFS in Web1 & Web2

Mount-t nfs 192.168.80.130:/web/blog/

Vim/etc/fstab

192.168.80.130:/web/blog nfs ults, _ netdev 0 0

# Automatic mounting upon startup

6. Test Access and upload data

 

Let's explain this result a little. Because I accessed it from a physical machine, I didn't use DNS, but we saw in the DNS test results that load balancing can be achieved. Another point is that my PHP Server and Web2 are on the same host, so once I log on, I will jump to the IP address of Web2. I hope you will understand that Web1 is not unavailable.

Okay, so far our small blog website has been set up. In fact, most of the websites are from small to large, we will continue to expand on this basis to complete a series of highly concurrent and reliable websites. If any errors occur, please note.

Install Xcache and Memcached on the LAMP platform to accelerate website operation

Build a LAMP platform environment in CentOS 7

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

Install LAMP in Ubuntu 14.10

This article permanently updates the link address:

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.