Connect two Web Servers through NFS

Source: Internet
Author: User
Tags php and mysql hex code

Lab requirements:1. Use three servers a B C and A for the NFS server to store webpage files and MySQL database files.

2. Install mysql-server on,

3. B and c install the web and PHP services, mount the NFS shared folder on server a, and call the MySQL service of server.

Implementation Mechanism:

1. Two Logical volumes are created on the NFS server. One is used to store MySQL database files and the other is used to store webpage files.

2. Shared/www/htdocs folder (storing the logical volumes of webpages)

3. Install Web Services and PHP services on www1 and www2

4. Use the PHP-mysql module to call the mysqld database through TCP/IP

 

Experiment process:

1. Clone three VMS, NFS, www1, and www2.

1) set the memory of a clean Virtual Machine to 300 MB.

2) clone three VMS named NFS, WW1, and WW2.

3) start 3 VMS

2. Change the host names of www1 and www2 to www1 and www2 to avoid conflict.

Take www1 as an example:

1) Use root to log on, view the IP address, and change the IP address to the 172 CIDR Block of the corresponding landline number.

# Ifconfig

# Ifconfig eth0 172.16.14.1

1) Use xshell to log on to www1

> SSH 172.16.14.1

3) modify the host configuration file

# Vim/etc/sysconfig/network // modify the following line

Hostname = www1.dean.com

# Hostname www1.dean.com

# Vim/etc/hosts // Add the following line

172.16.14.1 www1.dean.com www1

The host name has been changed to www1.

# Login

> SSH 172.16.14.1

[Root @ www1 ~] #

 

In the same step as www2, change the host name to www2 (IP configuration to 172.16.14.2)

[Root @ www2 ~] #

 

Iii. Configure the NFS server and install the MySQL database for the NFS server

1) log on to the NFS server as the root user, view the IP address, and change the IP address to 172.16.14.100.

# Ifconfig

# Ifconfig eth0 172.16.14.100

2) use xshell to log on and change the NFS server host name to nfs.dean.com.

> SSH 172.16.14.100

[Root @ station89 ~] # Vim/etc/sysconfig/Network

Hostname = nfs.dean.com

[Root @ NFS ~] # Vim/etc/hosts // Add the following line

172.16.14.100 nfs.dean.com NFS

[Root @ station89 ~] # Hostname nfs.dean.com

[Root @ station89 ~] # Login

> SSH 172.16.14.100

[Root @ NFS ~] #

3) create a 5g logical volume lvnfs and a 10g logical volume lvmydata, mount them to/www/htdocs and/www/lvmydata respectively, and mount them at startup.

Partition two logical volume formats

# Fdisk/dev/SDA

The number of cylinders for this disk isset to 15665.

There is nothing wrong with that, but thisis larger than 1024,

And coshould in certain setups cause problemswith:

1) software that runs at boot time (e.g., old versions of lilo)

2) booting and partitioning software fromother OSS

(E.g., DOS fdisk, OS/2 fdisk)

 

Command (M for help): n

First cylinder (8926-15665, default 8926 ):

Using default value 8926

Last cylinder or + size or + sizem or + sizek (8926-15665, default 15665): + 10g

 

Command (M for help): T

Partition Number (1-6): 6

HEX Code (type L to list codes): 8E

Changed system type of partition 6 to 8E (Linux LVM)

Create logical volume

# Partprobe/dev/SDA

# Pvcreate/DEA/SDA {6, 7}

# Vgcreate vg0/dev/SDA {6, 7}

# Lvcreate-L 10g-N lvmydata vg0

# Lvcreate-L 5G-N lvnfs vg0

Format two partitions

# Mke2fs-J-l mydata/dev/vg0/lvmydata

# Mke2fs-J-l nfs/dev/vg0/lvnfs

Create a mount directory and mount two partitions. Modify/etc/fstab to enable mounting upon startup.

# Mkdir/www/mydata/data-PV

# Mkdir/www/nfs

# Mount/dev/vg0/lvmydata/www/mydata/data/

# Mount/dev/vg0/lvnfs/www/htdocs/

Label = mydata/www/mydata/Data ext3 defaults 0 0

Label = nfs/www/nfs ext3 defaults 0 0

 

4) Enable the NFS service.

# Service Portmap status

Portmap (PID 2177) is running... // It should be running. If not, serviceportmap restart

# Vim/etc/exports

/Www/htdocs 172.16.0.0/16 (RW, async)

# Vim/etc/sysconfig/nfs // modify the NFS service port to prevent it from occupying other service ports

Mountd_port = 10010

Statd_port = 10011

Rquotad_port = 10012

Statd_outgoing_port = 10013

# Service NFS start

# Showmount-A // check to ensure the service is normal. If it cannot be displayed, you may have forgotten to modify/etc/host.

All mount points on nfs.dean.com:

192.168.0.48:/haha

 

5) configure and install the MySQL database

Download the MySQL binary package from the FTP server and decompress it to/usr/local for installation.

# Cd/tmp

# Lftp 192.168.0.254

> Cd pub/sources/new_lamp

> Get mysql-5.5.15-linux2.6-i686.tar.gz

> Bye

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

# Cd/usr/local/

# Ln-SV mysql-5.5.15-linux2.6-i686 MySQL

# Setenforce 0 // disable SELinux to prevent interference

Create mysql users and user groups and modify/www/mydata/data and/usr/local/MySQL File Permissions

# Groupadd-G 3306 MySQL

# Useradd mysql-m-S/sbin/nologin-gmysql-u 3306

# Chown MYSQL: MySQL mysql-R

# Cd MySQL

# Scripts/mysql_install_db -- user = MySQL -- datadir =/www/mydata/Data

# Cp support-files/MySQL. Server/etc/init. d/mysqld

# Chkconfig -- add mysqld

# Chown root: mysql-R.

# Chown MYSQL: MySQL/www/mydata-R

# Cp support-files/my-large.cnf/etc/My. CNF

# Vim/etc/My. CNF

Thread_concurrency = 2

Datadir =/www/mydata/Data

Start the MySQL service and configure the password for the root user.

# Export paht = $ path:/usr/local/MySQL/bin

Source $ path

# Service mysqld start

# MySQL

Mysql> grant all privileges on *. * toroot @ '%. %' identified by 'redhat ';

Mysql> flush privileges;

Mysql> quit

6) Create an Apache user

# Groupadd APACHE-G 48

# Useradd APACHE-m-u 48-G 48-S/bin/bash // note that/bin/bash

 

4. Configure the www1 and www2 servers and install httpd and PHP. The two servers have the same configuration. Take www1 as an example.

1) install httpd, PhP5, and PHP-mysql through yum

Yum install httpd PhP5 PHP-mysql-y

2) mount the NFS Shared File System

Mkdir/WWW

Mount-t nfs 172.16.1.100:/www/htdoc/Web

3) modify the httpd configuration file so that the home page is stored in the/web directory.

Vim/etc/httpd/CONF/httpd. conf

DocumentRoot "/www"

Addtype application/X-httpd-PHP. php

Addtype application/X-httpd-PHP-source. php

Directoryindex index.html. varindex. php

3) Enable the HTTPd service and test whether PHP and MySQL work normally.

Service httpd start

 

5. Install the WordPress webpage

1) decompress the Web package on the NFS server

Unzip wordpress.zip

2) Enter 172.16.1.1 to go to the webpage installation page.

Enter root in mysq database username

Password: RedHat

Database location: 172.16.1.100

Create a Web page management account and password admin Admin

Continue to the next step. installation is complete.

3) Publish the theme Heihei at 172.16.1.1, and then enter 172.16.1.2 in the browser. If the webpage is displayed normally and there is a hihei topic, it indicates that it is successful.

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.