The scene is introduced

This article describes how to quickly set up a private web disk based on ECS and NAS.

Background knowledge

This scenario involves the following cloud products and services: Cloud Server ECS The Elastic Compute Service (ECS) is an Infrastructure as a Service (IaaS) cloud computing Service provided by AliYun with excellent performance, reliability, and Elastic scalability. Cloud server ECS eliminates the need for you to purchase IT hardware. IT allows you to use the server as easily and efficiently as you use public resources such as water, electricity, and natural gas, realizing the out-of-the-hole and elastic scaling of computing resources. Aliyun ECS continues to provide innovative servers to solve various business needs and help your business development.

File Storage NAS Ali Cloud Network Attached Storage (NAS) is a file Storage service for computing nodes such as Ali Cloud ECS instances, E-HPC, and container services. NAS provides simple, scalable file storage for use with ECS, multiple ECS instances can access the NAS file system simultaneously, and storage capacity automatically grows and shrinks flexibly as you add and remove files, providing a common data source for workloads and applications running on multiple instances or servers.

Experience the scene

The following Ali Cloud Experience Lab page will provide an ECS instance (cloud server) configured with CentOS 7.7 and the created NAS file storage system. Through this tutorial, you can quickly build a personal web disk based on the existing environment. Ali cloud scene resources: developer.aliyun.com/adc/scenari…

Step 1: Install OwnCloud

OwnCloud is an open source cloud storage software, based on PHP self-built web disk. OwnCloud is basically for personal use, there is no user registration, but there is user add, you can add unlimited users, OwnCloud supports multiple platforms (Windows, MAC, Android, IOS, Linux).

1. Run the following command to add a new software source.

The 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 repoCopy the code

2. Run the following command to install owncloud-files.

yum -y install owncloud-files
Copy the code

3. Run the following command to check whether the installation is successful.

ll /var/www/html
Copy the code

Step 2: Install the Apache service

Apache HTTP Server (Apache for short) is the Apache Software Foundation’s open source web Server software that runs on most computer operating systems. Because of its cross-platform and security, it is widely used and is one of the most popular Web server software.

1. Run the following command to install the Apache service.

yum -y install httpd
Copy the code

2. Run the following command to start the Apache service.

systemctl start httpd
Copy the code

3. Open a browser and enter the elastic public IP address of the ECS created on the experience platform. If the following information is displayed, the Apache is successfully installed.

4. Add the OwnCloud configuration: a. Run the following command to open the Apache configuration file.

vim /etc/httpd/conf/httpd.conf
Copy the code

B. Press I to enter the file editing mode, and add the following 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>
Copy the code

C. Press Esc to exit the editing mode, and enter :wq to save and exit the configuration file.

Step 3: Install and configure PHP

As OwnCloud is a cloud storage software developed based on PHP, it requires a PHP operating environment. Please follow the following steps to complete the configuration of OwnCloud working environment.

1. Run 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   
Copy the code

2. Run the following command to install PHP 7.2. 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-mbstringCopy the code

3. Run the following command to check whether PHP is successfully installed.

php -v
Copy the code

4. Configure PHP in the Apache: a. Run the following command to locate the directory of the php.ini file.

find / -name php.ini
Copy the code

B. Run the following command to open the httpd.conf file.

vim /etc/httpd/conf/httpd.conf
Copy the code

C. Press I to enter the file editing mode and add the following content at the end of the file:

PHPIniDir /etc/php.ini
Copy the code

D. Press Esc to exit the editing mode, and enter :wq to save and exit the configuration file. E. Run the following command to restart the Apache service.

systemctl restart httpd
Copy the code

Step 4: Configure OwnCloud

After the above configuration is complete, you can log in to OwnCloud to create your own web disk.

1. Open a browser and enter the ECS elastic IP address/ownCloud, for example, 1.1.1.1/ ownCloud. 2. Create an administrator account and password, and clickStorage & databaseAnd clickThe installation is complete.

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

The successful login page is as follows:

Step 5: Mount the NAS service

After OwnCloud is initialized, you can mount the NAS storage package to your web disk server.

1. Click in the resource column on the left of the experience platformOne-click copy of the login URL, and then paste the copied URL in the browser.

2. Enter the subuser name and password provided by the experience platform to log in to aliyun Console. In the product list, search for NAS, and click File Storage NAS.

3. SelectThe file system>File System List, then click the file system ID to go to the file system details page.

4. SelectMount the use, and clickAdd mount pointsSelect a private network and click OK.

5. On the CLI, run the following command to install the NFS client.

yum install nfs-utils
Copy the code

6. On the console, clickMount the file system to the ECSView mounting commands.

7. On the mount file system to ECS page that is displayed, copy the mount command.

A. Click the mount command copy button. C. running.

8. Paste copy good mount command to the notepad, and then the command last/MNT for: / var/WWW/HTML/owncloud/data / < owncloud login name >. Such as:

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
Copy the code

9. On the CLI, run the mount command of the previous step.

10. Run the following command to check whether the mounting is successful.

df -h | grep aliyun
Copy the code

Note: After the NAS is successfully mounted, the default directories and files in the OwnCloud web disk cannot be read or written. Create a directory on the web disk and upload it.