基於Linux的owncloud搭建

爲了保證一個純淨的環境,我從新安裝了一臺centos系統php

[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
html

在安裝玩系統以後,首先須要搭建yum源,centos的網絡yum源是很是簡單的,甚至不須要你修改任何配置,只要安裝一個小軟件, rpm -ivh epel-release-6-5.noarch.rpmmysql

而後yum就可使用了c++


第一部分 apache的安裝sql

因爲在編譯apache的時候,須要用到一些插件,因此咱們須要提早安裝apache

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

apache的編譯安裝很簡單,可是咱們須要安裝一些包便於apache功能的擴展
瀏覽器

一、apr-1.4.6.tar.gz 的安裝網絡

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

[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 

二、libiconv-1.13.tar.gz的安裝

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

三、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

四、安裝openssl nss-devel

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

五、安裝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

六、安裝兩個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%]


七、安裝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 

八、安裝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

九、修改apache配置文件

[root@localhost ~]# vi /usr/local/apache2/conf/httpd.conf  指定DocumentRoot和容許訪問



將  第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!

十、開啓虛擬主機
[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)

一、新建用戶及相關目錄,並修改相關的屬主和屬組。

useradd  mysql

mkdir  /var/log/mysqld

mkdir /var/run/mysqld

mkdir /database

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


 

二、下載軟件並解壓編譯安裝

下載地址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/



三、這裏須要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



四、經過對比能夠看出,在cmake先後的差別仍是蠻大的,接下來make

[root@localhost mysql-5.6.10]# make


五、make這一步比較慢,須要多等一下,下一步就是make install 


make install 完成後,接下來就是對mysql進行配置

六、對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表示成功

七、修改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的安裝

 

一、下載軟件並安裝

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/

二、make && make install 

三、測試php是否安裝成功

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

頁面訪問http://127.0.0.1/index.php


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

第四部分  owncloud的安裝

一、下載並解壓

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

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

二、接下來頁面訪問http://192.168.254.153/owncloud/index.php


能夠看到返回的錯誤就是php少了三個模塊功能的擴展(zip,mb,GD)

三、因此接下來就要給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


經過對比,發現多了能夠編譯的參數,因此接下來進行編譯安裝

[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


如今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

這裏總共增長了四行擴展


重啓apache服務,而後刷新頁面

[root@localhost mbstring]# service apache restart


四、從圖中也能夠看出,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服務

五、創建管理員帳戶,而後登錄


注意:這裏強烈建議使用firefox訪問,我以前使用360訪問,發現有問題,並且頁面格式排版都有問題,可是日誌不報錯。

至此,owncloud結束,若是本文中有任何錯誤請你們指正!

相關文章
相關標籤/搜索