搭建私有云盘owncloud
一、 环境说明操作系统:centos-6.5 64位,最小化安装运行owncloud需要搭建web服务器,这里采用源码编译LAMP方式搭建软件包版本:apr-1.5.2.tar.gz httpd依赖包apr-util-1.5.4.tar.bz2 httpd依赖包pcre-8.37.tar.b
一、 环境说明
操作系统:centos-6.5 64位,最小化安装
运行owncloud需要搭建web服务器,这里采用源码编译LAMP方式搭建
软件包版本:
apr-1.5.2.tar.gz httpd依赖包
apr-util-1.5.4.tar.bz2 httpd依赖包
pcre-8.37.tar.bz2 httpd依赖包
httpd-2.4.16.tar.bz2 httpd主程序包
php-5.6.13.tar.bz2 php主程序包
mysql-5.6.35.tar.gz mysql主程序包
owncloud-10.0.2.tar.bz owncloud源码包
二、 安装LAMP环境
因为是最小化安装,所以,在编译安装之前,先安装开发包
这里采用yum方式安装,配置阿里云的网络yum源(配置过程详见http://mirrors.aliyun.com/help/centos)
1、安装开发包
[root@owncloud ~]# yum groupinstall"Development Tools" "Development Libraries" -y
2、安装依赖包
安装apr、apr-util依赖,编译安装
[root@owncloud ~]# cd /home/
[root@owncloud home]# ls
apr-1.5.2.tar.gz httpd-2.4.16.tar.bz2 pcre-8.37.tar.bz2
apr-util-1.5.4.tar.bz2 mysql-5.6.35.tar.gz php-5.6.13.tar.bz2
解压
[root@owncloud home]# tar xf apr-1.5.2.tar.gz-C /usr/local/src/
[root@owncloud home]# tar xfapr-util-1.5.4.tar.bz2 -C /usr/local/src/
安装apr
[root@owncloud home]# cd /usr/local/src/apr-1.5.2/
[root@owncloud apr-1.5.2]# ./configure--prefix=/usr/local/apr && make && make install
安装apr-util
[root@owncloud apr-util-1.5.4]# ./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make&& make install
安装pcre
[root@owncloud apr-util-1.5.4]# cd /home/
[root@owncloud home]# tar xfpcre-8.37.tar.bz2 -C /usr/local/src/
[root@owncloud home]# cd/usr/local/src/pcre-8.37/
[root@owncloud pcre-8.37]# ./configure--prefix=/usr/local/pcre && make && make install
3、安装httpd
Httpd依赖包已经安装完毕,现在开始编译安装httpd
[root@owncloud pcre-8.37]# cd /home/
[root@owncloud home]# tar xfhttpd-2.4.16.tar.bz2 -C /usr/local/src/
[root@owncloud home]# cd/usr/local/src/httpd-2.4.16/
[root@owncloud httpd-2.4.16]# ./configure --prefix=/usr/local/apache2.4--enable-so --enable-rewrite --enable-ssl --with-pcre=/usr/local/pcre--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util--enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@owncloud httpd-2.4.16]# make -j 4&& make install
配置httpd启动脚本
[root@owncloud httpd-2.4.16]# cp/usr/local/apache2.4/bin/apachectl /etc/init.d/apache2.4
编辑启动脚本
[root@owncloud httpd-2.4.16]# vim/etc/init.d/apache2.4
#chkconfig: 2345 64 36
#description: Apache2.4.16 start script
在开始位置添加以上两行
启动服务
[root@owncloud httpd-2.4.16]#/etc/init.d/apache2.4 start
添加开机自启动
[root@owncloud httpd-2.4.16]# chkconfigapache2.4 on
查看
[root@owncloud ~]# ps -aux | grep apache
Warning:bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 74577 0.0 0.2 72700 2200 ? Ss 16:43 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 74578 0.0 0.4 416960 4096 ? Sl 16:43 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 74579 0.0 0.4 416960 4100 ? Sl 16:43 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 74580 0.0 0.4 416960 4104 ? Sl 16:43 0:00 /usr/local/apache2.4/bin/httpd -k start
root 74664 0.0 0.0 103252 824 pts/0 S+ 16:44 0:00 grep apache
可以看到编译安装的用户是daemon,需要添加一个用户来运行apache
添加用户
[root@owncloud ~]# useradd -M -s/sbin/nologin apache
编辑apache配置文件
[root@owncloud ~]# vim/usr/local/apache2.4/conf/httpd.conf
改:
Userdaemon
Groupdaemon
为:
User apache
Group apache
更改目录权限
[root@owncloud ~]# chown -R apache.apache/usr/local/apache2.4/
重启服务
[root@owncloud ~]# /etc/init.d/apache2.4restart
测试
Apache安装成功
4、编译安装mysql
安装编译工具cmake和依赖
[root@owncloud ~]# yum install -y cmakencurses-devel
解压
[root@owncloud ~]# cd /home/
[root@owncloud home]# tar xfmysql-5.6.35.tar.gz -C /usr/local/src/
[root@owncloud home]# cd/usr/local/src/mysql-5.6.35/
创建mysql用户
[root@owncloud mysql-5.6.35]# useradd -M -s/sbin/nologin mysql
创建数据存放目录
[root@owncloud mysql-5.6.35]# mkdir -p/data/mydb
编译安装
[root@owncloud mysql-5.6.35]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mydb \
-DMYSQL-USER=mysql
[root@owncloud mysql-5.6.35]# make -j 4&& make install
配置mysql
[root@owncloud mysql-5.6.35] chown -Rmysql:mysql /usr/local/mysql/
[root@owncloud mysql-5.6.35] cp/usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@owncloud mysql-5.6.35] cp/usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@owncloud mysql-5.6.35] vim /etc/init.d/mysqld
basedir=
datadir=
#修改为
basedir=/usr/local/mysql
datadir=/data/mydb
设置开机自启
[root@owncloud ~]# chkconfig mysqld on
配置环境变量
[root@owncloud ~]# echo"PATH=/usr/local/mysql/bin:$PATH" >>/etc/profile
[root@owncloud ~]# source /etc/profile
初始化数据库
[root@owncloud ~]#/usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf--basedir=/usr/local/mysql/ --datadir=/data/mydb/ --user=mysql
启动数据库
[root@owncloud ~]# /etc/init.d/mysqld start
StartingMySQL.Logging to '/data/mydb/owncloud.err'.
.SUCCESS!
安全初始设置
[root@owncloud ~]# mysql_secure_installation
测试登陆
[root@owncloud ~]# mysql -uroot -p
Enter password:
Welcometo the MySQL monitor. Commands end with; or \g.
YourMySQL connection id is 12
Serverversion: 5.6.35 Source distribution
Copyright(c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracleis a registered trademark of Oracle Corporation and/or its
affiliates.Other names may be trademarks of their respective
owners.
Type'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
到此mysql编译安装完成
5、编译安装php
安装依赖
[root@owncloud ~]# yum install -ylibxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype freetype-devel
[root@owncloud home]# tar xflibmcrypt-2.5.8.tar.bz2 -C /usr/local/src/
[root@owncloud home]# cd/usr/local/src/libmcrypt-2.5.8/
[root@owncloud libmcrypt-2.5.8]# ./configure--prefix=/usr/local/libmcrypt ; make ; make install ; cd
[root@owncloud ~]# vim /etc/ld.so.conf
添加两行
/usr/local/libmcrypt/lib
/usr/local/mysql/lib
解压
[root@owncloud ~]# cd /home/
[root@owncloud home]# tar xfphp-5.6.13.tar.bz2 -C /usr/local/src/
[root@owncloud home]# cd/usr/local/src/php-5.6.13/
编译安装
[root@owncloud php-5.6.13]# ./configure--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2.4/bin/apxs \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr\
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-gettext \
--enable-opcache=no
[root@owncloud php-5.6.13]#make -j 4&& make install
复制配置文件
[root@owncloud php-5.6.13]# cpphp.ini-production /usr/local/php/php.ini
配置Apache支持PHP
root@owncloud ~]# vim/usr/local/apache2.4/conf/httpd.conf
251<IfModule dir_module>
252 DirectoryIndex index.html index.php
253</IfModule>
……
381 AddType application/x-httpd-php .php
382 AddTypeapplication/x-httpd-php-source .phps
重启apache服务
[root@owncloud ~]# /etc/init.d/apache2.4restart
测试
[root@owncloud ~]# vim/usr/local/apache2.4/htdocs/index.php
Php编译安装完成,下一步开始部署owncloud
三、部署owncloud
创建数据库
[root@owncloud ~]# mysql -uroot -p123456
mysql> create database if not exists owncloud;
Query OK, 1 rowaffected (0.16 sec)
授权用户
mysql> grant all privileges on owncloud.*to 'owncloud'@'localhost' identified by '123456';
Query OK, 0 rowsaffected (0.18 sec)
刷新授权表
mysql> flush privileges;
Query OK, 0 rowsaffected (0.10 sec)
修改my.cnf配置,添加以下4行
[mysqld]
binlog_format = row
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
重启mysql
[root@owncloud ~]# /etc/init.d/mysqld restart
Shuttingdown MySQL.. SUCCESS!
StartingMySQL.. SUCCESS!
解压owncloud源码到/usr/local/apache2.4/htdocs/
[root@owncloud home]# tar xfowncloud-10.0.2.tar.bz2 -C /usr/local/apache2.4/htdocs/
[root@owncloud home]# chown apache.apache/usr/local/apache2.4/htdocs/ -R
安装完成后,就可以登录了
登录后的页面是这样的
到此,所有配置完成
欢迎交流学习!!
更多推荐
所有评论(0)