Using remote NFS shared resources for site building based on lamp platform

Source: Internet
Author: User

Requirements:

Build an NFS Shared service, use NFS to provide remote shared resources, and Web services to build a lamp-based site (WordPress) with remote shared resources, requiring this site to publish articles and images normally


Environment:

192.168.1.101----->web

192.168.1.110----->MARIADB

192.168.1.113----->php

192.168.1.114----->nfs


First, the deployment lamp environment

#web服务的部署 (192.168.1.101)

(1) Installation service: Yum-y install httpd

(2) Configure the virtual host and PHP proxy

[[email protected] ~]# vim /etc/httpd/conf.d/vhost.confdirectoryindex index.php< virtualhost 192.168.1.101:80>        servername  wp.magedu.com        documentroot /data/web  ### Directories such as this will rely on NFS to remotely share a wordpress        proxyrequests off         proxypassmatch ^/(. *\.php) $ fcgi://192.168.1.113:9000/data/web/$ 1         <directory  "/data/web" >                 Options None                 allowoverride none                 Require  all granted        </Directory> </VirtualHost> 


(3) Start the service test httpd is normal

[[email protected] ~]# mkdir-p/data/web/[[email protected] ~]# vim/data/web/index.html (test content tested) [[email protected] ~] # httpd-tsyntax Ok[[email protected] ~]# systemctl start httpd [[email protected] ~]# Curl Http://wp.magedu.comtest


#mariadb服务部署 (192.168.1.110)

(1) Installer: yum-y Install Mariadb-server

(2) Start the service, establish the database and user authorization operation

[[email protected] ~]# systemctl start mariadb[[email protected] ~]# mysql mariadb [(none)]> CREATE Database wpdb; # # #这是为了WordPress准备MariaDB [(none)]> grant all on wpdb.* to ' wpuser ' @ ' 192.168.%.% ' identified by ' wppass ';


#php服务部署 (192.168.1.113)

(1) Installer: yum-y Install PHP-FPM Php-mysql

(2) Configure PHP

[Email protected] ~]# vim/etc/php-fpm.d/listen.allowed_clients = 192.168.1.101

(3) Build files on PHP server to test the connectivity of PHP and HTTP and mariadb

[Email protected] ~]# mkdir-p/data/web [[email protected] ~]# Vim/data/web/index.php<?php$conn = mysql_connect (' 192        .168.1.110 ', ' wpuser ', ' wppass ');        if ($conn) echo "MySQL is OK"; else echo "MySQL is bad";p hpinfo ();? >

(4) Start-up service

[[email protected] ~]# systemctl start php-fpm[[email protected] ~]# ss-tnl State recv-q send-q Loca Peer Addr Ess:port LISTEN 0 128 192.168.1.113:9000

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/89/wKioL1eTXpezrh9HAABjSBEx2aY408.png "title=" 2.png " Width= "720" height= "283" border= "0" hspace= "0" vspace= "0" style= "width:720px;height:283px;" alt= " Wkiol1etxpezrh9haabjsbex2ay408.png "/>

OK, now the lamp environment and ready.



Ii. Deploying an NFS environment to provide remote shared resources

(1) Installation service: Yum-y Install Nfs-utils

(2) Configure the NFS service to provide resources for the Web site

[Email protected] ~]# vim/etc/exports/data/application/web 192.168.1.0/24 (Rw,sync)

(3) Creating an NFS shared path

[Email protected] ~]# mkdir-p/data/application/web

(4) Provide and configure the good one WordPress service under the NFS share path

[Email protected] ~]# unzip wordpress-4.3.1-zh_cn.zip [[email protected] ~]# MV Wordpress/data/application/web/[[email Protected] ~]# Cd/data/application/web/wordpress/[[email protected] web]# cp wp-config-sample.php wp-config.php [[ Email protected] web]# VIM wp-config.php//* * MySQL Settings-specific information from the host you are using * *///** the name of the WordPress database */define (' db_name ', ' WPD B ');/** MySQL database user name */define (' Db_user ', ' wpuser ');/** MySQL database password */define (' Db_password ', ' wppass ');/** MySQL host */ Define (' Db_host ', ' 192.168.1.110 ');/** the default text encoding when creating a data table */define (' db_charset ', ' UTF8 ');

(4) Start NFS service

[[email protected] wordpress]# service nfs start  Startup  NFS  Service:                                               [OK] turn off  NFS  quotas:                                               [OK] Start  NFS mountd:                                            [OK] start  NFS  daemon:                                          [OK] is starting &NBSP;RPC  idmapd:                                        [Determine][[email protected] wordpress]# ss -tnl state        Recv-Q Send-Q                 Local Address:Port          Peer Address:Port LISTEN      0       64                        :::42365                       :::*      LISTEN       0      64                        :::2049                         :::*      LISTEN      0       64                        *:2049 # #nfs监听地址

(5) View the shared resources we provide

[[email protected] ~]# showmount-e 192.168.1.114Export list for 192.168.1.114:/data/application/web 192.168.1.0/24


Third, remote mount shared resources debugging

(1) Failover of NFS-provided shared directories on PHP and HTTPD servers, respectively

[Email protected] web]# mount-t NFS 192.168.1.114:/data/data/application/web/

(2) Reload httpd and PHP-FPM services separately

[[email protected] ~]# systemctl restart Php-fpm.service[[email protected] web]# systemctl restart httpd

(3) test

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/84/8A/wKioL1eTe0bTXq7jAAcTv-k6l4Q823.png "title=" 12.png "Width=" 720 "height=" 426 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:720px;height:426px; "alt=" Wkiol1ete0btxq7jaactv-k6l4q823.png "/>


Using remote NFS shared resources for site building based on lamp platform

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.