阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

基于Linux的ownCloud搭建

129次阅读
没有评论

共计 13576 个字符,预计需要花费 34 分钟才能阅读完成。

为了保证一个纯净的环境,我重新安装了一台 CentOS 系统

[root@localhost httpd-2.2.23]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.3 (Final)
Release:        6.3
Codename:      Final

在安装玩系统之后,首先需要搭建 yum 源,centos 的网络 yum 源是非常简单的,甚至不需要你修改任何配置,只要安装一个小软件,rpm -ivh epel-release-6-5.noarch.rpm

然后 yum 就可以使用了

第一部分 apache 的安装

由于在编译 apache 的时候,需要用到一些插件,所以我们需要提前安装

yum install gcc gcc-c++ ncursers-devel  zlib2-zip  -y

apache 的编译安装很简单,但是我们需要安装一些包便于 apache 功能的扩展

1、apr-1.4.6.tar.gz 的安装

[root@localhost lamp]# tar xf apr-1.4.6.tar.gz -C /usr/src/lamp/

[root@localhost apr-1.4.6]# pwd
/usr/src/lamp/apr-1.4.6

[root@localhost apr-1.4.6]# ./configure –enable-threads –disable-ipv6 –with-devrandowm=/dev/random && make && make install

2、libiconv-1.13.tar.gz 的安装

[root@localhost libiconv-1.13]# ./configure –enable-static && make && make install

3、apr-iconv-1.2.1.tar.gz 的安装

[root@localhost lamp]# tar xf apr-iconv-1.2.1.tar.gz -C /usr/src/lamp/

[root@localhost apr-iconv-1.2.1]# ./configure –with-apr=/usr/local/apr/bin/apr-1-config

[root@localhost lamp]# make  && make install

[root@localhost apr-iconv-1.2.1]# ln -s /usr/src/lamp/apr-iconv-1.2.1/lib/libapriconv-1.la  /usr/src/lamp/apr-iconv-12.1/lib/libapriconv.la

4、安装 openssl nss-devel

[root@localhost lamp]# yum install openssl* nss-devel -y

5、安装 apr-util-1.4.1.tar.gz

[root@localhost lamp]# tar xf apr-util-1.4.1.tar.gz -C /us
r/src/lamp/

[root@localhost apr-util-1.4.1]# ./configure –with-apr=/usr/local/apr/bin/apr-1-config –with-apr-iconv=./apr-iconv –with-openssl=/usr –with-nss=/usr –with-MySQL=/usr/local/mysql –with-iconv=/usr/local && make && make install

6、安装两个 rpm 包

libzip-0.9-3.1.el6.i686.rpm
libzip-devel-0.9-3.1.el6.i686.rpm

[root@localhost lamp]# rpm -ivh libzip-0.9-3.1.el6.i686.rpm
warning: libzip-0.9-3.1.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing…                                              ########################################### [100%]
  1:libzip                                              ########################################### [100%]
[root@localhost lamp]# rpm -ivh libzip-devel-0.9-3.1.el6.i686.rpm
warning: libzip-devel-0.9-3.1.el6.i686.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing…                                              ########################################### [100%]
  1:libzip-devel                                        ########################################### [100%]

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-10/92073p2.htm

参考阅读

在 Ubuntu 12.04 LTS 上安装 ownCloud 4.0.6 平台 http://www.linuxidc.com/Linux/2012-08/68297.htm

CentOS 6.2 下安装 ownCloud 4.0 图解 http://www.linuxidc.com/Linux/2013-03/80994.htm

Ubuntu 12.04 下使用 ownCloud 搭建私人存储云  http://www.linuxidc.com/Linux/2013-08/89380.htm
 

7、安装 pcre-7.9.tar.gz

[root@localhost lamp]# tar xf pcre-7.9.tar.gz -C /usr/src/lamp/

[root@localhost pcre-7.9]# ./configure –enable-utf8 –enable-rebuild-chartables –enable-newline-is-any –enable-pcregrep-libz –enable-pcregrep-libbz2

make && make install

8、安装 httpd–2.2.23.tar.gz

[root@localhost softs]# tar xf httpd–2.2.23.tar.gz -C /usr/src/

[root@localhost softs]# cd /usr/src/httpd-2.2.23/

[root@localhost httpd-2.2.23]# ./configure –enable-modules=all –enable-mods-shared=all –enable-cache –enable-disk-cache –enable-dumpio –enable-echo –enable-example –enable-logio –enable-mime-magic –enable-expires –enable-headers –enable-unique-id –enable-proxy –enable-proxy-balancer –enable-proxy-http –enable-proxy-ajp –enable-proxy-connect –enable-ssl –enable-static-ab –enable-http –enable-info –enable-cgi –enable-vhost-alias –enable-so –enable-rewrite –with-apr=/usr/local/apr-httpd/bin/apr-1-config –with-apr-util=/usr/local/apr-httpd/bin/apu-1-config –with-pcre=/usr/local –with-ssl=/usr –with-mpm=prefork

9、修改 apache 配置文件

[root@localhost ~]# vi /usr/local/apache2/conf/httpd.conf 指定 DocumentRoot 和允许访问

基于 Linux 的 ownCloud 搭建

 

将 第 195 行的目录路径也改为 /var/www <Directory “/var/www”>

[root@localhost ~]# mkdir /var/www /var/log/httpd

[root@localhost ~]# chown -R daemon.daemon /var/www /var/log/httpd

[root@localhost ~]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/apache

[root@localhost ~]# /etc/init.d/apache start

[root@localhost htdocs]# mv /usr/local/apache2/htdocs/index.html /var/www/ —— 将 apache 默认路径下的 index.html 移动到指定的 DocumentRoot 下面

浏览器访问 http://127.0.0.1/

 

It works!

10、开启虚拟主机
[root@localhost conf]# vi httpd.conf
将这一行前面的 #去掉
Include conf/extra/httpd-vhosts.conf
[root@localhost extra]# cd /usr/local/apache2/conf/extra/
[root@localhost extra]# vi httpd-vhosts.conf ## 增加一台虚拟主机
<VirtualHost *:80>
ServerAdmin owncloud@localhost
DocumentRoot “/var/www/owncloud”
ServerName test.owncloud.com
ErrorLog “/var/log/httpd/owncloud.error.log”
CustomLog “/var/log/httpd/owncloud-access_log” common
</VirtualHost>
重启 apache 服务
apache 的安装到此完成
####################################################################
第二部分 MySQL 的安装(如果只是为了安装 owncloud,此过程可以省略,我还有装其他服务,为了方便编译 php,所以我预装了 mysql)
 
1、 新建用户及相关目录, 并修改相关的属主和属组。

useradd mysql

mkdir /var/log/mysqld

mkdir /var/run/mysqld

mkdir /database

chown mysql.mysql -R /var/log/mysqld /var/run/mysqld /database

 

 

2、下载软件并解压编译安装

下载地址 http://yun.baidu.com/share/link?shareid=933310467&uk=2819702030&third=0

[root@localhost softs]# tar xf mysql-5.6.10.tar.gz -C /usr/src/
[root@localhost softs]# cd /usr/src/mysql-5.6.10/

基于 Linux 的 ownCloud 搭建

3、这里需要 cmake 安装

[root@localhost mysql-5.6.10]# cmake -DCMAKE_ISTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DMYSQL_DATADIR=/datadir -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql5.sock -DWITH_DEBUG=ON -DEXTRA_CHARSETS=ALL -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DSYSCONFDIR=/usr/local/mysql/etc -DWITH_READLINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1

基于 Linux 的 ownCloud 搭建

基于 Linux 的 ownCloud 搭建

4、通过对比可以看出,在 cmake 前后的差异还是蛮大的,接下来 make

[root@localhost mysql-5.6.10]# make

基于 Linux 的 ownCloud 搭建

5、make 这一步比较慢,需要多等一下,下一步就是 make install

基于 Linux 的 ownCloud 搭建

make install 完成后,接下来就是对 mysql 进行配置

为了保证一个纯净的环境,我重新安装了一台 CentOS 系统

[root@localhost httpd-2.2.23]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.3 (Final)
Release:        6.3
Codename:      Final

在安装玩系统之后,首先需要搭建 yum 源,centos 的网络 yum 源是非常简单的,甚至不需要你修改任何配置,只要安装一个小软件,rpm -ivh epel-release-6-5.noarch.rpm

然后 yum 就可以使用了

第一部分 apache 的安装

由于在编译 apache 的时候,需要用到一些插件,所以我们需要提前安装

yum install gcc gcc-c++ ncursers-devel  zlib2-zip  -y

apache 的编译安装很简单,但是我们需要安装一些包便于 apache 功能的扩展

1、apr-1.4.6.tar.gz 的安装

[root@localhost lamp]# tar xf apr-1.4.6.tar.gz -C /usr/src/lamp/

[root@localhost apr-1.4.6]# pwd
/usr/src/lamp/apr-1.4.6

[root@localhost apr-1.4.6]# ./configure –enable-threads –disable-ipv6 –with-devrandowm=/dev/random && make && make install

2、libiconv-1.13.tar.gz 的安装

[root@localhost libiconv-1.13]# ./configure –enable-static && make && make install

3、apr-iconv-1.2.1.tar.gz 的安装

[root@localhost lamp]# tar xf apr-iconv-1.2.1.tar.gz -C /usr/src/lamp/

[root@localhost apr-iconv-1.2.1]# ./configure –with-apr=/usr/local/apr/bin/apr-1-config

[root@localhost lamp]# make  && make install

[root@localhost apr-iconv-1.2.1]# ln -s /usr/src/lamp/apr-iconv-1.2.1/lib/libapriconv-1.la  /usr/src/lamp/apr-iconv-12.1/lib/libapriconv.la

4、安装 openssl nss-devel

[root@localhost lamp]# yum install openssl* nss-devel -y

5、安装 apr-util-1.4.1.tar.gz

[root@localhost lamp]# tar xf apr-util-1.4.1.tar.gz -C /us
r/src/lamp/

[root@localhost apr-util-1.4.1]# ./configure –with-apr=/usr/local/apr/bin/apr-1-config –with-apr-iconv=./apr-iconv –with-openssl=/usr –with-nss=/usr –with-MySQL=/usr/local/mysql –with-iconv=/usr/local && make && make install

6、安装两个 rpm 包

libzip-0.9-3.1.el6.i686.rpm
libzip-devel-0.9-3.1.el6.i686.rpm

[root@localhost lamp]# rpm -ivh libzip-0.9-3.1.el6.i686.rpm
warning: libzip-0.9-3.1.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing…                                              ########################################### [100%]
  1:libzip                                              ########################################### [100%]
[root@localhost lamp]# rpm -ivh libzip-devel-0.9-3.1.el6.i686.rpm
warning: libzip-devel-0.9-3.1.el6.i686.rpm: Header V4 DSA/SHA1 Signature, key ID 192a7d7d: NOKEY
Preparing…                                              ########################################### [100%]
  1:libzip-devel                                        ########################################### [100%]

更多详情见请继续阅读下一页的精彩内容 :http://www.linuxidc.com/Linux/2013-10/92073p2.htm

参考阅读

在 Ubuntu 12.04 LTS 上安装 ownCloud 4.0.6 平台 http://www.linuxidc.com/Linux/2012-08/68297.htm

CentOS 6.2 下安装 ownCloud 4.0 图解 http://www.linuxidc.com/Linux/2013-03/80994.htm

Ubuntu 12.04 下使用 ownCloud 搭建私人存储云  http://www.linuxidc.com/Linux/2013-08/89380.htm
 

6、对 MySQL 的初始化操作

[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db –basedir=/usr/local/mysql –datadir=/database –user=mysql

 

2013-10-28 04:13:57 13176 [Note] InnoDB: FTS optimize thread exiting.
2013-10-28 04:13:57 13176 [Note] InnoDB: Starting shutdown…
2013-10-28 04:13:58 13176 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables…2013-10-28 04:13:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
2013-10-28 04:13:58 7f78a8ba0720 InnoDB: !!!!!!!! UNIV_DEBUG switched on !!!!!!!!!
2013-10-28 04:13:58 7f78a8ba0720 InnoDB: !!!!!!!! UNIV_SYNC_DEBUG switched on !!!!!!!!!
2013-10-28 04:13:58 13199 [Note] InnoDB: The InnoDB memory heap is disabled
…………………………
2013-10-28 04:14:00 13199 [Note] InnoDB: Starting shutdown…
2013-10-28 04:14:01 13199 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

两个 OK 表示成功

7、修改 mysql 的几个配置文件

[root@localhost ~]# cd /usr/local/mysql/

[root@localhost etc]# chown -R mysql.mysql /usr/local/mysql
[root@localhost mysql]# mkdir etc
[root@localhost mysql]# cd etc/
[root@localhost etc]# vi my.cnf ———– 主配置文件的修改

[root@localhost etc]# cat my.cnf | grep -v ^# | grep -v ^$
[mysqld]
log_bin=myql-bin
log-bin-index=mysql-bin.index
log-error=/var/log/mysqld/error.log
general_log=1
general_log_file=/var/log/mysqld/mysql.log
basedir = /usr/local/mysql
datadir = /database
port = 3306
socket = /var/run/mysqld/mysql5.socket
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[root@localhost etc]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql5

开始尝试启动 mysql

[root@localhost mysqld]# /etc/init.d/mysql5 restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL.. [OK]

mysql 到此安装完成

##############################################################

第三部分 php 的安装

 

1、下载软件并安装

yum install libxml2 libxml2-devel -y libcurl libcurl-devel openssl openssl-devel

[root@localhost php-5.3.27]# ./configure –with-apxs2=/usr/local/apache2/bin/apxs –disable-ipv6 –with-libxml-dir=/usr –with-openssl=/usr –with-zlib=/usr –with-bz2=/usr –with-curl=/usr –enable-ftp –with-mysql=/usr/local/mysql –with-mysql-sock=/var/run/mysqld/mysql5.socket –with-mysqli=/usr/local/mysql/bin/mysql_config

这里报了一个错误

checking for X509_free in -lcrypto… yes
checking for pkg-config… /usr/bin/pkg-config
configure: error: Cannot find OpenSSL’s libraries

解决方法:
安装 opensslyum install openssl openssl-devel(如果没有安装的话)

建立软链接

ln -s /usr/lib64/libssl.so /usr/lib/

2、make && make install

3、测试 php 是否安装成功

[root@localhost www]# vi index.php
<?php
phpinfo();
?>

页面访问 http://127.0.0.1/index.php

基于 Linux 的 ownCloud 搭建

##############################################

第四部分 owncloud 的安装

1、下载并解压

[root@localhost softs]# tar xf owncloud-5.0.0.tar.bz2 -C /var/www/

[root@localhost conf]# chown -R daemon.daemon /var/www/

2、接下来页面访问 http://192.168.254.153/owncloud/index.php

基于 Linux 的 ownCloud 搭建

可以看到返回的错误就是 php 少了三个模块功能的扩展(zip,mb,GD)

3、所以接下来就要给 php 打三个补丁

首先我做个 gd 的扩展

[root@localhost gd]# pwd
/usr/src/php-5.3.27/ext/gd

[root@localhost gd]# yum install gd-devel ——–GD 的开发扩展包

[root@localhost gd]# ls
config.m4 CREDITS gdcache.c gd_ctx.c libgd tests
config.w32 gd.c gdcache.h gd.dsp php_gd.h

[root@localhost gd]# /usr/local/bin/phpize ## 生成 gd 模块
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

基于 Linux 的 ownCloud 搭建

通过对比,发现多了可以编译的参数,所以接下来进行编译安装

[root@localhost gd]# ./configure && make && make install 最后返回了下面两行

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files: /usr/local/include/php/

 

接下来修改 php 配置文件

[root@localhost gd]# cd modules/
[root@localhost modules]# ls
gd.so

生成一个 gd.so 的库文件,需要加到 php.ini 的扩展中, 然后需要在 /usr/local/lib/php.ini 文件中加下面两行

vi /usr/loca/lib/php.ini

extension_dir=”/usr/local/lib/php/extensions/no-debug-non-zts-20090626/”
extension=gd.so

重启 apache 服务即可

[root@localhost ~]# /etc/init.d/apache restart

基于 Linux 的 ownCloud 搭建

现在 gd 模块安装成功了,接下来只是简单介绍一下另外两个模块的扩展,首先是 zip 模块

[root@localhost zip]# cd /usr/src/php-5.3.27/ext/zip

[root@localhost zip]# /usr/local/bin/phpize

[root@localhost zip]# ./configure && make

[root@localhost zip]# make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
[root@localhost zip]# ls modules/
zip.so

[root@localhost zip]# vi /usr/local/lib/php.ini

增加一行 extension=zip.so

最后是 mb 模块的扩展

[root@localhost ~]# cd /usr/src/php-5.3.27/ext/mbstring/

[root@localhost mbstring]# /usr/local/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

[root@localhost mbstring]# ./configure && make && make install
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
Installing header files: /usr/local/include/php/

[root@localhost mbstring]# ls modules/
mbstring.so

[root@localhost mbstring]# vi /usr/local/lib/php.ini

在增加一行 extension=mbstring.so

这里总共增加了四行扩展

基于 Linux 的 ownCloud 搭建

重启 apache 服务,然后刷新页面

[root@localhost mbstring]# service apache restart

基于 Linux 的 ownCloud 搭建

4、从图中也可以看出,owncloud 报了新的错误

Security Warning

Your data directory and files are probably accessible from the internet because the .htaccess file does not work.
For information how to properly configure your server, please see the documentation.

解决这个问题,只需要在我建立的虚拟主机中增加

<VirtualHost *:80>
ServerAdmin owncloud@localhost
DocumentRoot “/var/www/owncloud”
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

ServerName test.owncloud.com
ErrorLog “/var/log/httpd/owncloud.error.log”
CustomLog “/var/log/httpd/owncloud-access_log” common
</VirtualHost>

然后重启 apache 服务

5、建立管理员账户,然后登陆

基于 Linux 的 ownCloud 搭建

注意:这里强烈建议使用 firefox 访问,我之前使用 360 访问,发现有问题,而且页面格式排版都有问题,但是日志不报错。

至此,owncloud 结束,如果本文中有任何错误请大家指正!

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计13576字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中