Manually upgrade owncloud from 8.0.16 to 9.1.4

จาก Wiki Opensource

ปรับปรุงครั้งล่าสุดวันที่ 2-03-2560
เขียนโดย วิบูลย์

References:
https://owncloud.org/changelog/#latest9.1
https://doc.owncloud.org/server/8.1/admin_manual/maintenance/manual_upgrade.html


Manually upgrade owncloud from 8.0.16 to 9.1.4

/////If use cron.php, then stop cron.
vi /etc/cron.d/owncloud-cron-dot-php
#*/15  *  *  *  * www-data php -f /var/www/html/owncloud/cron.php

#Working directory
cd /var/www/html

/////Round 1 upgrade from 8.0.16 to 8.1.12

rsync -Aax owncloud/ owncloud-dirbkp_`date +"%Y%m%d"`/
mysqldump --lock-tables -u root -p dbname > owncloud-sqlbkp_`date +"%Y%m%d"`.bak

sudo -u www-data php owncloud/occ maintenance:mode --on

mkdir tmp
cd tmp
wget https://download.owncloud.org/community/owncloud-8.1.12.tar.bz2
tar xjf ../owncloud-8.1.12.tar.bz2 
service apache2 stop
cd ..
mv owncloud/ owncloud80
mv tmp/owncloud/ .
cp owncloud80/config/config.php owncloud/config/
cd owncloud
REM Because our owncloud data is soft link to /srv/data so I need to make a soft link
ln -s /srv/data/ data
service apache2 start
cd ..
chown -R www-data:www-data owncloud
sudo -u www-data php owncloud/occ upgrade
sudo -u www-data php owncloud/occ maintenance:mode --off


/////Round 2 upgrade from 8.1.12 to 8.2.10

cd tmp
wget https://download.owncloud.org/community/owncloud-8.2.10.tar.bz2
tar xjf owncloud-8.2.10.tar.bz2 
sudo -u www-data php ../owncloud/occ maintenance:mode --on
service apache2 stop
cd ..
mv owncloud owncloud81
mv tmp/owncloud .
cp owncloud81/config/config.php owncloud/config/
cd owncloud
REM Because our owncloud data is soft link to /srv/data so I need to make a soft link
ln -s /srv/data/ data
REM
service apache2 start
cd ..
chown -R www-data:www-data owncloud
sudo -u www-data php owncloud/occ upgrade


/////Round 3 upgrade from 8.2.10 to 9.0.8
cd tmp
wget https://download.owncloud.org/community/owncloud-9.0.8.tar.bz2
tar xjf owncloud-9.0.8.tar.bz2 
service apache2 stop
cd ..
mv owncloud owncloud82
mv tmp/owncloud .
cp owncloud82/config/config.php owncloud/config/
cd owncloud
REM Because our owncloud data is soft link to /srv/data so I need to make a soft link
ln -s /srv/data/ data
REM
service apache2 start
cd ..
chown -R www-data:www-data owncloud
sudo -u www-data php owncloud/occ upgrade


/////Round 4 upgrade from 9.0.8 to 9.1.4
cd tmp
wget https://download.owncloud.org/community/owncloud-9.1.4.tar.bz2
tar xjf owncloud-9.1.4.tar.bz2 
service apache2 stop
cd ..
mv owncloud owncloud90
mv tmp/owncloud .
cp owncloud90/config/config.php owncloud/config/
cd owncloud
REM Because our owncloud data is soft link to /srv/data so I need to make a soft link
ln -s /srv/data/ data
REM
service apache2 start
cd ..
chown -R www-data:www-data owncloud
sudo -u www-data php owncloud/occ upgrade


/////Finish upgrade
sudo -u www-data php owncloud/occ maintenance:mode --off


/////Clean unwanted directories and files
rm -rf owncloud80 owncloud81 owncloud82 owncloud90
rm -rf tmp


/////DO Upgrade ubuntu 14.04 to 16.04
sudo do-release-upgrade 
reboot
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo vi /etc/fail2ban/jail.local 
############
#
# SSH servers
#

[sshd]

enabled = true
bantime = 3600
port    = ssh
logpath = %(sshd_log)s
############
sudo systemctl restart fail2ban.service 
sudo systemctl status fail2ban.service 
sudo vi /etc/shorewall/rules 
//correct the line
SECTION NEW 
to
?SECTION NEW
//
sudo systemctl restart shorewall.service 
sudo systemctl status shorewall.service 


/////DO THIS: After upgrade ubuntu 14.04 to 16.04
sudo su -
apachectl -M
apt install php7.0
apt install php7.0-mysql 
apt install php7.0-gd
apt install php7.0-zip 
apt install php7.0-curl 
apt install php7.0-mbstring 
service apache2 restart


#Empty the old owncloud.log
echo "" > owncloud.log 

#Change maximum upload file size
cd /var/www/html/owncloud/
vi .htaccess 
######
<IfModule mod_php7.c>
#  php_value upload_max_filesize 513M
#  php_value post_max_size 513M
  php_value upload_max_filesize 1024M
  php_value post_max_size 1024M
######
vi /etc/php/7.0/apache2/php.ini 
######
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
; upload_max_filesize = 2M
upload_max_filesize = 1024M
######
service apache2 restart 

#Show all user disk usage
cd /srv/data
find . -maxdepth 1 -type d -exec du -sh {} \;


#Setting strong directory permissions
cd
mkdir manage_owncloud
cd manage_owncloud
vi setting-strong-directory-permissions.sh
######
#!/bin/bash
ocpath='/var/www/html/owncloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/

chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess

chmod 0644 ${ocpath}/.htaccess
chmod 0644 ${ocpath}/data/.htaccess
######
bash setting-strong-directory-permissions.sh 


#Delete unwanted backup files
cd /srv/data/updater_backup/
rm -rf 8.0.*


/////Last checking step. Goto sharedrive.psu.ac.th and then you will see warning messages.
cd /etc/apache2/sites-enabled/
sudo vi sharedrive.psu.ac.th.conf 
###########
        Header always set Public-Key-Pins "pin-sha256=\"/2HGX/OiBOgncwWb2NCBne3PEEx7Vu3ydZNKvN5WCu0=\"; pin-sha256=\"xtowzM+NfIjxXeOcfN074GW6L8wLf0UG7dBLvERNcGA=\"; max-age=63072000"
        Header always set Strict-Transport-Security "max-age=63072000;includeSubDomains;preload"
        Header set X-XSS-Protection "1; mode=block"
        Header set X-Content-Type-Options nosniff
    <files xmlrpc.php>
      order allow,deny
      deny from all
    </files>
###########
sudo service apache2 restart

/////If use cron.php, then start cron.
sudo vi /etc/cron.d/owncloud-cron-dot-php
*/15  *  *  *  * www-data php -f /var/www/html/owncloud/cron.php