平台:Centos 6.5 x86_64最小化安装
1,安装源
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -Uvh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum update -y
2,安装nginx
yum -y install nginx
3,安装mysql
yum --enablerepo=remi -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel
yum --enablerepo=remi -y install mysql mysql-server mysql-devel
service mysqld start
mysql_secure_installation
mysql -u root -p
CREATE DATABASE owncloud;
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'hello';
GRANT ALL ON owncloud.* TO admin@localhost IDENTIFIED BY 'hello';
FLUSH PRIVILEGES;
EXIT
4,安装php
yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-fpm php56w-dom
或者
yum --enablerepo=remi install -y php php-fpm php-mysql php-common php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-dom php-xmlwriter php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel redis php-pecl-redis
设置上传单个文件最大值
sed -i 's/post_max_size = 8M/post_max_size = 5G/g' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 5G/g' /etc/php.ini
sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf
vi /etc/php-fpm.d/www.conf
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp
将以上几行前的;去掉并保存
chown -R root:nginx /var/lib/php/session
service php-fpm start
5,部署owncloud
wget https://download.owncloud.org/community/owncloud-8.2.2.tar.bz2
tar jxvf owncloud-8.2.2.tar.bz2 -C /usr/share/nginx/html
chown -R nginx:nginx /usr/share/nginx/html/owncloud/
mkdir -p /usr/share/nginx/html/owncloud/data
chown -R nginx:nginx /usr/share/nginx/html/owncloud/data
6,cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bk
vi /etc/nginx/conf.d/default.conf 用以下内容替换原内容
upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name localhost;
# Path to the root of your installation
root /usr/share/nginx/html/owncloud/;
# set max upload size
client_max_body_size 10G;
fastcgi_buffers 64 4K;
# Disable gzip to avoid the removal of the ETag header
gzip off;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
deny all;
}
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ /index.php;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass php-handler;
}
# Optional: set long EXPIRES header on static assets
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
}
使用redis做本地缓存
vi /usr/share/nginx/html/owncloud/config/config.php
添加
'redis' => array(
'host' => 'localhost',
'port' => 6379,
'timeout' => 0.0,
),
service redis start
7,测试
浏览器输入http://yourserverip
admin (自定义用户名)
password (自定义密码)
MYSQL (选择mysql)
admin (之前建立的数据库账号)
hello
owncloud
localhost
安装后进入网盘,enjoy it!这里没能用https,还是建议加上ssl比较安全。