centos7.6部署harbor2.1.1

在这里插入图片描述
1.安装docker
2.安装docker-compose
3. 安装Harbor

一、新装centos7.6操作系统
操作日志

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# sed -i 's/^SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/

二、使用yum安装docker-ce

操作日志

[root@localhost ~]# sudo yum install -y yum-utils
[root@localhost ~]# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost ~]# sudo yum install -y docker-ce

启动docker

[root@localhost ~]# sudo systemctl start docker
[root@localhost ~]# sudo systemctl status docker

三、安装 Docker-Compose

  1. 使用pip安装 Docker-Compose
yum install epel-release wget -y
pip install --upgrade pip
sudo yum install -y python-pip
pip install docker-compose
  1. 使用二进制包安装Docker-Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose## Giving permissions
sudo chmod +x /usr/local/bin/docker-compose## Test installation
docker-compose --version

四、安装harbor
离线安装

#下载harbor在线安装包
wget https://github.com/goharbor/harbor/releases/download/v2.1.1/harbor-offline-installer-v2.1.1.tgz
tar xvf harbor-online-installer-v2.1.1.tgz -C /opt

创建加密文件

mkdir cert && cd cert
openssl req -sha256 -x509 -days 365 -nodes -newkey rsa:4096 -keyout  harbor.example.com.key -out harbor.example.com.crt

编辑配置harbor

vim harbor.yml

Change hostname to your host's FQDN and enable https.
hostname = harbor.example.com
https:
  # https port for harbor, default is 443
  port: 443
  # The path of cert and key files for nginx
  certificate: /root/cert/harbor.example.com.crt
  private_key: /root/cert/harbor.example.com.key

运行 install.sh 完成安装

./install.sh

浏览器访问

http://harobr.example.com 
admin
Harbor12345

操作日志

#linux下生成https的crt和key证书
[root@localhost ~]# mkdir cert && cd cert
[root@localhost cert]# ll
total 0
[root@localhost cert]# openssl req -sha256 -x509 -days 365 -nodes -newkey rsa:4096 -keyout  192.168.200.132.key -out 192.168.200.132.crt
Generating a 4096 bit RSA private key
...................................................................................................................++
.....................................................................................................................................................++
writing new private key to '192.168.200.132.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:test
Organizational Unit Name (eg, section) []:Ops
Common Name (eg, your name or your server's hostname) []:gongshuaili
Email Address []:13526464656@163.com
#生成的证书
[root@localhost cert]# ll
total 8
-rw-r--r-- 1 root root 2057 Nov 17 10:39 192.168.200.132.crt
-rw-r--r-- 1 root root 3272 Nov 17 10:39 192.168.200.132.key
[root@localhost cert]# 
#配置harbor仓库的配置文件
[root@localhost ~]# cd /opt/harbor/
[root@localhost harbor]# mv harbor.yml.tmpl harbor.yml
[root@localhost harbor]# cat harbor.yml 
# Configuration file of Harbor

# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: 192.168.200.132

# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80

# https related config
https:
  # https port for harbor, default is 443
  port: 443
  # The path of cert and key files for nginx
  certificate: /root/cert/192.168.200.132.crt
  private_key: /root/cert/192.168.200.132.key
# # Uncomment following will enable tls communication between all harbor components
# internal_tls:
#   # set enabled to true means internal tls is enabled
#   enabled: true
#   # put your cert and key files on dir
#   dir: /etc/harbor/tls/internal

# Uncomment external_url if you want to enable external proxy
# And when it enabled the hostname will no longer used
# external_url: https://reg.mydomain.com:8433

# The initial password of Harbor admin
# It only works in first time to install harbor
# Remember Change the admin password from UI after launching Harbor.
harbor_admin_password: Harbor12345

# Harbor DB configuration
database:
  # The password for the root user of Harbor DB. Change this before any production use
  password: root123
  # The maximum number of connections in the idle connection pool. If it <=0, no idle 
  max_idle_conns: 50
  # The maximum number of open connections to the database. If it <= 0, then there is 
  # Note: the default number of connections is 1024 for postgres of harbor.
  max_open_conns: 1000

# The default data volume
data_volume: /data

# Harbor Storage settings by default is using /data dir on local filesystem
# Uncomment storage_service setting If you want to using external storage
# storage_service:
#   # ca_bundle is the path to the custom root ca certificate, which will be injected 
#   # of registry's and chart repository's containers.  This is usually needed when th
#   ca_bundle:

#   # storage backend, default is filesystem, options include filesystem, azure, gcs, 
#   # for more info about this configuration please refer https://docs.docker.com/regi
#   filesystem:
#     maxthreads: 100
#   # set disable to true when you want to disable registry redirect
#   redirect:
#     disabled: false

# Clair configuration
clair:
  # The interval of clair updaters, the unit is hour, set to 0 to disable the updaters
  updaters_interval: 12

# Trivy configuration
#
# Trivy DB contains vulnerability information from NVD, Red Hat, and many other upstre
# It is downloaded by Trivy from the GitHub release page https://github.com/aquasecuri
# in the local file system. In addition, the database contains the update timestamp so
# should download a newer version from the Internet or use the cached one. Currently, 
# 12 hours and published as a new release to GitHub.
trivy:
  # ignoreUnfixed The flag to display only fixed vulnerabilities
  ignore_unfixed: false
  # skipUpdate The flag to enable or disable Trivy DB downloads from GitHub
  #
  # You might want to enable this flag in test or CI/CD environments to avoid GitHub r
  # If the flag is enabled you have to download the `trivy-offline.tar.gz` archive man
  # `metadata.json` files and mount them in the `/home/scanner/.cache/trivy/db` path.
  skip_update: false
  #
  # insecure The flag to skip verifying registry certificate
  insecure: false
  # github_token The GitHub access token to download Trivy DB
  #
  # Anonymous downloads from GitHub are subject to the limit of 60 requests per hour. 
  # for production operations. If, for any reason, it's not enough, you could increase
  # requests per hour by specifying the GitHub access token. For more details on GitHu
  # https://developer.github.com/v3/#rate-limiting
  #
  # You can create a GitHub token by following the instructions in
  # https://help.github.com/en/github/authenticating-to-github/creating-a-personal-acc
  #
  # github_token: xxx

jobservice:
  # Maximum number of job workers in job service
  max_job_workers: 10

notification:
  # Maximum retry count for webhook job
  webhook_job_max_retry: 10

chart:
  # Change the value of absolute_url to enabled can enable absolute url in chart
  absolute_url: disabled

# Log configurations
log:
  # options are debug, info, warning, error, fatal
  level: info
  # configs for logs in local storage
  local:
    # Log files are rotated log_rotate_count times before being removed. If count is 0
    rotate_count: 50
    # Log files are rotated only if they grow bigger than log_rotate_size bytes. If si
    # If the M is used, the size is in megabytes, and if G is used, the size is in gig
    # are all valid.
    rotate_size: 200M
    # The directory on your host that store log
    location: /var/log/harbor

  # Uncomment following lines to enable external syslog endpoint.
  # external_endpoint:
  #   # protocol used to transmit log to external endpoint, options is tcp or udp
  #   protocol: tcp
  #   # The host of external endpoint
  #   host: localhost
  #   # Port of external endpoint
  #   port: 5140

#This attribute is for migrator to detect the version of the .cfg file, DO NOT MODIFY!
_version: 2.0.0

# Uncomment external_database if using external database.
# external_database:
#   harbor:
#     host: harbor_db_host
#     port: harbor_db_port
#     db_name: harbor_db_name
#     username: harbor_db_username
#     password: harbor_db_password
#     ssl_mode: disable
#     max_idle_conns: 2
#     max_open_conns: 0
#   clair:
#     host: clair_db_host
#     port: clair_db_port
#     db_name: clair_db_name
#     username: clair_db_username
#     password: clair_db_password
#     ssl_mode: disable
#   notary_signer:
#     host: notary_signer_db_host
#     port: notary_signer_db_port
#     db_name: notary_signer_db_name
#     username: notary_signer_db_username
#     password: notary_signer_db_password
#     ssl_mode: disable
#   notary_server:
#     host: notary_server_db_host
#     port: notary_server_db_port
#     db_name: notary_server_db_name
#     username: notary_server_db_username
#     password: notary_server_db_password
#     ssl_mode: disable

# Uncomment external_redis if using external Redis server
# external_redis:
#   # support redis, redis+sentinel
#   # host for redis: <host_redis>:<port_redis>
#   # host for redis+sentinel:
#   #  <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_senti
#   host: redis:6379
#   password:
#   # sentinel_master_set must be set to support redis+sentinel
#   #sentinel_master_set:
#   # db_index 0 is for core, it's unchangeable
#   registry_db_index: 1
#   jobservice_db_index: 2
#   chartmuseum_db_index: 3
#   clair_db_index: 4
#   trivy_db_index: 5
#   idle_timeout_seconds: 30

# Uncomment uaa for trusting the certificate of uaa instance that is hosted via self-s
# uaa:
#   ca_file: /path/to/ca

# Global proxy
# Config http proxy for components, e.g. http://my.proxy.com:3128
# Components doesn't need to connect to each others via http proxy.
# Remove component from `components` array if want disable proxy
# for it. If you want use proxy for replication, MUST enable proxy
# for core and jobservice, and set `http_proxy` and `https_proxy`.
# Add domain to the `no_proxy` field, when you want disable proxy
# for some special registry.
proxy:
  http_proxy:
  https_proxy:
  no_proxy:
  components:
    - core
    - jobservice
    - clair
    - trivy
#修改完配置文件,进程安装操作
[root@localhost harbor]# ./install.sh 

[Step 0]: checking if docker is installed ...

Note: docker version: 19.03.13

[Step 1]: checking docker-compose is installed ...
/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend

Note: docker-compose version: 1.26.2

[Step 2]: loading Harbor images ...
81af4c478a3f: Loading layer [==================================================>]   34.5MB/34.5MB
4fa475ef4cbd: Loading layer [==================================================>]  63.62MB/63.62MB
5eff830f23a7: Loading layer [==================================================>]  73.67MB/73.67MB
bff112a0a7df: Loading layer [==================================================>]  6.144kB/6.144kB
92d0354f8258: Loading layer [==================================================>]   2.56kB/2.56kB
5b672e0d5a7c: Loading layer [==================================================>]   2.56kB/2.56kB
0012b787c903: Loading layer [==================================================>]   2.56kB/2.56kB
c1d893c2c205: Loading layer [==================================================>]   2.56kB/2.56kB
63018bb28a47: Loading layer [==================================================>]  11.26kB/11.26kB
Loaded image: goharbor/harbor-db:v2.1.1
117a4b9c585f: Loading layer [==================================================>]  39.48MB/39.48MB
0b4acae09a15: Loading layer [==================================================>]  3.072kB/3.072kB
846d3bae53bd: Loading layer [==================================================>]   59.9kB/59.9kB
2c0ec6969a29: Loading layer [==================================================>]  61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.1.1
7800c77b21f0: Loading layer [==================================================>]   8.46MB/8.46MB
ed90abbc3df2: Loading layer [==================================================>]  6.343MB/6.343MB
14d785d5e998: Loading layer [==================================================>]  14.43MB/14.43MB
1a60f4ccd1a7: Loading layer [==================================================>]  27.97MB/27.97MB
b198161fb35d: Loading layer [==================================================>]  22.02kB/22.02kB
7e4ed0ddff6a: Loading layer [==================================================>]  14.43MB/14.43MB
Loaded image: goharbor/notary-signer-photon:v2.1.1
48234182d466: Loading layer [==================================================>]  115.3MB/115.3MB
1a825d191bba: Loading layer [==================================================>]  12.59MB/12.59MB
582bbbec2032: Loading layer [==================================================>]  3.072kB/3.072kB
45afe505e59a: Loading layer [==================================================>]  49.15kB/49.15kB
f54e5a3cce60: Loading layer [==================================================>]  4.096kB/4.096kB
906e1b7ebbf0: Loading layer [==================================================>]  13.46MB/13.46MB
Loaded image: goharbor/clair-photon:v2.1.1
7c78c5b4e41d: Loading layer [==================================================>]  8.466MB/8.466MB
9706fb42af39: Loading layer [==================================================>]  4.096kB/4.096kB
412158a07706: Loading layer [==================================================>]  3.072kB/3.072kB
5a4149254af8: Loading layer [==================================================>]  9.427MB/9.427MB
ac618bd3efa5: Loading layer [==================================================>]  10.25MB/10.25MB
Loaded image: goharbor/clair-adapter-photon:v2.1.1
7621e4411b71: Loading layer [==================================================>]  12.24MB/12.24MB
88ebbde19b9a: Loading layer [==================================================>]  3.584kB/3.584kB
dd7f5fa0c20b: Loading layer [==================================================>]   2.56kB/2.56kB
61de20d88ce0: Loading layer [==================================================>]  53.05MB/53.05MB
7d03bb69f5c1: Loading layer [==================================================>]  5.632kB/5.632kB
99b674e86288: Loading layer [==================================================>]  60.42kB/60.42kB
421951bf6edd: Loading layer [==================================================>]  11.78kB/11.78kB
f0ce9f0cf59d: Loading layer [==================================================>]  53.87MB/53.87MB
adb52dc1f963: Loading layer [==================================================>]   2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.1.1
9b74f5ada1af: Loading layer [==================================================>]  10.31MB/10.31MB
e48bb7f757c7: Loading layer [==================================================>]  8.986MB/8.986MB
9b9758ae081f: Loading layer [==================================================>]  173.6kB/173.6kB
072402c85f81: Loading layer [==================================================>]  152.6kB/152.6kB
6900a5d9558b: Loading layer [==================================================>]  67.07kB/67.07kB
4a5c5d9b23fc: Loading layer [==================================================>]  17.41kB/17.41kB
08c7bfa040bb: Loading layer [==================================================>]  15.36kB/15.36kB
Loaded image: goharbor/harbor-portal:v2.1.1
3f036012790d: Loading layer [==================================================>]  74.74MB/74.74MB
6486b9b0bea4: Loading layer [==================================================>]  3.584kB/3.584kB
fcb4207cbe8b: Loading layer [==================================================>]  3.072kB/3.072kB
f80a573a5b31: Loading layer [==================================================>]   2.56kB/2.56kB
7297e3f9a0b8: Loading layer [==================================================>]  3.072kB/3.072kB
ec743a12422d: Loading layer [==================================================>]  3.584kB/3.584kB
06af0f6c6c0a: Loading layer [==================================================>]  12.29kB/12.29kB
3a03e3162ccb: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: goharbor/harbor-log:v2.1.1
9b886c2b88ee: Loading layer [==================================================>]  10.31MB/10.31MB
Loaded image: goharbor/nginx-photon:v2.1.1
9557ca1fbfe7: Loading layer [==================================================>]  77.33MB/77.33MB
6fd533f8ba56: Loading layer [==================================================>]  49.89MB/49.89MB
2eb9181e5c98: Loading layer [==================================================>]   2.56kB/2.56kB
516fbf6480ef: Loading layer [==================================================>]  1.536kB/1.536kB
67687e526277: Loading layer [==================================================>]  18.43kB/18.43kB
cf31cddf7676: Loading layer [==================================================>]  4.043MB/4.043MB
4630eb98dd7a: Loading layer [==================================================>]  266.2kB/266.2kB
Loaded image: goharbor/prepare:v2.1.1
a319c7fa9a57: Loading layer [==================================================>]  8.466MB/8.466MB
866240ea7853: Loading layer [==================================================>]  4.096kB/4.096kB
0e57611ac97f: Loading layer [==================================================>]  20.51MB/20.51MB
64b6488d8b42: Loading layer [==================================================>]  3.072kB/3.072kB
e3aa629f0e54: Loading layer [==================================================>]  25.91MB/25.91MB
e1a654cccad5: Loading layer [==================================================>]  47.24MB/47.24MB
Loaded image: goharbor/harbor-registryctl:v2.1.1
aeb529371336: Loading layer [==================================================>]  15.84MB/15.84MB
3825bcdb8937: Loading layer [==================================================>]  27.97MB/27.97MB
d35ad2e83013: Loading layer [==================================================>]  22.02kB/22.02kB
4cae6ab55745: Loading layer [==================================================>]  15.84MB/15.84MB
Loaded image: goharbor/notary-server-photon:v2.1.1
03c1cfd538b9: Loading layer [==================================================>]  9.762MB/9.762MB
bb229ed4a902: Loading layer [==================================================>]  4.096kB/4.096kB
53080b277f56: Loading layer [==================================================>]  3.072kB/3.072kB
8d0c44eee93d: Loading layer [==================================================>]  23.51MB/23.51MB
6a867e399ba9: Loading layer [==================================================>]  9.432MB/9.432MB
885cf5f9a697: Loading layer [==================================================>]  33.76MB/33.76MB
Loaded image: goharbor/trivy-adapter-photon:v2.1.1
ab97c837dabc: Loading layer [==================================================>]  12.24MB/12.24MB
2b9ed339f3e9: Loading layer [==================================================>]  3.584kB/3.584kB
136a56bdcff8: Loading layer [==================================================>]   2.56kB/2.56kB
9b73d85a3395: Loading layer [==================================================>]  62.26MB/62.26MB
97eeb1c8ba34: Loading layer [==================================================>]  63.09MB/63.09MB
Loaded image: goharbor/harbor-jobservice:v2.1.1
5ad257a201da: Loading layer [==================================================>]  8.465MB/8.465MB
8d38823b6ed8: Loading layer [==================================================>]  66.44MB/66.44MB
e177bb58e2da: Loading layer [==================================================>]  3.072kB/3.072kB
0f55ea3be23d: Loading layer [==================================================>]  4.096kB/4.096kB
2c47702c1637: Loading layer [==================================================>]  67.27MB/67.27MB
Loaded image: goharbor/chartmuseum-photon:v2.1.1
ee934b038aca: Loading layer [==================================================>]  8.466MB/8.466MB
21b5c3fb5cc2: Loading layer [==================================================>]  4.096kB/4.096kB
fb579280336a: Loading layer [==================================================>]  3.072kB/3.072kB
e5a1aa8a3f60: Loading layer [==================================================>]  20.51MB/20.51MB
37db791e93fd: Loading layer [==================================================>]  21.33MB/21.33MB
Loaded image: goharbor/registry-photon:v2.1.1


[Step 3]: preparing environment ...

[Step 4]: preparing harbor configs ...
prepare base dir is set to /opt/harbor
Generated configuration file: /config/portal/nginx.conf
Generated configuration file: /config/log/logrotate.conf
Generated configuration file: /config/log/rsyslog_docker.conf
Generated configuration file: /config/nginx/nginx.conf
Generated configuration file: /config/core/env
Generated configuration file: /config/core/app.conf
Generated configuration file: /config/registry/config.yml
Generated configuration file: /config/registryctl/env
Generated configuration file: /config/registryctl/config.yml
Generated configuration file: /config/db/env
Generated configuration file: /config/jobservice/env
Generated configuration file: /config/jobservice/config.yml
Generated and saved secret to file: /data/secret/keys/secretkey
Successfully called func: create_root_cert
Generated configuration file: /compose_location/docker-compose.yml
Clean up the input dir

/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend


[Step 5]: starting Harbor ...
/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry      ... done
Creating registryctl   ... done
Creating harbor-db     ... done
Creating redis         ... done
Creating harbor-portal ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----
[root@localhost harbor]# 
#启动停止
[root@localhost harbor]# cd /opt/harbor
[root@localhost harbor]# docker-compose down
/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
  from cryptography.hazmat.backends import default_backend
Stopping nginx             ... done
Stopping harbor-jobservice ... done
Stopping harbor-core       ... done
Stopping redis             ... done
Stopping harbor-portal     ... done
Stopping registryctl       ... done
Stopping harbor-db         ... done
Stopping registry          ... done
Stopping harbor-log        ... done
Removing nginx             ... done
Removing harbor-jobservice ... done
Removing harbor-core       ... done
Removing redis             ... done
Removing harbor-portal     ... done
Removing registryctl       ... done
Removing harbor-db         ... done
Removing registry          ... done
Removing harbor-log        ... done
Removing network harbor_harbor
[root@localhost harbor]# docker-compose up -d

浏览器访问
登录harbor 账户密码在配置文件内
修改docker配置文件

vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"],
  "insecure-registries": ["harbor.example.com"]
}

推送镜像

docker harbor.example.com
docker tag busybox:latest harbor.example.com/test/busybox:latest
docker push harbor.example.com/test/busybox:latest
<think>嗯,用户想在CentOS 7.6部署Box服务或应用,我需要先理清步骤。首先,可能得确认Box的具体类型,比如是文件存储服务还是其他应用。假设是常见的文件共享服务,可能需要安装依赖、下载软件包、配置环境,然后启动服务。 接下来,我应该考虑系统准备,比如更新系统、安装必要的工具,如wget或yum-utils。用户之前提到过使用yum安装Docker,可能可以参考类似的方法。可能需要添加特定的软件源,或者直接从官网下载安装包。 然后,安装Box服务可能需要下载官方提供的RPM包或者源码编译。如果是通过yum安装,可能需要配置第三方仓库,比如添加Box的repo文件。如果官网没有提供,可能需要手动下载并安装。 配置部分可能需要编辑配置文件,设置端口、用户权限、存储路径等。防火墙设置也很重要,CentOS 7用的是firewalld,需要开放相应端口,比如80或443,或者自定义端口。SELinux可能会影响服务运行,可能需要调整策略或关闭。 启动服务后,确保开机自启,用systemctl enable。测试部署是否成功,可以通过curl访问本地端口,或者查看服务状态日志。 另外,用户提供的引用里有关于Docker安装的步骤,如果Box有Docker镜像的话,可能用Docker部署会更方便,比如拉取镜像、运行容器,挂载卷等。但用户可能更倾向于直接安装,所以需要两种方法都考虑。 最后,生成相关问题,比如优化性能、配置SSL,或者备份策略。需要确保每个步骤都清晰,用户容易跟随,避免遗漏关键步骤,比如依赖安装或防火墙设置。</think>### 在 CentOS 7.6部署 Box 服务的步骤指南 #### 1. 系统环境准备 - **更新系统** 确保系统组件为最新版本: ```bash sudo yum update -y ``` - **安装必要工具** 安装依赖工具(如`wget`、`curl`等): ```bash sudo yum install -y wget curl epel-release ``` #### 2. 安装 Box 服务 假设部署的是类似“FileCloud”或“Nextcloud”的类 Box 文件存储服务,以 **Nextcloud** 为例: - **安装 PHP 和数据库** Nextcloud 依赖 PHP 和数据库(如 MariaDB): ```bash sudo yum install -y httpd mariadb-server mariadb php php-mysqlnd php-gd php-json php-mbstring php-xml php-zip ``` - **启动服务并设置开机自启** ```bash sudo systemctl start httpd mariadb sudo systemctl enable httpd mariadb ``` - **配置数据库** 初始化 MariaDB 并创建数据库: ```bash sudo mysql_secure_installation mysql -u root -p # 执行 SQL 命令 CREATE DATABASE nextcloud; CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; FLUSH PRIVILEGES; ``` #### 3. 下载并配置 Nextcloud - **下载安装包** ```bash wget https://download.nextcloud.com/server/releases/latest.zip sudo unzip latest.zip -d /var/www/html/ sudo chown -R apache:apache /var/www/html/nextcloud ``` - **配置 Apache** 编辑配置文件 `/etc/httpd/conf.d/nextcloud.conf`: ```apache <VirtualHost *:80> DocumentRoot /var/www/html/nextcloud ServerName your_domain.com <Directory /var/www/html/nextcloud> Require all granted AllowOverride All </Directory> </VirtualHost> ``` - **重启 Apache** ```bash sudo systemctl restart httpd ``` #### 4. 防火墙与 SELinux 配置 - **开放 HTTP/HTTPS 端口** ```bash sudo firewall-cmd --permanent --add-service=http --add-service=https sudo firewall-cmd --reload ``` - **调整 SELinux 策略** 若遇到权限问题,临时关闭 SELinux 或设置规则: ```bash sudo setenforce 0 # 临时关闭 # 或永久修改 /etc/selinux/config 中 SELINUX=permissive ``` #### 5. 完成安装 通过浏览器访问 `http://your_server_ip`,按向导完成 Nextcloud 的初始化配置(填写数据库信息和管理员账户)[^2]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值