简体   繁体   中英

Uploaded files getting deleted while redeploying in Openshift server

After pushing the whole application, The whole application is working fine. Then I upload some files to my uploads folder via my web interface.

If I push the code via git, All the files in uploads folder is deleting automaticaly. Is there a way to stop this in my openshift server ?

Your application should be storing any persistent files in the $OPENSHIFT_DATA_DIR , which is usually ~/app-root/data. Your application is likely storing these "uploads" into the $OPENSHIFT_REPO_DIR , where your code lives. This directory is overwritten with your new code every time you git push .

You need to configure your application to store the uploads in $OPENSHIFT_DATA_DIR to store them persistently.

on your root wordpress local create a dir for action hook

mkdir -p .openshift/action_hooks

then create deploy hook

vim .openshift/action_hooks/deploy

paste this

#!/bin/bas
echo "Creating symlink folder of uploads" 
if [ ! -d ${OPENSHIFT_DATA_DIR}uploads ]; then
    mkdir ${OPENSHIFT_DATA_DIR}uploads
fi
ln -svf ${OPENSHIFT_DATA_DIR}uploads ${OPENSHIFT_REPO_DIR}wp-content/uploads

NOTE : The .openshift/action_hooks/deploy hook is not executable, to make it executable:

On Windows: git update-index --chmod=+x .openshift/action_hooks/deploy

On Linux/OSX: chmod +x .openshift/action_hooks/deploy

add changes, commit and push.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM