centos7搭建owncloud私有云

sealin發表於2017-11-28
版權宣告:本文為博主原創文章,轉載請標明出處。 https://blog.csdn.net/chaoyu168/article/details/78651362

1、更改yum源

[1] 首先備份/etc/yum.repos.d/CentOS-Base.repo

[root@localhostyum.repos.d]#
mv
/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup

[2] 進入yum源配置檔案所在資料夾

[root@localhostyum.repos.d]# cd /etc/yum.repos.d/

[3] 下載阿里的yum源配置檔案,放入/etc/yum.repos.d/(操作前請做好相應備份)

[root@localhostyum.repos.d]# wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[4] 執行yum makecache生成快取

[root@localhostyum.repos.d]# yum makecache

2、安裝php

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm

rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install php70w.x86_64 php70w-cli.x86_64php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64php70w-mcrypt.x86_64 php70w-mysql.x86_64 php70w-pdo.x86_64 php70w-devel.x86_64gd gd-devel php70w-pear.x86_64 php70w-xmlrpc.x86_64 php70w-imap.x86_64php70w-dom.x86_64
php70w-xmlwriter.x86_64 php70w-mcrypt.x86_64php70w-pecl-imagick.x86_64 php70w-xml.x86_64 php70w-pecl-redis.x86_64

 

yum install php70w-fpm

systemctl enable php-fpm.service

配置php

 vim/etc/php.ini

在php.ini裡查詢
max_execution_time
預設是30秒.改為
max_execution_time = 0

查詢 post_max_size .改為
post_max_size = 10240M

查詢upload_max_filesize,預設為8M改為
upload_max_filesize = 10240M

max_input_time = 7200

memory_limit = 10240m

 

3、  安裝Mariadb

[root@linuxprobe~]# yum -y install mariadb-server

[root@linuxprobe~]# vi /etc/my.cnf

# add follows within [mysqld] section

[mysqld]

character-set-server=utf8

[root@linuxprobe~]# systemctl start mariadb

[root@linuxprobe~]# systemctl enable mariadb

·        初始化MariaDB

[root@linuxprobe~]# mysql_secure_installation   #MySQL一樣,一路y

·        1

·        連線MariaDB

[root@linuxprobe~]# mysql -u root -p

Enter password:

Welcome to theMariaDB monitor.  Commands end with ; org.

Your MariaDBconnection id is 1023

Server version:5.5.50-MariaDB MariaDB Server

 

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

 

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

 

MariaDB[(none)]> select user,host,password from mysql.user;

+———–+———–+——————————————-+

| user      | host      | password                                  |

+———–+———–+——————————————-+

| root      | localhost | *F1DAE8BCDFCA7A57F246E0F834AC35830A3D640E|

| root      | 127.0.0.1 |*F1DAE8BCDFCA7A57F246E0F834AC35830A3D640E |

| root      | ::1       |*F1DAE8BCDFCA7A57F246E0F834AC35830A3D640E |

+———–+———–+——————————————-+

5 rows in set(0.00 sec)

MariaDB[(none)]> show databases;

+——————–+

| Database           |

+——————–+

|information_schema |

| mysql              |

|performance_schema |

+——————–+

5 rows in set(0.05 sec)

MariaDB[(none)]> exit;

Bye

防火牆開啟埠

# 客戶端設定

[root@vdevops ~]# firewall-cmd –add-service=mysql–permanent

success

[root@vdevops ~]# firewall-cmd –reload

success

#firewall-cmd –permanent –zone=public–add-service=http
#firewall-cmd –permanent –zone=public–add-service=https

#firewall-cmd –reload

 

.配置mariadb例項
#mysql_secure_installation;

Set root password?[Y/n]New password: (輸入資料庫密碼等下需要)
Re-enter new password:
(再次確認密碼)
Remove anonymous users?[Y/n]Y

Disallow root login remotely?[Y/n]Y
Remove test database and access to it?[Y/n]Y
Reload privilege tables now?[Y/n]Y

 

安裝apache

[1]安裝 httpd.

[root@linuxprobe ~]# yum -y install httpd

# 刪除預設歡迎頁面

[root@linuxprobe ~]# rm -f /etc/httpd/conf.d/welcome.conf

[2]配置httpd,將伺服器名稱替換為您自己的環境

[root@linuxprobe ~]# vi /etc/httpd/conf/httpd.conf

# line 86: 改變管理員的郵箱地址

ServerAdmin root@linuxprobe.org

# line 95: 改變域名資訊

ServerName www.linuxprobe.org:80

# line 151: none變成All

AllowOverride All

# line 164: 新增只能使用目錄名稱訪問的檔名

DirectoryIndex index.htmlindex.cgi
index.php

# add follows to the end

# server`s response header(安全性)

ServerTokens Prod

# keepalive is ON

KeepAlive On

[root@linuxprobe ~]# systemctl start httpd

[root@linuxprobe ~]# systemctl enable httpd

[3]如果Firewalld正在執行,請允許HTTP服務。,HTTP使用80
/ TCP

[root@linuxprobe ~]# firewall-cmd –add-service=http–permanent

success

[root@linuxprobe ~]# firewall-cmd –reload

Success

·        安裝ownCloud

# install fromEPEL

[root@linuxprobe ~]# yum –enablerepo=epel -y installphp-pear-MDB2-Driver-mysqli php-pear-Net-Curl

[root@linuxprobe ~]# wgethttp://download.owncloud.org/download/repositories/stable/CentOS_7/ce:stable.repo-P
/etc/yum.repos.d

[root@linuxprobe ~]# yum -y install owncloud

[root@linuxprobe ~]# systemctl restart httpd

 

·        MariaDB中為ownCloud新增使用者和資料庫。

[root@linuxprobe~]# mysql -u root -p

Enter password:

ERROR 1045 (28000): Access deniedfor
user
`root`@`localhost` (using password: YES)

[root@linuxprobe~]# mysql -u root -p

Enter password:

Welcome to the MariaDB monitor.  Commandsendwith
;
or g.

Your MariaDBconnection id is11

Server version: 5.5.52-MariaDB MariaDB Server

 

Copyright (c) 2000,2016, Oracle, MariaDB Corporation Aband
others.

 

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

 

MariaDB[(none)]> create database owncloud;

Query OK, 1 row affected (0.15 sec)

 

MariaDB[(none)]> grant all privilegeson owncloud.*to owncloud@`localhost`
identified
by`password`;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB[(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]>exit

Bye

注:如果系統開啟selinux,需設定以下操作:

[root@linuxprobe ~]# semanage fcontext -a -thttpd_sys_rw_content_t /var/www/html/owncloud/apps

[root@linuxprobe ~]# semanage fcontext -a -thttpd_sys_rw_content_t /var/www/html/owncloud/config

[root@linuxprobe ~]# restorecon /var/www/html/owncloud/apps

[root@linuxprobe ~]# restorecon /var/www/html/owncloud/config


相關文章