Build a personal network disk based on ECS and NAS! Create your own private space!

Build a personal network disk based on ECS and NAS

Experience address: https://developer.aliyun.com/adc/scenario/bd0643a87c3e4cde8b488a56850df181

Scene experience goal

This scenario will provide an ECS instance (cloud server) configured with CentOS 7.7 and a created NAS file storage system. Through the operation of this tutorial, you can quickly build a personal network disk based on the existing environment.

After experiencing this scene, the knowledge you can master is:

  1. Basic knowledge of NAS file storage system

  2. Installation and deployment of Apache + PHP language environment

  3. Mount NAS file storage system

  4. Basic Linux system commands

background knowledge

This scenario mainly involves the following cloud products and services:

Cloud server ECS

Elastic Compute Service (ECS for short) is an IaaS (Infrastructure as a Service)-level cloud computing service provided by Alibaba Cloud with excellent performance, stability, reliability, and elastic expansion. The cloud server ECS eliminates the pre-preparation for purchasing IT hardware, allowing you to use the server as convenient and efficient as using public resources such as water, electricity, and natural gas, realizing out-of-the-box and elastic scaling of computing resources. Alibaba Cloud ECS continues to provide innovative servers to solve a variety of business needs and help your business development.

File storage NAS

Alibaba Cloud File Storage (Network Attached Storage, NAS for short) is a file storage service for computing nodes such as Alibaba Cloud ECS instances, E-HPC, and container services. NAS provides simple and expandable file storage for use with ECS. Multiple ECS instances can access the NAS file system at the same time, and the storage capacity will automatically grow and shrink as you add and delete files. Workloads and applications running on the server provide common data sources.

    1. Create resources
    1. Connect to ECS server
    1. Install OwnCloud
    1. Install Apache service
    1. Install and configure PHP
    1. Configure OwnCloud
    1. Mount NAS service

Create resources

  1. Click on the left side of the page Cloud product resources , in the drop-down box to view this experiment resource information;

  2. Click on the drop-down bar in the resource free open button to start creating resources.

Note: The resource creation process takes 1-3 minutes. After completing the creation of the experiment resource, the user can view the resource information required in the experiment through the cloud product resource, such as: IP address, user name, password, etc.

Connect to ECS server

  1. Open the terminal tool.
  • Windows: Open a command window.
  • MAC: Open the command line terminal Terminal.
  1. Enter the connection command in the terminal ssh [username]@[ipaddress]. You need to replace the username and ipaddress with the username and elastic IP of the ECS server created in Section 1. E.g:
ssh [email protected]

img

The command display results are as follows:

img

  1. Enter yes.

  2. After agreeing to continue, you will be prompted to enter the login password. The password is the login password of the ECS of the created cloud service.

img

After successful login, the following information will be displayed.

img

Install OwnCloud

OwnCloud is an open source cloud storage software, a self-built network disk based on PHP. Basically for private use, there is no user registration function, but there is a user addition function, you can add users without restrictions, OwnCloud supports multiple platforms (windows, MAC, Android, IOS, Linux).

  1. Execute the following command to add a new software source.
rpm --import https://download.owncloud.org/download/repositories/10.0/CentOS_7/repodata/repomd.xml.key

wget http://download.owncloud.org/download/repositories/10.0/CentOS_7/ce:10.0.repo -O /etc/yum.repos.d/ce:10.0.repo
  1. Execute the following command to install OwnCloud-files.
yum install owncloud-files
  1. Execute the following command to check whether the installation is successful.
ll /var/www/html

img

Install Apache service

  1. Execute the following command to install the Apache service.
yum install httpd –y
  1. Execute the following command to start the Apache service.
systemctl start httpd.service
  1. Open the browser and enter the ECS elastic public network IP created by the experience platform. If the following figure appears, the Apache installation is successful.

img

  1. Add OwnCloud configuration:

1) Execute the following command to open the Apache configuration file.

vim /etc/httpd/conf/httpd.conf

2) Press the ibutton to enter the edit mode, and then add the following at the content.

# owncloud config
Alias /owncloud "/var/www/html/owncloud/"
<Directory /var/www/html/owncloud/>
    Options +FollowSymlinks
    AllowOverride All
    <IfModule mod_dav.c>
        Dav off
    </IfModule>
    SetEnv HOME /var/www/html/owncloud
    SetEnv HTTP_HOME /var/www/html/owncloud
</Directory>

img

3) Press the esckey to exit edit mode, and then enter the :wqsave and exit the configuration file.

Install and configure PHP

Since OwnCloud is a cloud storage software developed based on PHP and requires a PHP operating environment, please follow the steps below to complete the configuration of the OwnCloud working environment.

  1. Execute the following command to manually update the rpm source.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm   
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm   
  1. Execute the following command to install PHP 7.2 version.

Note: OwnCloud only supports PHP 5.6+.

yum -y install php72w
yum -y install php72w-cli php72w-common php72w-devel php72w-mysql php72w-xml php72w-odbc php72w-gd php72w-intl php72w-mbstring
  1. Execute the following command to check whether PHP is installed successfully.
php -v
  1. Configure PHP into Apache:

1) Execute the following command to find the php.ini file directory.

find / -name php.ini

2) Execute the following command to open the httpd.conf file.

vi /etc/httpd/conf/httpd.conf

3) Press the ibutton to enter the edit mode, and then finally add the following to the file.

PHPIniDir /etc/php.ini

4) Press the esckey to exit edit mode, and then enter the :wqsave and exit the configuration file.

5) Execute the following command to restart the Apache service.

systemctl restart httpd.service

Configure OwnCloud

After completing the above configuration, you can log in to OwnCloud to create a personal network disk.

  1. Open the browser and enter ECS弹性IP/owncloud, for example 1.1.1.1/owncloud.

  2. Create an administrator account and password, then click [Storage & Database], configure the database, and finally click [Installation Complete].

img

  1. Enter the created user name and password to log in to Owncloud.

img

The successful login interface is as follows:

img

Mount NAS service

After completing OwnCloud initialization, you can mount the NAS storage package to your network disk server.

  1. First, in the left column, click the resource cloud offerings a key to copy the url , url and paste the copied browser incognito window (incognito mode) in.

img

  1. Enter the user name and password provided by the cloud product resource to log in to the Alibaba Cloud console. On the product list page, search for NAS, and then click [File Storage NAS].

img

  1. Click [File System List] on the left, select the region provided by the resource, you can see the file system that has been created, and then click [File System ID] to enter the file system details page.

img

  1. Select [Mount to use], then click [Add Mount Point] to select VPC, and finally click [OK].

img

  1. In the command line terminal, execute the following command to install the NFS client.
yum install nfs-utils
  1. In the console, click [Mount File System to ECS] to view the mount command.

img

  1. Copy the mount command on the opened mount file system to ECS page.

img

  1. The copied into Notepad mount command, and then the last command /mntis replaced with: /var/www/html/owncloud/data/<OwnCloud登录名>.

E.g:

sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 3ad894afd4-uon67.cn-shanghai.nas.aliyuncs.com:/ /var/www/html/owncloud/data/admin
  1. Execute the mount command of the previous step in the command window.

img

  1. Execute the following command to check whether the mount is successful.
df -h | grep aliyun

img

,hard,timeo=600,retrans=2,noresvport 3ad894afd4-uon67.cn-shanghai.nas.aliyuncs.com:/ /var/www/html/owncloud/data/admin


9. 在命令窗口执行上一步骤的挂载命令。

[外链图片转存中...(img-66WqM7DJ-1612525064675)]



10. 执行以下命令查看挂载是否成功。

df -h | grep aliyun




[外链图片转存中...(img-3WVY2Dxj-1612525064676)]

注意:NAS挂载成功后,OwnCloud网盘中的默认目录和文件不可读写,请在网盘中新建目录上传。

Guess you like

Origin blog.csdn.net/weixin_43314519/article/details/113702830