Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nfs learning

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I. Experimental requirements

(1) nfs server Export / data/application/web

(2) nfs client mounts the file system exported by nfs server to / var/www/html

(3) the client (lamp) deploys wordpress and allows it to access it normally; to ensure that articles can be posted normally, upload pictures

(4) client 2 (lamp), mount the file system exported by nfs server to / var/www/html; to verify whether its wordpress can be accessed; to ensure that articles can be sent normally, upload pictures

Second, experimental preparation

Operating system of IP:172.16.28.72,CentOS 7 for server server

IP:172.16.28.70 of client client, pre-deployed lamp service, operating system of CentOS 7

IP:172.16.28.71 of client client2, pre-deployed lamp service, operating system of CentOS 7

III. Operation

1. Nfs server Export / data/application/web

1.1 install nfs-utils and start the service

# yum-y install nfs-utils

# systemctl start nfs.service

# ss-tnl

Verify that port 2049 is started

1.2 create a shared file directory / data/application/web

# mkdir-pv / data/application/web

# vim / etc/exports

/ data/application/web172.16.0.0/16 (rw)

1.4 re-import the file system

# exportfs-ar

2. Nfs client mounts the nfs server exported file system to / var/www/html

2.1 take a look at what shared file systems nfs server has

# showmount-e 172.16.28.72

2.2 Mount the file system to / var/www/html

# mount-t nfs 172.16.28.72:/data/application/web/var/www/html

# mount

Verify successful mount

3. The client (lamp) deploys wordpress and allows it to access it normally; to ensure that articles can be posted properly, upload pictures

The operation failed and there is no permission to create the file. The default rootroot user will be mapped to an nfsnobody anonymous user to access it, so configure permissions on the server side first.

3.1 make sure that you can post articles and upload pictures normally.

To ensure that you can post articles and upload pictures normally, you need to ensure two permissions, one is file sharing permission, and the other is user permission, which needs to be configured on the nfs server side.

Note: the default root user is mapped to nfsnobody anonymous user to access, and the web service is run as user apache (id number 48), so add this UID and GID as well

3.1.1 the following configuration file / etc/exports in the nfs server server

# vim / etc/exports

/ data/application/web 172.16.0.0 Compact 16 (rw,no_root_squash,anonuid=48,anongid=48)

3.1.2 re-import the file system

# exportfs-ar

3.2 in the client, put the wordpress file such as / var/www/html directory

# cp / root/work/wordpress / var/www/html

3.3 provide configuration files for wordpress

# cp wp-config-sample.phpwp-config.php

# vim wp-config.php

/ create users and databases when you start mariadb

/ * * name of WordPress database * /

Define ('DB_NAME','wpdb')

/ * * MySQL database user name * /

Define ('DB_USER','wpuser')

/ * * MySQL database password * /

Define ('DB_PASSWORD','123456')

/ * * MySQL host * /

Define ('DB_HOST','172.16.28.70')

Browser test, found that can not be passed, the user does not have permission

Modify the owner and group of wordpress in the client

# chown-Rapache.apche / var/www/html/wordpress

The browser verifies again.

Publish an article

4 client 2 (lamp), 172.16.28.71 mount the file system exported by nfs server to / var/www/html; to verify whether its wordpress can be accessed; to ensure that articles can be sent normally, upload pictures

4.1 take a look at what shared file systems nfs server has

# showmount-e 172.16.28.72

4.2 Mount the file system to / var/www/html

# mount-t nfs 172.16.28.72:/data/application/web/var/www/html

# mount

Browser verification

But if you log in, it will jump to 172.16.28.70.

Explanation: for this jump, I think wordpress is the user of the mapped apache (id is 48) on the deployment server 172.16.28.72, and the client 172.16.28.71 borrows the status of 172.16.28.70 before logging in, and I verify that when the client 172.16.28.70 unmounts / data/application/web, the client 172.16.28.71 cannot access wordpress

Brief description of deployment LAMP

1. Install httpd and start it

# yum-y install httpd

# systemctl start httpd.service

# ss-tnl verify that port 80 is open

two。 Install mariadb-server and

# yum-y install mariadb-server

# systemctl start mariadb.service

# ss-tnl verify that port 3306 is enabled

Log in to the mysql database and authorize

# mysql-uroot-p

> use mysql

> create database wpdb

> show databases

> grant all on wpdb.* to'wpuser'@'localhost' identified by '123456'

> select user,host,password from user

> flush privileges

> exit

3. Install php

# yum install php php-mysql php-gdphp-mbstring php-xml

# httpd-M | grep php

Verify that the php module is loaded

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report