zoukankan      html  css  js  c++  java
  • 第十六周作业

    架构题:前端有一个 LAMP 架构通过 wordpress 来部署,后端构建一个 NFS 服务器实现要求将用户上传的图片保存至后端 NFS 服务器上。

    答:

    环境

    centos8(10.0.0.8):搭建LAMP架构(这里使用yum安装)

    centos7(10.0.0.7):搭建NFS服务器

    搭建LAMP

    • 下载所需程序包
      • 由于centos8默认已经支持fcgi,所以不用对httpd的配置文件做修改
    [root@centos8 ~]#yum install -y httpd php-fpm php-mysqlnd mariadb-server php-json
    
    [root@centos8 ~]#wget https://cn.wp.xz.cn/latest-zh_CN.tar.gz
    • 将wordpress解压并移动到/var/www/html下,并使apache用户对此目录有所需权限
    [root@centos8 ~]#tar xf latest-zh_CN.tar.gz 
    [root@centos8 ~]#mv wordpress/ /var/www/html/
    [root@centos8 ~]#ls /var/www/html/
    wordpress

    [root@centos8 ~]#setfacl -Rm u:apache:rwx /var/www/html/wordpress/
    • php-fpm配置文件
      • 由于当前LAMP都在同一台主机上,php-fpm默认使用socket文件和httpd连接,所以这里也不用做过多修改,只需要将套接字文件的属主和属组修改为apache,并且启用660权限
    [root@centos8 ~]#vim /etc/php-fpm.d/www.conf
    listen = /run/php-fpm/www.sock
    listen.owner = apache
    listen.group = apache
    listen.mode = 0660
    • 创建wordpress所需数据库
    [root@centos8 ~]#mysql -e 'CREATE DATABASE wp;'
    [root@centos8 ~]#mysql -e 'GRANT ALL ON wp.* TO wpuser@"localhost" IDENTIFIED BY "magedu";'
    • 使用浏览器登陆10.0.0.8/wordpress,完成wordpress的安装

     

    部署NFS服务器

    • 安装nfs-utils工具,并配置共享目录为/data/upload
    [root@centos7 ~]#yum install -y nfs-utils
    
    [root@centos7 ~]#systemctl start nfs  #若是centos8上,则启动nfs-server
    
    [root@centos7 ~]#vim /etc/exports
    /data/upload    10.0.0.0/8(rw)

      [root@centos7 ~]#exportfs -r
      [root@centos7 ~]#exportfs -v
      /data/upload 10.0.0.0/8(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash)

    [root@centos7 ~]#mkdir /data/upload
    • 创建apache用户并使其对/data/upload有可创建文件的权限,注意这里apache用户的uid需要和LAMP中apache用户的一样
    [root@centos7 ~]#useradd -u 48 apache
    [root@centos7 ~]#setfacl -m u:apache:rwx /data/upload

     

    在LAMP服务器上挂载NFS共享目录

    • 作为NFS客户端,也需要安装nfs-utils工具
    [root@centos8 ~]#yum install -y nfs-utils
    
    [root@centos8 ~]#showmount -e 10.0.0.7
    Export list for 10.0.0.7:
    /data/upload 10.0.0.0/8
    • 挂载共享目录:wordpress的默认上传目录为 /var/www/html/wordpress/wp-content/uploads/
    [root@centos8 ~]#mount 10.0.0.7:/data/upload /var/www/html/wordpress/wp-content/uploads/
    
    [root@centos8 ~]#df /var/www/html/wordpress/wp-content/uploads/
    Filesystem            1K-blocks  Used Available Use% Mounted on
    10.0.0.7:/data/upload  51474944 53248  48783872   1% /var/www/html/wordpress/wp-content/uploads

    在浏览器中登陆wordpress,并上传文件

     查看NFS服务器是否已经有文件上传

     

  • 相关阅读:
    为什么要用Hibernate框架? 把SessionFactory,Session,Transcational封装成包含crud的工具类并且处理了事务,那不是用不着spring了?
    Weblogic12c安装与配置详解
    淘宝自己的前端框架KISSY(类似jquery)
    ExtJS4中initComponent和constructor的区别
    Servlet的getContextPath(), getServletPath(), getRequestURI(), getRealPath("/")
    Hash Join 一定是选择小表作为驱动表吗
    oracle for loop 简单
    oracle正则表达式
    Android开发--用户定位服务--UserLocation
    android蓝牙开发---与蓝牙模块进行通信
  • 原文地址:https://www.cnblogs.com/jojohyj/p/13759333.html
Copyright © 2011-2022 走看看