CentOS7搭建Kodexplorer文件资源管理器

来源:互联网 发布:linux arp防火墙关闭 编辑:程序博客网 时间:2024/06/15 21:38
1.概要
web文件资源管理器,使用体验类似 云盘。服务部署,需要自己搭建web服务器。
然后配置web服务,最后部署kodexplorer代码即可。

2. 部署
2.1 部署nginx 在附录部分有说明
2.2 部署php 在附录部分有说明
2.3 部署Kodexplorer,附录部分有说明

3.web文件资源管理密码和使用说明
默认加入了三个用户(分别对应不同的用户组)
管理员:  admin/admin
普通用户:demo/demo
游客用户:guest/guest

[如何使用] 下载程序,解压上传到你的服务器路径下,data目录设置777权限。访问体验超便捷的服务吧!
(为确保数据安全,最好配置服务器不允许列目录)
[关于上传问题] 程序没有做任何限制,如果需要上传大文件,则修改
  php.ini:
  max_execution_time = 6000
  max_input_time = 6000
  memory_limit = 1024M
  post_max_size = 1024M
  upload_max_filesize = 1024M
  注意不能大于2g,可能否则导致php无法正常运行(不支持post)。
[关于解压缩问题] 程序不做任何限制,如若失败请设置php内存限制。memory_limit  1024M
[关于解压缩乱码] linux服务器压缩,下载到windows下中文会乱码。是由于系统导致的。所以尽量不要跨系统操作。
[关于"系统错误"] 请配置php错误提示级别error_reporting; 配置php.ini或者允许error_reporting函数
[关于兼容性] 建议使用chrome firefox ie9+  体验更完整。ie8以下基本上不做兼容处理。chrome支持文件夹拖拽上传。
[文件打开] office文件在线预览功能,服务器必须在公网(外部能访问该服务器);
    内部或局域网需要使用请参考qq群共享“web office搭建”,然后配置kod程序config/config.php OFFICE_SERVER
[安全提示] 为确保数据安全,请设置http服务器不允许列目录。
[忘记密码] 修改data/system/member.php 密码为明文的md5值 例如将admin密码重设为admin
    则修改第一行:"name":"admin","password":"21232f297a57a5a743894a0e4a801fc3"

【文件拖拽上传】除了ie8以下的大部分浏览器支持;建议使用chrome、360、猎豹、uc等

【文件夹拖拽上传】除了ie10以下、firefox大部分浏览器都支持,建议使用chrome、360、猎豹、uc等


附录

部署nginx

部署方法参考:http://blog.csdn.net/wangkai_123456/article/details/70877569

Nginx编译安装过程优化:

1、编译安装过程优化
在编译Nginx时,默认以debug模式进行,而在debug模式下会插入很多跟踪和ASSERT之类的信息,编译完成后,一个Nginx要有好几兆字节。在编译前取消Nginx的debug模式,编译完成后Nginx只有几百千字节,因此可以在编译之前,修改相关源码,取消debug模式,具体方法如下: 在Nginx源码文件被解压后,找到源码目录下的auto/cc/gcc文件,在其中找到如下几行:

# debug
CFLAGS=”$CFLAGS -g”

注释掉或删除

2、为特定的CPU指定CPU类型编译优化.
默认nginx使用的GCC编译参数是-O
需要更加优化可以使用以下两个参数
--with-cc-opt='-O3' \
--with-cpu-opt=opteron \
使得编译针对特定CPU以及增加GCC的优化.
此方法仅对性能有所改善并不会有很大的性能提升,供朋友们参考.
CPUD类型确定: # cat /proc/cpuinfo | grep "model name"

其它优化可参考:
https://www.cnblogs.com/suihui/p/3799683.html


nginx配置文件:

#user  nobody;worker_processes  2;error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;pid        logs/nginx.pid;events {    use epoll;    worker_connections  1024;}http {    include       mime.types;    default_type  application/octet-stream;    client_max_body_size 1024M;    client_header_timeout 30;    client_body_timeout 30;        #proxy_connect_timeout 600;    #proxy_read_timeout 6000;    #proxy_send_timeout 6000;    #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  logs/access.log  main;    sendfile        on;    tcp_nopush      on;    tcp_nodelay     on;    #keepalive_timeout  0;    keepalive_timeout  60;    keepalive_requests 1024;    #gzip  on;    server {        listen       80;        server_name  10.62.32.112;charset utf-8;        #access_log  logs/host.access.log  main;root   html;        index  index.php index.html;        location / {            # Check if a file or directory index file exists, else route it to index.php;            try_files $uri $uri/ /index.php;        }        #error_page  404              /404.html;        # redirect server error pages to the static page /50x.html        #        error_page   500 502 503 504  /50x.html;        location = /50x.html {            root   html;        }        # proxy the PHP scripts to Apache listening on 127.0.0.1:80        #        #location ~ \.php$ {        #    proxy_pass   http://127.0.0.1;        #}        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000        #        location ~ \.php$ {            #root           html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;    fastcgi_connect_timeout 300;    fastcgi_send_timeout 300;    fastcgi_read_timeout 300;        }        # deny access to .htaccess files, if Apache's document root        # concurs with nginx's one        #        #location ~ /\.ht {        #    deny  all;        #}    }    # another virtual host using mix of IP-, name-, and port-based configuration    #    #server {    #    listen       8000;    #    listen       somename:8080;    #    server_name  somename  alias  another.alias;    #    location / {    #        root   html;    #        index  index.html index.htm;    #    }    #}    # HTTPS server    #    #server {    #    listen       443 ssl;    #    server_name  localhost;    #    ssl_certificate      cert.pem;    #    ssl_certificate_key  cert.key;    #    ssl_session_cache    shared:SSL:1m;    #    ssl_session_timeout  5m;    #    ssl_ciphers  HIGH:!aNULL:!MD5;    #    ssl_prefer_server_ciphers  on;    #    location / {    #        root   html;    #        index  index.html index.htm;    #    }    #}}

部署php:可参考:http://blog.csdn.net/wangkai_123456/article/details/71082491

PHP源码安装前准备

Kodexplorer需要PHP支持curl和GD,而GD依赖jpeg,所以需要先安装curl、jpeg
curl下载:http://curl.haxx.se/download.html
具体安装过程:
tar zxvf curl-7.56.1.tar.gz
cd curl-7.56.1 
./configure --prefix=/usr/local/curl

jpeg下载:http://www.ijg.org/
具体安装过程:
tar zxvf jpegsrc.v9b.tar.gz
cd jpeg-9b 
./configure --prefix=/usr/local/jpeg

PHP源码安装流程
1.下载源码
http://cn.php.net/downloads.php

2.进入源码包所在路径下,解压安装包到/usr/local/src
$tar  -xzvf php-7.1.4.tar.gz

3.进入解压的php文件夹下/usr/local/src/php-7.1.4
安装依赖(视实际需要而定)
$yum install  libxml2  libxml2-devel gd php-gd gd-devel

配置安装
#--without-pear  --disable-phar
$./configure --prefix=/usr/local/php  --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64 --without-pear  --disable-phar  --with-gd --with-curl=/usr/local/curl --with-jpeg-dir=/usr/local/jpeg (应该一般不需要--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd)

./configure --prefix=/usr/local/php \ #指定安装目录
--with-config-file-path=/usr/local/php/etc \ #指定配置文件的目录,默认在php/lib下满\
--enable-fpm \启用php的fpm
--enable-mbstring  \ 启用多字节字符串支持
--with-libdir=lib64 \
--without-pear \禁用pear扩展 
--disable-phar \ 禁用pear扩展的phar函数库
--with-gd \启动GD
--with-curl=/usr/local/curl \启动curl
--with-jpeg-dir=/usr/local/jpeg \支持JPEG格式图片,GD开启后需要安装JPEG
--enable-mysqlnd \ 启用php的mysql驱动 
--with-mysqli=mysqlnd \ 指定mysql
--with-pdo-mysql=mysqlnd \指定mysql


####################################################################################
网络上的示例配置参数
'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' \
'--with-fpm-user=www' '--with-fpm-group=www' '--enable-fpm' '--enable-opcache' \
'--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' \
'--disable-fileinfo' '--with-iconv-dir=/usr/local' '--with-freetype-dir' '--with-jpeg-dir' \
'--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' \
'--enable-bcmath' '--enable-shmop' '--enable-exif' '--enable-sysvsem' '--enable-inline-optimization' \
'--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--with-gd' \
'--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' \
'--with-xmlrpc' '--enable-ftp' '--with-gettext' '--enable-zip' '--enable-soap' '--disable-ipv6' \
'--disable-debug'
##########################################################################################

$make

$make install

#安装完成后的摘要信息
summary:
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM config:        /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing phpdbg binary:         /usr/local/php/bin/
Installing phpdbg man page:       /usr/local/php/php/man/man1/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:           /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1

  
4.修改配置文件
#Php的配置文件为 php.ini
$cp /usr/local/src/php-7.1.4/php.ini-production   /usr/local/php/lib/php.ini

#下面使得另一种方法来管理服务,usage:./php-fpm {start|stop|force-quit|restart|reload|status|configtest}。
$cp /usr/local/src/php-7.1.4/sapi/fpm/init.d.php-fpm    /etc/init.d/php-fpm
$chmod +x /etc/init.d/php-fpm   #添加执行权限

#php-fpm的配置文件
$cp /usr/local/php/etc/php-fpm.conf.default   /usr/local/php/etc/php-fpm.conf
$cp /usr/local/php/etc/php-fpm.d/www.conf.default   /usr/local/php/etc/php-fpm.d/www.conf
记得根据机器配置修改php-fpm进程数最大限制,这限制在/usr/local/php/etc/php-fpm.d/www.conf里面
使用 netstat -napo |grep "php-fpm" | wc -l 查看一下当前fastcgi进程个数,如果个数接近conf里配置的上限,就需要调高进程数。
但也不能无休止调高,可以根据服务器内存情况,可以把php-fpm子进程数调到100或以上,在4G内存的服务器上200就可以。
pm.max_children = 200

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3

5.将/usr/local/php/bin目录添加至PATH环境变量
vim /etc/profile

在profile最后中添加
export PATH=/usr/local/php/bin:$PATH

使添加的环境变量立即生效
source /etc/profile

6.启动php测试
6.1 启动
$/etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status|configtest}

6.2 测试php
$cd /usr/local/nginx/html
$vim test.php

添加如下内容:
<?php  
 echo phpinfo();  
?> 

浏览器输入:http://10.62.32.112/test.php

如果出现:PHP Version 7.1.4 界面,显示php详细的配置的界面,说明安装正确

部署Kodexplorer
:下载、解压到nginx/html/目录下即可

一、出于 程序安全 和 服务器本身的磁盘挂载情况,需要将kodexplorer的数据目录移到web目录之外,这样也就不用限制用户的扩展名权限了,方法如下:
1、将data文件夹移到指定目录(例如:/data/KodServer/目录)
2、在config文件夹下新建define.php 新增一行 <?php define('DATA_PATH','/data/KodServer/data/');
3、修改define.php文件的权限,命令如下:
chmod 777 define.php

二、登录kodexplorer后,新建文件、解压文件默认权限为755,这样会导致通过ftp客户端无法上传文件到kodexplorer用户的home目录,解决办法如下:
修改config文件夹下config.php文件:
cd /usr/local/nginx/html/config/
vi config.php

修改
define('DEFAULT_PERRMISSIONS',0755);  //新建文件、解压文件默认权限,777 部分虚拟主机限制了777

define('DEFAULT_PERRMISSIONS',0777);  //新建文件、解压文件默认权限修改为777