热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CentOS7安装ownCloud

ownCloud的安装依赖LAMP环境,即LinuxApacheMySQL(Mariadb)PHP,所以在装owncloud前最好先装好这些࿰

ownCloud的安装依赖LAMP环境,即 Linux + Apache +  MySQL(Mariadb) + PHP,所以在装owncloud前最好先装好这些,并且保证已经可用。

    为了方便,本文在运行shell命令时都是以管理员用户身份运行(root权限下运行)!!!


具体步骤:

    这里重申一下,为免麻烦,以下命令都是以管理员用户的身份运行的,root权限下执行的!


1. 开放防火墙

setenforce 0
sed -i 's/enforcing/disabled/' /etc/selinux/config
systemctl disable --now firewalld
reboot

2. 安装php 7.2 + apahce 运行环境

yum install centos-release-scl-rh -y
# yum search php
yum install rh-php72 -y
yum install rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-intl rh-php72-php-pecl-apcu -y
yum install rh-php72-php-mysqlnd -y
scl -l
scl enable rh-php72 "php -v"
scl enable rh-php72 bash
php -v
php -myum install -y httpd
systemctl start httpd
systemctl enabled httpdln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/systemctl restart httpd

3.  下载owncloud包

    去owncloud官网 https://download.owncloud.org/community/owncloud-10.5.0.tar.bz2  下载包并解压,解压后的包文件夹名称应该也是owncloud

官网下载owncloud包

   解压安装

yum install bzip2 lrzsz -y
mkdir -p /var/www/html/owncloud
tar -xjvf owncloud-10.5.0.tar.bz2
cd owncloud
yes | cp -r * /var/www/html/owncloud/
chown -R apache:apache /var/www/html/owncloud
chmod -R 777 /var/www/html/owncloud
chcon -v -R -u system_u -r object_r -t httpd_sys_content_t '/var/www/html/owncloud/'
chcon -R -t httpd_sys_rw_content_t '/var/www/html/owncloud/config/'
chcon -R -t httpd_sys_rw_content_t '/var/www/html/owncloud/apps/'
cd /var/www/html/owncloud
mkdir data
chown -R apache:apache /var/www/html/owncloud/
chcon -v -R -u system_u -r object_r -t httpd_sys_content_t '/var/www/html/owncloud/'
chcon -R -t httpd_sys_rw_content_t '/var/www/html/owncloud/data/'
chcon -R -t httpd_sys_rw_content_t '/var/www/html/owncloud/config/'
chcon -R -t httpd_sys_rw_content_t '/var/www/html/owncloud/apps/'
systemctl restart httpd

3,安装mysql数据库

yum -y install wget gcc gcc-c++ ncurses ncurses-devel cmake numactl.x86_64 libaio
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.24-linux-glibc2.12-x86_64/ /usr/local/mysql
cd /usr/local/mysql/
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cat >/etc/my.cnf <[client]
port&#61;3306
socket&#61;/tmp/mysql.sock
[mysqld]
port&#61;3306
socket&#61;/tmp/mysql.sock
skip-external-locking
key_buffer_size &#61; 38M
max_allowed_packet &#61; 1M
table_open_cache &#61; 64
sort_buffer_size &#61; 512K
net_buffer_length &#61; 8K
read_buffer_size &#61; 256K
read_rnd_buffer_size &#61; 512K
myisam_sort_buffer_size &#61; 8M
basedir&#61;/usr/local/mysql
datadir&#61;/var/lib/mysql
bind-address&#61;0.0.0.0
innodb_flush_log_at_trx_commit&#61;1
sync_binlog&#61;1
log-bin&#61;/var/lib/mysql/mysql_logbin
log-error&#61;/var/log/mariadb
slow_query_log &#61;1
slow_query_log_file&#61;/tmp/mysql_slow.log
server-id&#61;1
symbolic-links&#61;0
[mysqld_safe]
pid-file&#61;/var/run/mariadb/mariadb.pid
EOFuseradd mysql
mkdir -p /var/lib/mysql
chown mysql:mysql /var/lib/mysql
mkdir -p /var/log/mariadb
chown mysql:mysql /var/log/mariadb/
mkdir -p /var/run/mariadb
chown mysql:mysql /var/run/mariadb/
touch /var/run/mariadb/mariadb.pid
cat >> /etc/profile <export PATH&#61;\$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
EOF
source /etc/profile
chmod -R 777 /var/log
mysqld --defaults-file&#61;/etc/my.cnf --user&#61;mysql --initialize-insecure
/etc/init.d/mysql startmysql -u root -p
update mysql.user set authentication_string&#61;password(&#39;123456&#39;) where user&#61;&#39;root&#39;;
flush privileges;ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock

登录owncloud&#xff0c;创建管理员用户&#xff0c;访问&#xff1a;http://192.168.225.194/owncloud/ 

 

登录owncloud&#xff0c;创建管理员用户

    【注意&#xff01;】  图4这步包括以下内容&#xff1a;1. 创建owncloud的管理员用户&#xff08;Create an admin account&#xff09;。2. 数据存储文件夹&#xff08;Data folder&#xff09;。这里默认文件夹就可以了&#xff0c;不用管。  3. 配置数据库&#xff0c;包括数据库类型的选择&#xff0c;对应的用户、密码、数据库配置。这里默认是SQLite数据库类型&#xff0c;如果要用MySQL或者MariaDB的&#xff0c;这里一定要配置一下。如果忘记配置了&#xff0c;可以参考博文《如何将owncloud的数据库从SQLite迁移到MySQL/MariaDB》迁移数据库。


4 . 本机登录看看

登录owncloud

图4. 登录owncloud

8. 配置trusted_domains

    在其他电脑上访问服务器&#xff08;假设IP为198.12.12.6&#xff09;&#xff0c;提示需要配置trusted_domains。

配置trusted_domains

图5. 配置trusted_domains

    从图片中的提示可以看出来&#xff0c;需要在服务器上配置/var/www/html/owncloud/config/config.php文件&#xff0c;并且在同一个文件夹下有一个配置的示例文件config.sample.php可供参考。

vim /var/www/html/owncloud/config/config.php

修改配置文件trusted_domains

图6. 修改配置文件trusted_domains

    前5行都不要动&#xff0c;在第8行  0 &#61;> &#39;c1loud.frankgreg.com&#39;,  这一行后面添加如下一句(假设服务器IP为192.12.12.6)

1 &#61;> &#39;192.12.12.6&#39;,

    重启httpd服务&#xff0c;完工。

systemctl restart httpd

推荐阅读
author-avatar
乐在TV
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有