[Openwrt扩展下篇]Openwrt搭建私有云Owncloud9

[Openwrt扩展下篇]Openwrt搭建私有云Owncloud9

2023年7月3日发(作者:)

[Openwrt扩展下篇]Openwrt搭建私有云Owncloud9⽹上很多资料讲⽤Linux打造owncloud构建私有云 ,花了些时间研究了下,我将之前的需求打造成了Openwrt下的Owncloud 9。其实⽹上还有Seafile。⼤家对⽐来看下知乎的评论,其实主要是⾃⼰⽤不必要那么挑剔。软件版本:  Nginx 1.4.7

  PHP 5.6.17

  Sqlite3 ⾃带数据库 ,这⾥要说下openwrt下的mysql不能使⽤,版本5.1.X,⽽且Owncloud 7以上版本Mysql应该是⾄少要5.7.X,⽼外也没想管Mysql的版本,说了句没空~~~  不过对我来讲,我不熟悉就没有⽤,研究还的要时间的,不如弄个Linux了呢。

本着测试的想法,毕竟我想测试好aria2和Owncloud以后买个阿⾥云或者腾讯云,这样⼦配置会⾼很多带宽也会相对充裕些。上⼲货我们开始配置把,这⾥推荐⼤家看下这俩⽂档,是Openwrt添加Nginx,PHP,和Mysql的,当然Mysql不能⽤,Pass把基础环境搭建好了就到官⽹下载 就可以了,⼀切准备完后记得测试PHP+Nginx然后我们开始.............PHP配置root@Sean_OpenWrt:/etc/config# cat /etc/

[PHP]1_compatibility_mode = Off; Language Optionsengine = On;short_open_tag = Offprecision = 12y2k_compliance = Onoutput_buffering = Off;output_handler =_compression = Off;_compression_level = -1;_handler =implicit_flush = Offunserialize_callback_func =serialize_precision = 100;open_basedir =disable_functions =disable_classes =; Colors for Syntax Highlighting mode. Anything that's acceptable in; would work.; = #DD0000;t = #FF9900;d = #007700; = #FFFFFF;t = #0000BB; = #000000;ignore_user_abort = On;realpath_cache_size = 16k;realpath_cache_ttl = 120; Miscellaneousexpose_php = On; Resource Limitsmax_execution_time = 30 ; Maximum execution time of each script, in _input_time = 60 ; Maximum amount of time each script may spend parsing request data.;max_input_nesting_level = 64memory_limit = 8M ; Maximum amount of memory a script may consume.; Error handling and logging; Error Level Constants:; E_ALL - All errors and warnings (includes E_STRICT as of PHP 6.0.0); E_ERROR - fatal run-time errors; E_RECOVERABLE_ERROR - almost fatal run-time errors; E_WARNING - run-time warnings (non-fatal errors); E_PARSE - compile-time parse errors; E_NOTICE - run-time notices (these are warnings which often result; from a bug in your code, but it's possible that it was; intentional (e.g., using an uninitialized variable and; relying on the fact it's automatically initialized to an; empty string); E_STRICT - run-time notices, enable to have PHP suggest changes; to your code which will ensure the best interoperability; and forward compatibility of your code; E_CORE_ERROR - fatal errors that occur during PHP's initial startup; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's; initial startup; E_COMPILE_ERROR - fatal compile-time errors; E_COMPILE_WARNING - compile-time warnings (non-fatal errors); E_USER_ERROR - user-generated error message; E_USER_WARNING - user-generated warning message; E_USER_NOTICE - user-generated notice message; E_DEPRECATED - warn about code that will not work in future versions; of PHP; E_USER_DEPRECATED - user-generated deprecation warnings;; Common Values:; E_ALL & ~E_NOTICE (Show all errors, except for notices and coding standards warnings.); E_ALL & ~E_NOTICE | E_STRICT (Show all errors, except for notices); E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors); E_ALL | E_STRICT (Show all errors, warnings and notices including coding standards.); Default Value: E_ALL & ~E_NOTICEerror_reporting = E_ALL & ~E_NOTICE & ~E_STRICTdisplay_errors = Ondisplay_startup_errors = Offlog_errors = Offlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = On;report_zend_debug = 0track_errors = Off;html_errors = Off;docref_root = "/phpmanual/";docref_ext = .html;error_prepend_string = "";error_append_string = ""; Log errors to specified file.;error_log = /var/log/php_; Log errors to syslog.;error_log = syslog; Data Handling;arg_ = "&";arg_ = ";&"variables_order = "EGPCS"request_order = "GP"register_globals = Offregister_long_arrays = Offregister_argc_argv = Onauto_globals_jit = Onpost_max_size = 8M;magic_quotes_gpc = Offmagic_quotes_runtime = Offmagic_quotes_sybase = Offauto_prepend_file =auto_append_file =default_mimetype = "text/html";default_charset = "iso-8859-1";always_populate_raw_post_data = On; Paths and Directories; UNIX: "/path1:/path2";include_path = ".:/php/includes"user_dir =extension_dir = "/usr/lib/php"enable_dl = On;_redirect = 1; = 1;ct_status_env = ;_pathinfo=1;onate = 1;;g = 0;2616_headers = 0; File Uploadsfile_uploads = Onupload_tmp_dir = "/tmp"upload_max_filesize = 2Mmax_file_uploads = 20; Fopen wrappersallow_url_fopen = Onallow_url_include = Off;from="john@";user_agent="PHP"default_socket_timeout = 60;auto_detect_line_endings = Off; Dynamic Extensions;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=pdo_;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=;extension=; Module Settings[APC]d = _segments = 1 ;The number of shared memory segments to allocate for the compiler _size = 4M ;The size of each shared memory segment.[Date];ne = Asia/Chongqing;t_latitude = 31.7667;t_longitude = 35.2333;e_zenith = 90.583333;_zenith = 90.583333[filter];t = unsafe_raw;t_flags =[iconv];_encoding = ISO-8859-1;al_encoding = ISO-8859-1;_encoding = ISO-8859-1[sqlite];_case = 0[sqlite3];ion_dir =[Pdo_mysql]pdo__size = 2000pdo_t_socket=[MySQL]_local_infile = _persistent = _size = _persistent = -_links = -t_port =t_socket = /tmp/t_host =t_user =t_password =t_timeout = _mode = Off[PostgresSQL]_persistent = _reset_persistent = _persistent = -_links = -_notice = _notice = 0[Session]_handler = _path = "/tmp"_cookies = 1;_secure =_only_cookies = = _start = _lifetime = _path = /_domain =_httponly =ize_handler = _probability = _divisor = _maxlifetime = _compat_42 = _compat_warn = r_check =y_length = 0;y_file = /dev/y_file =;y_length = _limiter = _expire = _trans_sid = _function = _bits_per_character = 4url_ = "a=href,area=href,frame=src,input=src,form=,fieldset="[mbstring];ge = Japanese;al_encoding = EUC-JP;_input = auto;_output = SJIS;ng_translation = Off;_order = auto;tute_character = none;;_overload = 0;_detection = Off;_output_conv_mimetype=;_encoding=[gd];_ignore_warning = 0[exif];_unicode = ISO-8859-15;_unicode_motorola = UCS-2BE;_unicode_intel = UCS-2LE;_jis =;_jis_motorola = JIS;_jis_intel = JIS[soap]_cache_enabled=_cache_dir="/tmp"_cache_ttl=_cache_limit = 5[sysvshm];_mem = 10000[ldap]_links = -1[mcrypt];thms_dir=;_dir=[opcache];_consumption=8 ; 8M is the allowed minimum;ed_strings_buffer=_accelerated_files=200 ; 200 is the allowed minimum;date_freq=60;_shutdown=_cli==1;_verbosity_level=4View CodeNginx配置(官⽹推荐的Owncloud⽆SSL配置以及做的基本Nginx优化)root@Sean_OpenWrt:/etc/config# cat /etc/nginx/

user www www;worker_processes 1;error_log /mnt/sda2/nginx/logs/;#error_log /mnt/sda2/nginx/logs/ notice;#error_log /mnt/sda2/nginx/logs/ info;pid /mnt/sda2/nginx/logs/;events { worker_connections 10240;}http { include ; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /mnt/sda2/nginx/logs/ main; sendfile on;

keepalive_timeout 65; large_client_header_buffers 4 32k; client_max_body_size 8m; tcp_nopush on; tcp_nodelay off; client_body_timeout 10; client_header_timeout 10; output_buffers 1 32k; postpone_output 1460; open_file_cache max=1000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 32k; fastcgi_buffers 4 32k; fastcgi_busy_buffers_size 32k; fastcgi_temp_file_write_size 32k; gzip on; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_proxied expired no-cache no-store private auth; #proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=staticfilecache:80m inactive=1d max_size=2500m; proxy_temp_path /var/lib/nginx/proxy; proxy_connect_timeout 300; proxy_read_timeout 120; proxy_send_timeout 120; proxy_buffer_size 16k; proxy_buffers 4 16k;

server { listen 7777; server_name 66.66.66.60; access_log /mnt/sda2/nginx/logs/ main; root /mnt/sda2/nginx; index ; client_max_body_size 10G;

fastcgi_buffers 64 4K;

rewrite ^/caldav(.*)$ //caldav$1 redirect;

rewrite ^/carddav(.*)$ //carddav$1 redirect;

rewrite ^/webdav(.*)$ //webdav$1 redirect;

location = / { allow all; log_not_found off; access_log off; } location ~ ^/(?:.htaccess|data|config|db_|README){ deny all; } location / { rewrite ^/.well-known/host-meta /?service=host-meta last; rewrite ^/.well-known/ /?service=host-meta-json last; rewrite ^/.well-known/carddav //carddav/ redirect; rewrite ^/.well-known/caldav //caldav/ redirect; rewrite ^(/core/doc/[^]+/)$ $1/; try_files $uri $uri/ /; } location ~ .php(?:$|/) { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index ; fastcgi_param SCRIPT_FILENAME /mnt/sda2/nginx/$fastcgi_script_name; fastcgi_param PATH_INFO $1; include fastcgi_params; } location ~* .(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ { expires 30d; access_log off; } }}View Code因为万恶的Openwrt没有语⾔环境的所谓BUG, ⽹上的很多⼈要修改 ,可能⽐较⼩众资料不多,且多是爱好者在问答,⼤家可能没找到这个路径,其实5以上版本的路径换了,grep⼀下报错就可以找到。设置语⾔为 en_-8/fr_-8/es_-8/de_-8/ru_-8/pt_-8/it_-8/ja_-8/zh_-8 失败Please install one of these locales on your system and restart your webserver.相对路径为:注释掉这⾥

//if (!OC_Util::isSetLocaleWorking()) { // $errors[] = array( // 'error' => $l->t('Setting locale to %s failed', // array('en_-8/fr_-8/es_-8/de_-8/ru_-8/' // . 'pt_-8/it_-8/ja_-8/zh_-8')), // 'hint' => $l->t('Please install one of these locales on your system and restart your webserver.') // ); //配置Owncloud这⾥还应该改⼀下config/ 'ocx8is0pm6p9', 'default_language' => 'zh',);

数据库选择Sqlite,如果你是Linux 并且你的Mysql是5.7+的版本或者能⽤的MariaDB,,那么....我想说我好羡慕你... 因为装完后我就很郁闷了....因为这个数据库和系统本⾝的硬件不能撑起来,所以访问速度极其慢,我也没太关注就是搭建了个壳⼦,如果有⼤神知道如何优化请留⾔给我。系统资源占⽤:Load了36秒...⽽且由于注释了php代码出现了这个黄⾊的⼀⼤坨....表⽰强迫症不能忍,果断要换成VPS的...

虽然结果不是很理想,但是过程还是很开⼼的,毕竟⼀个路由也不能当服务器⽤....下⾯的参考资料⼤家可以找到各种版本的Owncloud,⽼外对Openwrt下的Mysql的态度....唉赶紧尝试⼀次⾼版本的Mysql吧.....⼤家有机会还是弄个vps吧....或者弄个⾼性能的....

总的来讲不建议⽤路由刷Openwrt上Owncloud,或者其他云Server,资源占⽤较⼤,也可能我配置的默认SQL问题或者还有哪⾥没有优化到,如有⼤神,请留⾔给我。VPS上效果展⽰,LNMP环境速度还算可以,然后我花了6RMB买了个官⽹客户端,感觉然并卵....可能还没仔细研究,抽空吧.....Python学习进度都落后了~~~~~~~~~~~~ 传送:

参考资料

发布者:admin,转转请注明出处:http://www.yc00.com/news/1688379509a129193.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信