Step-by-Step Guide: Deploy WordPress with NFS on CentOS 7
This tutorial walks through configuring an NFS server and client on CentOS 7, installing the LAMP stack, setting up a virtual host, deploying WordPress, configuring the MySQL database, and verifying the site works, providing complete command‑line instructions and code snippets.
Experiment Content
Host IPs: NFS server 192.168.29.120, NFS client 192.168.29.110.
Requirements
NFS server shares /data/web and /data/mysql.
NFS client mounts these directories and deploys WordPress.
Server‑side Configuration
Install
nfs-utils:
<code># yum install nfs-utils</code>Edit
/etc/exportsto share the directories:
<code>/data/web *(rw,no_root_squash)
/data/mysql *(rw,no_root_squash)</code>Create the shared directories:
<code># mkdir -pv /data/web/
# mkdir -pv /data/mysql</code>Start the NFS service:
<code># systemctl start nfs.service</code>Client‑side Configuration
Create the mount point:
<code># mkdir /var/www/html</code>Mount the NFS shares:
<code># mount -t nfs 192.168.29.120:/data/web /var/www/html
# mount -t nfs 192.168.29.120:/data/mysql /var/lib/mysql</code>Install the LAMP stack:
<code># yum install httpd mariadb-server php php-mysql -y</code>Create a virtual host for WordPress:
<code><VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www.mywordpress.com
<Directory "/var/www/html">
AllowOverride None
Require all granted
</Directory>
</VirtualHost></code>Check Apache syntax and start the service:
<code># httpd -t
# systemctl start httpd.service</code>Extract WordPress and copy to the document root:
<code># tar -xf wordpress-4.7.4-zh_CN.tar.gz
# cp -a wordpress /var/www/html/</code>Give write permission to
wp-content:
<code># chmod o+w /var/www/html/wordpress/wp-content/</code>Start MariaDB:
<code># systemctl start mariadb</code>Edit
wp-config.phpwith database credentials (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST).
Create the WordPress database and user, then grant privileges:
<code>CREATE DATABASE wordpress;
CREATE USER 'test1'@'localhost' IDENTIFIED BY '123456';
GRANT ALL ON wordpress.* TO 'test1'@'localhost';</code>Test the site by opening
http://192.168.29.110/wordpress/in a browser.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.