LNMP项目实战:
L:Linux(centos 7.6) http://mirrors.cqu.edu.cn/CentOS/7.6.1810/isos/x86_64/
N:Nginx(1.12.2) https://nginx.org/en/download.html
M:MySQL(5.6.43) https://dev.mysql.com/downloads/mysql/5.6.html#downloads
P:PHP(7.2.15) http://php.net/downloads.php
Worldpress(5.0.3):https://cn.wordpress.org/download/
部署规划:
192.168.39.7:Nginx php-fpm 运行web服务
192.168.39.10:NFS存储服务器,存储上传的图片
192.168.39.101:运行MySQL数据库
[root@Centos7 wordpress]#pwd
/data/nginx/wordpress/wordpress
[root@Centos7 wordpress]#tar -xvf wordpress-5.3-zh_CN.tar.gz
[root@Centos7 wordpress]#mv wordpress/* .
[root@Centos7 wordpress]#ll
total 12348
-rw-r--r-- 1 wang apache 420 Dec 1 2017 index.php
-rw-r--r-- 1 wang apache 19935 Jan 2 2019 license.txt
-rw-r--r-- 1 wang apache 7005 Nov 14 09:00 readme.html
drwxr-xr-x 2 wang apache 4096 Apr 11 16:04 wordpress
-rw-r--r-- 1 root root 12423575 Dec 12 14:18 wordpress-5.3-zh_CN.tar.gz
-rw-r--r-- 1 wang apache 6939 Sep 3 2019 wp-activate.php
drwxr-xr-x 9 wang apache 4096 Nov 14 09:00 wp-admin
-rw-r--r-- 1 wang apache 369 Dec 1 2017 wp-blog-header.php
-rw-r--r-- 1 wang apache 2283 Jan 21 2019 wp-comments-post.php
-rw-r--r-- 1 wang apache 2776 Nov 14 09:00 wp-config-sample.php
drwxr-xr-x 5 wang apache 4096 Nov 14 09:00 wp-content
-rw-r--r-- 1 wang apache 3955 Oct 11 2019 wp-cron.php
drwxr-xr-x 20 wang apache 12288 Nov 14 09:00 wp-includes
-rw-r--r-- 1 wang apache 2504 Sep 3 2019 wp-links-opml.php
-rw-r--r-- 1 wang apache 3326 Sep 3 2019 wp-load.php
-rw-r--r-- 1 wang apache 47007 Oct 1 2019 wp-login.php
-rw-r--r-- 1 wang apache 8483 Sep 3 2019 wp-mail.php
-rw-r--r-- 1 wang apache 19120 Oct 15 23:37 wp-settings.php
-rw-r--r-- 1 wang apache 31112 Sep 3 2019 wp-signup.php
-rw-r--r-- 1 wang apache 4764 Dec 1 2017 wp-trackback.php
-rw-r--r-- 1 wang apache 3150 Jul 1 2019 xmlrpc.php
二、准备配置文件和配置数据库
[root@Centos7 wordpress]#mv wordpress wordpress-5.3-zh_CN.tar.gz /opt
[root@Centos7 wordpress]#cp wp-config-sample.php wp-config.php
[root@Centos7 wordpress]#pwd
/data/nginx/wordpress
[root@Centos7 wordpress]#vim wp-config.php
23 define( 'DB_NAME', 'wordpress' );
24
25 /** MySQL数据库用户名 */
26 define( 'DB_USER', 'wordpress' );
27
28 /** MySQL数据库密码 */
29 define( 'DB_PASSWORD', '123456' );
30
31 /** MySQL主机 */
32 define( 'DB_HOST', '192.168.39.101' );
33
34 /** 创建数据表时默认的文字编码 */
35 define( 'DB_CHARSET', 'utf8' );
36
37 /** 数据库整理类型。如不确定请勿更改 */
38 define( 'DB_COLLATE', '' );
[root@Centos7 wordpress]#chown nginx.nginx -R /data/nginx/
[root@centos7 ~]#yum install nfs-utils
[root@centos7 ~]#vim /etc/exports
/data/nfs1 *(rw)
[root@centos7 ~]#
[root@centos7 ~]#
[root@centos7 ~]#mkdir /data/nfs1
[root@centos7 ~]#systemctl start nfs
[root@centos7 ~]#exportfs -v
/data/nfs1 (sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)
客户端查看:
[root@Centos7 nginx]#showmount -e 192.168.39.10
Export list for 192.168.39.10:
/data/nfs1 *
4、挂载磁盘: /nfs文件夹必须存在
mount 192.168.39.10:/data/nfs1 /data/nginx/wordpress/wp-content/uploads
5、查看挂载后结果
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 730M 0 730M 0% /dev
tmpfs 746M 0 746M 0% /dev/shm
tmpfs 746M 19M 727M 3% /run
tmpfs 746M 0 746M 0% /sys/fs/cgroup
/dev/sda2 80G 11G 69G 14% /
/dev/sda6 30G 94M 28G 1% /data
/dev/sda1 1014M 168M 847M 17% /boot
tmpfs 150M 12K 150M 1% /run/user/42
tmpfs 150M 0 150M 0% /run/user/0
192.168.39.10:/data/nfs1 47M 41M 6.5M 87% /data/nginx/wordpress/wp-content/uploads
使用 mount 和umount 命令进行挂载和取消挂载,
注意以上只是临时挂载,如果要开机自动挂载需要修改, vim /etc/fstb文件,另外_netdev,没有网络时,就不挂载,避免开启启动不起来,最好加上。
测试访问:
在nfs服务器上查看存放的位置:
[root@centos7 04]#pwd
/data/nfs1/2020/04
[root@centos7 04]#ls
timg.jpg