NextCloud private network disk deployment
1. Introduction to NextCloud
-
About NextCloud
NextCloud is an open source private cloud disk storage project, which can quickly build its own network disk platform. It can also be used by your own team. In addition to the network disk, it also provides various plug-in extension functions. The upload and download speed depends on the bandwidth of your server. It's too high to know where it is
-
About environment
The server is required to provide LNMP or LAMP environment. For the installation method, NextCloud can be simply understood as a website written by others. We just need to put it on the server.
-
About offline Downloads
Basically, network disks have the function of offline download. The offline download of NextCloud uses Aria2.
2. NextCloud deployment configuration
2.1 LAMP construction
This place can be built manually or by using some one click scripts or panels. You can better understand the whole process through manual setup. Therefore, the following processes are all built manually.
- First, configure the source (centos7 according to the system configuration) and install the wget download tool
[root@Cloud ~]# mount /dev/sr0 /mnt [root@Cloud ~]# mv /etc/yum.repos.d/* /tmp/ [root@Cloud ~]# vi /etc/yum.repos.d/local.repo [local] name=centos baseurl=file:///mnt gpgcheck=0 enabled=1 [root@Cloud ~]# yum clean all && yum install -y wget The output is omitted. So we can use wget Find resources on the network. Then install it zip This installation nextcloud You need it when you [root@Cloud ~]#yum install -y zip unzip
Apache installation configuration
- Install apache using yum or up2date
[root@Cloud ~]# yum install -y httpd Omit partial output [root@Cloud ~]# systemctl start httpd && systemctl enable httpd open apache Service and startup Then we can verify [root@Cloud ~]# ss -tnl | grep 80 LISTEN 0 128 :::80 :::* Remember to turn off the firewall [root@Cloud ~]# systemctl stop firewalld [root@Cloud ~]# systemctl disable firewalld SELinux Turn it off (you can also configure the security context, but it's too troublesome. Just turn it off to see the effect. You can change it later) [root@Cloud ~]# setenforce 0 [root@Cloud ~]# vi /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled #Set this to disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are pro tected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
After that, there should be A default test page accessed through your own ip address. We won't show the L and A in the LAMP so far, and we will finish it.
Mariadb installation configuration
- Install Mariadb using yum or up2date
[root@Cloud ~]#yum install mariadb mariadb-server mariadb-devel -y Omit partial output Set auto start and start service [root@Cloud ~]# systemctl start mariadb && systemctl enable mariadb Check it out [root@Cloud ~]# ss -tnl | grep 3306 LISTEN 0 50 *:3306 *:* After that, I will annotate every step of initializing the database. [root@Cloud ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): #Press enter here because the initial database does not have a password OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y #Here I ask you whether you want to set a root password. Remember this password for later use New password: #Enter new password Re-enter new password: #Repeat input Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y #Do you want to remove anonymous users? It is recommended to select y to remove ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] n #Do you want to disable root remote login? I don't prohibit it here ... skipping. By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y #Do you want to delete the database for testing. This library is useless. Just delete it - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y #Do you want to refresh the authorization table. Here y is refreshed because the password has been changed ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! eject Thanks for using MariaDB Then we can use it [root@Cloud ~]# mysql -uroot -p password just set #-Pthe following is your password. Do not enter the Chinese "password just set" before the database operation.
MariaDB [(none)]> show databases; #First, let's see what's in the database +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.00 sec) #Create a database called nextcloud_ The DB default character set uses utf8. If you don't take this, it may be garbled. The default character set of mysql is latin1 Chinese is not supported MariaDB [(none)]> create database nextcloud_db default charset=utf8; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | nextcloud_db | | performance_schema | +--------------------+ #Take another look at the database and find multiple nextclouds_ db #Give root all permissions to use this database. The password is: 123456 MariaDB [(none)]> grant all privileges on nextcloud_db.* to root@'%' identified by '123456'; MariaDB [(none)]> flush privileges; #Brush the authorization
This completes the construction of the database. Finally, php is left, and our environment is set up
PHP installation configuration
nextcloud setup requires php7.2 or above. However, if the local version of yum is too low, it does not meet the requirements of building. So this place needs to use the network source. Or you can choose to use the source installation, but it is not necessary. Here, you can directly find a fedora source to install PHP 7.2
- Add a source first
[root@Cloud ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm #Omit partial output [root@Cloud ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm #Omit partial output
- Next, install php7.2
[root@Cloud ~]# yum install -y php72w php72w-devel php72w-pear php72w-pecl php72w-gd php72w-opcache php72w-cli php72w-pdo php72w-process php72w-pecl-apcu php72w-mcrypt php72w-mysql php72w-fpm php72w-pecl-redis php72w-common php72w-xml php72w-mbstring php72w-pecl-igbinary php72w-intl php72w-pecl-imagick #Omit partial output Change it after installation apache Configuration file for [root@Cloud ~]# vi /etc/httpd/conf/httpd.conf #Omit partial output AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php #Add this line [root@Cloud html]# chown -R apache.apache /var/www/html #Give the permissions of this default directory to apache #Write a php test page and restart the httpd service [root@Cloud ~]# vi /var/www/html/test.php <?php phpinfo(); ?> [root@Cloud html]# systemctl restart httpd
2.2 nextcloud installation
Download nextcloud from the official website.
[root@Cloud html]# wget https://download.nextcloud.com/server/releases/nextcloud-18.0.0.zip #Omit partial output Then use unzip decompression [root@Cloud html]# unzip nextcloud-18.0.0.zip #Omit partial output Then move the entire folder to/var/www/html in [root@Cloud html]# mv nextcloud /var/www/html Write a/var/www/html/nextcloud/config/config.php File, modify the corresponding database options [root@Cloud nextcloud]#vi /var/www/html/nextcloud/config/config.php <?php $CONFIG = array ( 'instanceid' => 'oc0tplp89d0x', 'passwordsalt' => 'totCDGnfkMaK2up5DRbu2fXLdS7tsU', 'secret' => 'QcZ6cI370VrscFPg/WJiWzjxFivtltGCOdhuprNu2y9fKh7a', 'trusted_domains' => array ( 0 => '192.168.2.9', #Here is your IP address ), 'datadirectory' => '/var/www/html/nextcloud/data', 'dbtype' => 'mysql', 'version' => '18.0.0.10', 'overwrite.cli.url' => 'http://192.168.2.9/nextcloud', \here is your own IP address 'dbname' => 'nextcloud_db', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'dbuser' => 'root', 'dbpassword' => '123456', ); Finally, give me permission [root@Cloud html]# chown -R apache.apache /var/www/html/nextcloud
Then you can go through http:// server ip/nextcloud/index php Finally, the service can be mapped out through port mapping. This basic installation is over
Of course, if it is mapped out and accessed from the Internet, the untrusted domain name access may pop up. You need to change the configuration file at this time
[root@Cloud nextcloud]#vi /var/www/html/nextcloud/config/config.php array ( 0 => '192.168.2.9', 1 => 'Your public network ip'