在 centos7 安裝私有云 owncloud
Step1. 在 centos 上安裝 Nginx
yum install epel-release -y
yum install nginx -y
systemctl enable nginx
//設置開機啓動- 打開
localhost
觀察 nginx 是否安裝成功
Step2. 安裝 Mysql (MariaDB)
yum install mariadb-server mariadb -y
systemctl start mariadb
//啓動MariaDBsystemctl enable mariadb
//設置開機啓動mysql_secure_installation
對 MariaDB 進行設置
Step3. 安裝 PHP V7.1
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm
yum install yum-utils -y
yum-config-manager --enable remi-php71
yum --enablerepo=remi,remi-php71 install php-fpm php-common
yum --enablerepo=remi,remi-php71 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml
//安裝PHP 拓展。若還有其他拓展可以另外執行安裝
STEP4. 配置 SSL(Https 證書)
sudo apt-get install git
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt/
sudo systemctl stop nginx
//停止 nginx./letsencrypt-auto certonly --standalone --email 你的郵箱地址 --agree-tos -d 你的域名
- 你的SSL證書會保存在/etc/letsencrypt/live/<你的域名>目錄下.
STEP5. 配置 Nginx
新建一個配置文件vi /etc/nginx/conf.d/owncloud.conf
server {
listen 80;
server_name vpn.biyongyao.com; #YourIP or domain
return 301 https://$server_name$request_uri; # redirect all to use ssl
}
server {
listen 443 ssl;
server_name biyongyao.com; #YourIP or domain
#SSL Certificate you created
ssl_certificate /etc/letsencrypt/live/vpn.biyongyao.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/vpn.biyongyao.com/privkey.pem;
# owncloud path
root /usr/share/nginx/html/owncloud/;
client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;
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 ~ ^/(data|config|\.ht|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)(/.*)?$ {
try_files $1 = 404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_param HTTPS on;
#fastcgi_pass php-handler;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# 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;
}
}
vi /etc/nginx/nginx.conf
在最後一個花括號前面增加一句include /etc/nginx/conf.d/*.conf
;