
路由宝安装owncloud记录(一):
一、安装固件
为防路由宝性能不够,安装潘多拉7M版的固件(http://downloads.openwrt.org.cn/PandoraBox/YouKu_YK1/firmware/stable/PandoraBox-ralink-mt7620-yk1-squashfs-sysupgrade-r1024-20150608.bin)。本想安装原版openwrt(才3.5M,连uhttpd都没装,只能ssh连接),但是安装后发现只要一重启,lan口就会和wan口一样获得外部IP地址,搞的跟个交换机似的,试着改配置文件等方法尝试解决,最终能力有限,无法解决,随老老实实用潘多拉版吧。实际想用官方新版,主要是因为官方15.05软件库里有seafile服务版,能直接安装的话,就不用配置web那一堆东西了。
二、对tf卡进行必要的操作
1.ssh进路由器,先把tf卡格式化:
umount /dev/mmcblk0p1
umount /dev/mmcblk0p2
umount /dev/mmcblk0p3
umount /dev/mmcblk0p4
umount /dev/mmcblk0p5
umount /dev/mmcblk0p6
cfdisk /dev/mmcblk0 #这一步是图形操作,先把里面有的分区一个一个删除,再new创建一个未来存放软件的分区,大小6G多点吧,然后剩下大概1G左右空间作为swap分区,最后write保存退出
mkfs.ext3 /dev/mmcblk0p1 #把tf第一个分区格式化成 ext3格式 也可以格式化成其他格式ext2/4
mkswap /dev/mmcblk0p2 #对第二个分区进行swap格式化
注:如果提示找不到命令,需要安装一下相关软件
opkg update
opkg install fdisk e2fsprogs
2.打开web管理界面
进入“系统“---”挂载点”,把默认的几个挂载点删除,重启。
重启后添加挂载点,把tf卡第一个分区挂载上去,挂在到/mnt/tf;
在“SWAP”里面添加第二个分区作为swap,记得勾选“启用”。重启,看看首页“总览”里是否已经出现了交换区。或者ssh里面:
[root@PandoraBox:/root]#df
Filesystem Size Used Available Use% Mounted on
rootfs 24.6M 772.0K 23.8M 3% /
/dev/root 6.0M 6.0M 0 100% /rom
tmpfs 61.7M 332.0K 61.4M 1% /tmp
/dev/mtdblock7 24.6M 772.0K 23.8M 3% /overlay
overlayfs:/overlay 24.6M 772.0K 23.8M 3% /
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mmcblk0p1 6.1G 14.3M 5.8G 0% /mnt/tf
[root@PandoraBox:/root]#free
total used free shared buffers
Mem: 126392 44412 81980 0 5744
-/+ buffers: 38668 87724
Swap: 1150588 0 1150588
(抱歉,网站资源有限,外挂图库“贴图库”也开始收费后,害得我好多文章中的图片无法访问,故以后尽量不截图,纯文字记录)
3.软件安装到tf分区
参考自:
http://blog.csdn.net/jk110333/article/details/11920163
vi /etc/opkg.conf
dest root /
dest ram /tmp
dest tf /mnt/tf #添加此命令
lists_dir ext /var/opkg-lists
option overlay_root /overlay
src/gz r2_base http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/base
src/gz r2_management http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/manageme
src/gz r2_oldpackages http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/oldpack
src/gz r2_packages http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/packages
src/gz r2_routing http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/routing
src/gz r2_telephony http://downloads.openwrt.org.cn/PandoraBox/ralink/packages/telephony
vi /etc/profile #(主要的目的是设置环境变量,让系统能找到相关的文件
执行;设置两个环境变量,PATH和LD_LIBRARY_PATH,没有设置好PATH变量,运行安装在U盘的命令会提示找不到命令,而LD_LIBARY_PATH没设好就会提示xxlib.so没有找到。)
#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
export LD_LIBRARY_PATH="/mnt/tf/usr/lib:/mnt/tf/lib" #添加此环境变量
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/mnt/tf/usr/bin:/mnt/tf/usr/sbin #添加此环境变量
export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6)
export HOME=${HOME:-/root}
#export PS1='\u@\h:\w\$ '
export PS1='[\[\033[35;1m\]\u\[\033[0m\]@\[\033[31;1m\]\h\[\033\[0m\]:\[\033[32;1m\]$PWD
[ -x /bin/more ] || alias more=less
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; }
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
alias df='df -h'
alias free='free -m'
#alias ls='ls -hF --color=auto'
alias ll='ls -alh'
alias la='ll -A'
#alias top='top -d1'
执行#source /etc/profile
安装软件的时候添加选项-d tf
$opkg install XXX -d tf
然后直接执行相关的命令
三、开始安装相关平台软件
参考:http://wiki.openwrt.org/doc/howto/owncloud
1.安装lighttpd:
opkg install lighttpd lighttpd-mod-cgi lighttpd-mod-fastcgi lighttpd-mod-access -d tf
vi /mnt/tf/etc/lighttpd/lighttpd.conf
配置文件如下:
# lighttpd configuration file
#
## modules to load
# all other module should only be loaded if really neccesary
# - saves some time
# - saves memory
server.modules = (
# "mod_rewrite",
# "mod_redirect",
# "mod_alias",
# "mod_auth",
# "mod_status",
# "mod_setenv",
"mod_fastcgi",
# "mod_proxy",
# "mod_simple_vhost",
"mod_access",
"mod_cgi",
# "mod_ssi",
# "mod_usertrack",
# "mod_expire",
# "mod_webdav"
)
# force use of the "write" backend (closes: #2401)
server.network-backend = "write"
## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = "/mnt/tf/www/owncloud"
## where to send error-messages to
server.errorlog = "/mnt/tf/var/log/lighttpd/error.log"
## files to check for if .../ is requested
index-file.names = ("index.php", "index.html", "default.html", "index.htm", "default.htm" )
## mimetype mapping
mimetype.assign = (
".pdf" => "application/pdf",
".class" => "application/octet-stream",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".svg" => "image/svg+xml",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml"
)
## Use the "Content-Type" extended attribute to obtain mime type if possible
#mimetypes.use-xattr = "enable"
## send a different Server: header
## be nice and keep it at lighttpd
#server.tag = "lighttpd"
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
$HTTP["url"] =~ "^/data/" {
url.access-deny = ("")
}
$HTTP["url"] =~ "^($|/)" {
dir-listing.activate = "disable"
}
##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
######### Options that are good to be but not neccesary to be changed #######
## bind to port (default: 80)
server.port = 81
## bind to localhost (default: all interfaces)
#server.bind = "localhost"
## error-handler for status 404
#server.error-handler-404 = "/error-handler.html"
#server.error-handler-404 = "/error-handler.php"
## to help the rc.scripts
server.pid-file = "/var/run/lighttpd.pid"
###### virtual hosts
##
## If you want name-based virtual hosting add the next three settings and load
## mod_simple_vhost
##
## document-root =
## virtual-server-root + virtual-server-default-host + virtual-server-docroot or
## virtual-server-root + http-host + virtual-server-docroot
##
#simple-vhost.server-root = "/home/weigon/wwwroot/servers/"
#simple-vhost.default-host = "grisu.home.kneschke.de"
#simple-vhost.document-root = "/pages/"
##
## Format: <errorfile-prefix><status>.html
## -> ..../status-404.html for 'File not found'
#server.errorfile-prefix = "/www/error-"
## virtual directory listings
#server.dir-listing = "enable"
## send unhandled HTTP-header headers to error-log
#debug.dump-unknown-headers = "enable"
### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot = "/"
## change uid to <uid> (default: don't care)
#server.username = "nobody"
#
server.upload-dirs = ( "/tmp" )
## change uid to <uid> (default: don't care)
#server.groupname = "nobody"
#### compress module
#compress.cache-dir = "/dev/null/"
#compress.filetype = ("text/plain", "text/html")
#### proxy module
## read proxy.txt for more info
#proxy.server = (
# ".php" => (
# "localhost" => (
# "host" => "192.168.0.101",
# "port" => 80
# )
# )
#)
#### fastcgi module
## read fastcgi.txt for more info
fastcgi.server = (
".php" => (
"localhost" => (
"socket" => "/mnt/tf/tmp/php-fastcgi.socket",
"bin-path" => "/mnt/tf/usr/bin/php-fcgi"
)
)
)
#### CGI module
#cgi.assign = ( ".pl" => "/usr/bin/perl", ".cgi" => "/usr/bin/perl" )
#### SSL engine
#ssl.engine = "enable"
#ssl.pemfile = "server.pem"
#### status module
#status.status-url = "/server-status"
#status.config-url = "/server-config"
#### auth module
## read authentification.txt for more info
#auth.backend = "plain"
#auth.backend.plain.userfile = "lighttpd.user"
#auth.backend.plain.groupfile = "lighttpd.group"
#auth.require = (
# "/server-status" => (
# "method" => "digest",
# "realm" => "download archiv",
# "require" => "group=www|user=jan|host=192.168.2.10"
# ),
# "/server-info" => (
# "method" => "digest",
# "realm" => "download archiv",
# "require" => "group=www|user=jan|host=192.168.2.10"
# )
#)
#### url handling modules (rewrite, redirect, access)
#url.rewrite = ( "^/$" => "/server-status" )
#url.redirect = ( "^/wishlist/(.+)" => "http://www.123.org/$1" )
#### both rewrite/redirect support back reference to regex conditional using %n
#$HTTP["host"] =~ "^www\.(.*)" {
# url.redirect = ( "^/(.*)" => "http://%1/$1" )
#}
#### expire module
#expire.url = ( "/buggy/" => "access 2 hours", "/asdhas/" => "access plus 1 seconds 2 minutes")
#### ssi
#ssi.extension = ( ".shtml" )
#### setenv
#setenv.add-request-header = ( "TRAV_ENV" => "mysql://user@host/db" )
#setenv.add-response-header = ( "X-Secret-Message" => "42" )
#### variable usage:
## variable name without "." is auto prefixed by "var." and becomes "var.bar"
#bar = 1
#var.mystring = "foo"
## integer add
#bar += 1
## string concat, with integer cast as string, result: "www.foo1.com"
#server.name = "www." + mystring + var.bar + ".com"
## array merge
#index-file.names = (foo + ".php") + index-file.names
#index-file.names += (foo + ".php")
#### include
#include /etc/lighttpd/lighttpd-inc.conf
## same as above if you run: "lighttpd -f /etc/lighttpd/lighttpd.conf"
#include "lighttpd-inc.conf"
#### include_shell
#include_shell "echo var.a=1"
## the above is same as:
#var.a=1
#### webdav
#$HTTP["url"] =~ "^/webdav($|/)" {
# webdav.activate = "enable"
# webdav.is-readonly = "enable"
# webdav.sqlite-db-name = "/var/run/lighttpd-webdav-lock.db"
#}
还要更改启动文件配置:
vi /mnt/tf/etc/init.d/lighttpd
配置如下:
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2011 OpenWrt.org
SERVICE_USE_PID=1
START=50
start() {
[ -d /mnt/tf/var/log/lighttpd ] || mkdir -p /mnt/tf/var/log/lighttpd
chmod 0777 /mnt/tf/var/log/lighttpd
service_start /mnt/tf/usr/sbin/lighttpd -f /mnt/tf/etc/lighttpd/lighttpd.conf
}
stop() {
service_stop /mnt/tf/usr/sbin/lighttpd
}
#/mnt/tf/etc/init.d/lighttpd start #启动lighttpd
报错:
2016-10-30 00:01:13: (plugin.c.169) dlopen() failed for: /usr/lib/lighttpd/mod_indexfile.so File not found
2016-10-30 00:01:13: (server.c.679) loading plugins finally failed
搞的我莫名其妙的,环境变量也设了啊,怎么还会这样,处理半天无法解决,只得做个软连接解决:
#ln -s /mnt/tf/usr/lib/lighttpd /usr/lib/lighttpd
# netstat -antl | grep LIST #查看81端口是否已被监听
2.安装php
opkg install php5 php5-cgi php5-fastcgi php5-mod-json php5-mod-session php5-mod-zip libsqlite3 zoneinfo-core php5-mod-pdo php5-mod-pdo-sqlite php5-mod-ctype php5-mod-mbstring php5-mod-gd sqlite3-cli php5-mod-sqlite3 php5-mod-curl curl php5-mod-xml php5-mod-simplexml php5-mod-hash php5-mod-dom php5-mod-iconv -d tf
opkg install php5-mod-mcrypt php5-mod-openssl php5-mod-fileinfo php5-mod-exif -d tf
修改php.ini
short_open_tag = on
doc_root = "/mnt/www" (网站的根目录,可根据自己的情况改写,但要与lighttpd的配置相同)
extension=ctype.so
extension=curl.so
extension=gd.so
extension=mbstring.so
extension=mcrypt.so
extension=mysql.so
extension=pdo.so
extension=pdo_mysql.so
extension=session.so
extension=sockets.so
extension=tokenizer.so
extension=xml.so
[Date]
date.timezone = Asia/Shanghai (如果不改的话,有些程序会提示不安全或其他错误)
更改启动文件:
vi /mnt/tf/etc/init.d/php5-fastcgi
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
start_instance() {
local section="$1"
local enabled
local port
config_get_bool enabled "$section" 'enabled' 0
config_get port "$section" 'port' 1026
[ $enabled -gt 0 ] || return 1
PHP_FCGI_CHILDREN='' \
service_start /mnt/tf/usr/bin/php-fcgi -b $port
}
start() {
config_load 'php5-fastcgi'
config_foreach start_instance 'php5-fastcgi'
}
stop() {
service_stop /mnt/tf/usr/bin/php-fcgi
}
启动php,
#/mnt/tf/etc/init.d/php5-fastcgi enable
#/mnt/tf/etc/init.d/php5-fastcgi start
3.安装MYSQL
#opkg install mysql-server libncursesw libncurses libreadline terminfo uclibcxx zlib libmysqlclient libmcrypt libltdl libmcrypt -d tf
建立如下文件夹
#mkdir /mnt/tf/data /mnt/tf/data/mysql /mnt/tf/data/tmp
输入如下命令创建默认的数据库:
#/mnt/tf/usr/bin/mysql_install_db --force
报错:
FATAL ERROR: Could not find /usr/bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
于是:
vi /mnt/tf/usr/bin/mysql_install_db
basedir="/mnt/tf/usr"
builddir="/mnt/tf/data"
ldata="/mnt/tf/data/mysql"
langdir=""
srcdir=""
再次创建默认数据库,成功
启动数据库:
#/mnt/tf/etc/init.d/mysqld start
三、
为防性能不足,根据网上教程说法,安装4.5.13版本
下载地址:
http://download.owncloud.org/community/4/owncloud-4.5.13.tar.bz2
http://download.owncloud.org/community/5/owncloud-5.0.19.tar.bz2
#cd /mnt/tf/tmp
#wget http://download.owncloud.org/community/4/owncloud-4.5.13.tar.bz2
#opkg update
#opkg install tar
#cd /mnt/tf/www
#tar -xjf /mnt/tf/tmp/owncloud-4.5.13.tar.bz2
chown -R root:root /mnt/tf/www/owncloud
cd /mnt/tf
mkdir owncloud
chown -R root:root /mnt/tf/owncloud
chmod 770 -R /mnt/tf/owncloud
cd owncloud
mkdir data
chmod 770 -R /mnt/tf/owncloud/data
未完待续



本文地址:https://www.xxnet.eu.org/?post=220
版权声明:若无注明,本文皆为“点滴记忆---观雨亭”原创,转载请保留文章出处。

