第10章 搭建网盘服务

10.1 配置本地仓库

首先我们需要在 /etc/yum.repos.d 目录下新建一个仓库文件,如:yum.repo。

 [root@localhost yum.repos.d]# vim yum.repo
 ​
 # 添加如下内容
 [baseos]
 name=baseos
 baseurl=/mnt/BaseOS
 gpgcheck=0
 [appstream]
 name=appstream
 baseurl=/mnt/AppStream
 gpgcheck=0

然后我们把光盘挂载到 /mnt 目录下

 # 挂载
 [root@localhost yum.repos.d]# mount /dev/sr0 /mnt
 mount: /mnt: WARNING: source write-protected, mounted read-only.
 ​
 # 查看
 [root@localhost yum.repos.d]# ls /mnt
 AppStream  EFI   extra_files.json  images    media.repo               RPM-GPG-KEY-redhat-release
 BaseOS     EULA  GPL               isolinux  RPM-GPG-KEY-redhat-beta

10.2 安装对应的软件

10.2.1 安装php运行环境

 [root@localhost yum.repos.d]# dnf install -y php*
 ​
 ​

10.2.2 安装httpd服务

 [root@localhost yum.repos.d]# dnf install -y httpd
 ​
 ​

10.2.3 安装mariadb数据库

 [root@localhost yum.repos.d]# dnf install -y mariadb mariadb-server
 ​
 ......
 Installed:
   mariadb-3:10.5.16-2.el9_0.x86_64                              mariadb-backup-3:10.5.16-2.el9_0.x86_64   
   mariadb-common-3:10.5.16-2.el9_0.x86_64                       mariadb-errmsg-3:10.5.16-2.el9_0.x86_64
   mariadb-gssapi-server-3:10.5.16-2.el9_0.x86_64                mariadb-server-3:10.5.16-2.el9_0.x86_64
   mariadb-server-utils-3:10.5.16-2.el9_0.x86_64                 mysql-selinux-1.0.5-1.el9_0.noarch
   perl-DBD-MariaDB-1.21-16.el9_0.x86_64                         perl-DBI-1.643-9.el9.x86_64
   perl-Math-BigInt-1:1.9998.18-460.el9.noarch                   perl-Math-Complex-1.59-480.el9.noarch
   perl-Sys-Hostname-1.23-480.el9.x86_64
 ​
 Complete!
 ​

10.3 启动服务

10.3.1 启动httpd

 [root@localhost yum.repos.d]# systemctl start httpd
 [root@localhost yum.repos.d]# netstat -lntup | grep httpd
 tcp6       0      0 :::80                   :::*                    LISTEN      39790/httpd

启动后,我们还是不能访问 httpd 服务,我们需要把这个服务加入到防火墙中,或者把防火墙关闭。

 # 将 http 服务添加到防火墙中
 [root@localhost yum.repos.d]# firewall-cmd --permanent --add-service=http
 success
 # 将 80 端口添加到防火墙中
 [root@localhost yum.repos.d]# firewall-cmd --permanent --add-port=80/tcp
 success
 # 重新加载防火墙
 [root@localhost yum.repos.d]# firewall-cmd --reload
 success
 # 关闭selinux
 [root@localhost yum.repos.d]# setenforce 0
 ​
 ​
 # 或者执行如下的命令来关闭防火墙
 [root@localhost yum.repos.d]# systemctl stop firewalld

完成上面的操作后,我们就可以在浏览器中看到页面了。

10.3.2 启动mariadb

 [root@localhost yum.repos.d]# systemctl start mariadb.service 
 [root@localhost yum.repos.d]# 
 ​

10.4 配置数据库

首先执行如下的命令来进入到数据库中:

[root@localhost yum.repos.d]# mysql -uroot -p
Enter password: 			# 在此处直接回车即可
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

然后创建一个数据库,名称我们取名为 luntan

# 查看目前的所有数据库信息
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.000 sec)

# 创建luntan数据库
MariaDB [(none)]> create database luntan;
Query OK, 1 row affected (0.000 sec)

# 再次查看确认
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| luntan             |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.000 sec)

接下来我们修改数据库的 root 用户的密码:

MariaDB [(none)]> alter user 'root'@'localhost' identified by 'redhat123';
Query OK, 0 rows affected (0.001 sec)

-- alter user 'root'@'localhost' identified by 'redhat123'; 格式说明:
-- alter 表示要修改,可能是表,可能是数据库
-- user 表示user表
-- 'root'@'localhost'  表示 root 用户在 localhost 域下的的操作
-- identified by 这个后面要跟上密码
-- 'redhat123'  表示新的密码,注意:密码的值是不带引号的

执行完上面的修改密码语句后,我们执行 exit 命令来退出数据库,然后重新通过用户名和密码来登录数据库

[root@localhost yum.repos.d]# mysql -uroot -predhat123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

要选择数据库:

# 选择数据库
MariaDB [(none)]> use luntan;
Database changed

# 查看数据库下所有表信息
MariaDB [luntan]> show tables;
Empty set (0.000 sec)

10.5 传源码并解压

我们将 Discuz_X3.5_SC_UTF8_20230520.zip 文件上传到 /var/www/html 目录下

[root@localhost html]# ll
total 11500
-rw-r--r--. 1 root root 11775903 Feb 23 16:02 Discuz_X3.5_SC_UTF8_20230520.zip

然后执行如下的命令来解压这个文件

[root@localhost html]# unzip Discuz_X3.5_SC_UTF8_20230520.zip

解压完成后,查看解压的目录:

[root@localhost html]# ll
total 11624
-rw-r--r--.  1 root root 11775903 Feb 23 16:02 Discuz_X3.5_SC_UTF8_20230520.zip
-rw-r--r--.  1 root root     8181 May 20  2023 LICENSE
-rw-r--r--.  1 root root    33294 Dec 21  2022 qqqun.png
drwxr-xr-x.  2 root root      124 May 20  2023 readme
-rw-r--r--.  1 root root    70226 Mar 16  2023 readme.html
drwxr-xr-x. 12 root root     4096 May 20  2023 upload
-rw-r--r--.  1 root root      140 Feb 12  2023 utility.html

接下来我们进入到 upload 目录中:

[root@localhost html]# cd upload/
[root@localhost upload]# ll
total 72
-rw-r--r--.  1 root root 2869 May 20  2023 admin.php
drwxr-xr-x. 10 root root  149 May 20  2023 api
-rw-r--r--.  1 root root  727 May 20  2023 api.php
drwxr-xr-x.  2 root root   23 May 20  2023 archiver
drwxr-xr-x.  2 root root   90 May 20  2023 config
-rw-r--r--.  1 root root 1040 May 20  2023 connect.php
-rw-r--r--.  1 root root  106 May 20  2023 crossdomain.xml
drwxr-xr-x. 12 root root  178 May 20  2023 data
-rw-r--r--.  1 root root 5558 May 20  2023 favicon.ico
-rw-r--r--.  1 root root 2357 May 20  2023 forum.php
-rw-r--r--.  1 root root  906 May 20  2023 group.php
-rw-r--r--.  1 root root 1325 May 20  2023 home.php
-rw-r--r--.  1 root root 6912 May 20  2023 index.php
drwxr-xr-x.  5 root root   64 May 20  2023 install
-rw-r--r--.  1 root root  998 May 20  2023 member.php
-rw-r--r--.  1 root root 2410 May 20  2023 misc.php
-rw-r--r--.  1 root root 1790 May 20  2023 plugin.php
-rw-r--r--.  1 root root 1086 May 20  2023 portal.php
-rw-r--r--.  1 root root  639 May 20  2023 robots.txt
-rw-r--r--.  1 root root 1755 May 20  2023 search.php
drwxr-xr-x. 10 root root  168 May 20  2023 source
drwxr-xr-x.  7 root root   86 May 20  2023 static
drwxr-xr-x.  3 root root   38 May 20  2023 template
drwxr-xr-x.  8 root root  146 May 20  2023 uc_client
drwxr-xr-x. 13 root root 4096 May 20  2023 uc_server

10.6 页面初始化

我们打开浏览器,在地址栏中输入 http://192.168.72.128/upload

由于 upload 目录目前是不可写状态,我们要执行如下的命令来修改它的权限:

[root@localhost upload]# chmod -R 777 data/ uc_client/ uc_server/ config/

执行完后再刷新页面,就不会再有警告信息了,我们点击下一步来一步一步的根据提示信息操作即可。

相关推荐

  1. 10 服务

    2024-02-23 18:24:02       42 阅读
  2. 华纳云:服务器需要哪些技术支持?

    2024-02-23 18:24:02       51 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-23 18:24:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-23 18:24:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-02-23 18:24:02       87 阅读
  4. Python语言-面向对象

    2024-02-23 18:24:02       96 阅读

热门阅读

  1. Linux第64步_编译移植好的虚拟机文件

    2024-02-23 18:24:02       40 阅读
  2. npm install报错,解决记录

    2024-02-23 18:24:02       53 阅读
  3. vue+electron 修改默认安装目录

    2024-02-23 18:24:02       48 阅读
  4. 听课笔记03

    2024-02-23 18:24:02       49 阅读
  5. k8s中基于alpine的pod无法解析域名问题

    2024-02-23 18:24:02       52 阅读
  6. Visual Studio Code 实用快捷键

    2024-02-23 18:24:02       52 阅读
  7. 抖店注册个体还是个人?哪个比较适合新手?

    2024-02-23 18:24:02       44 阅读
  8. IP 电话

    IP 电话

    2024-02-23 18:24:02      47 阅读
  9. 【PTA|编程题|期末复习|part 1】结构体(注释详细)

    2024-02-23 18:24:02       52 阅读
  10. commander插件

    2024-02-23 18:24:02       49 阅读