Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Losing the public/uploads directory after deploy #402

Closed
folivi opened this issue Jul 14, 2016 · 10 comments
Closed

Losing the public/uploads directory after deploy #402

folivi opened this issue Jul 14, 2016 · 10 comments

Comments

@folivi
Copy link

folivi commented Jul 14, 2016

Hi,

I'm using carrierwave which stores uploaded files into public/uploads.

After deploying, the public/uploads directory is not copied to the current version and all my uploaded files are lost.

How can I fix this?

@d4be4st
Copy link
Member

d4be4st commented Jul 14, 2016

Add public/uploads to shared_paths variable and create public/uploads
in shared folder on server

On Thu, Jul 14, 2016, 20:19 Folivi notifications@github.com wrote:

Hi,

I'm using carrierwave which stores uploaded files into public/uploads.

After deploying, the public/uploads directory is not copied to the current
version and all my uploaded files are lost.

How can I fix this?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#402, or mute the thread
https://github.com/notifications/unsubscribe/AA7cMLtfT13OKFLdiTxLyHeMMh7oYP51ks5qVn2sgaJpZM4JMtSU
.

@folivi
Copy link
Author

folivi commented Jul 15, 2016

Thanks

@folivi folivi closed this as completed Jul 15, 2016
@folivi
Copy link
Author

folivi commented Jul 17, 2016

Unfortunately this doesn't work as expected.
I followed the instructions.
Performed a Model.delete_all on the model mounted with Carrierwave gem
I create a new record with an attachment then go to the show action, I get a NetworkError: 403 Forbidden - error on the uploaded file.
But when I create manually the 'uploads' directory in the public directory, this error doesn't happen.
When I make changes in the app and deploy a new version, the errors shows up again.

I decided to repeat the entire process from the beginning; deleted the app folder from the server, created the public/uploads dir in the shared dir, add the variable etc...
Started the brand new app again and got the the same 403 error again.

How can I fix it?
Thanks again

@folivi folivi reopened this Jul 17, 2016
@d4be4st
Copy link
Member

d4be4st commented Jul 19, 2016

Can you ssh to your server and do a ls -al in the public directory to see if the symlinks are created as they should?

@folivi
Copy link
Author

folivi commented Jul 19, 2016

ls -al returns this

lrwxrwxrwx 1 folivi folivi 59 juil. 19 11:18 uploads -> /home/jigger/rails/deepblue/production/shared/public/upload

@d4be4st
Copy link
Member

d4be4st commented Jul 19, 2016

is that upload missing an s or was that just a copy/paste mistake?

either way, this should be it. There should be files in your /home/jigger/rails/deepblue/production/shared/public/uploads folder.

Also 403 error message might mean that the shared uploads folder does not have the right permissions. If that is so please google around for nginx static permission denied

@folivi
Copy link
Author

folivi commented Jul 19, 2016

It's a copy/paste mistake. The dir name is correct

this is what I get when I ls -al in my production/shared/public dir:
drwxr-xr-x 4 folivi folivi 4096 juil. 18 01:31 uploads

I followed exactly what is described in the docs and this question: #214

@d4be4st
Copy link
Member

d4be4st commented Jul 19, 2016

Sorry but this looks like a web server issue.

If the symlinks didn't work you would get 404 as he cant find the files.
the server can find the files but it does not have permissions to access them.

@d4be4st d4be4st closed this as completed Jul 19, 2016
@folivi
Copy link
Author

folivi commented Jul 19, 2016

ok.
I've been looking but looks like I'm the one who came accross this issue.

Do you see anything wrong with my virtual host config?

DocumentRoot /home/folivi/rails/myapp/production/current/public
PassengerRuby /home/folivi/.rvm/wrappers/ruby-2.2.3/ruby
ServerName myapp.com
ServerAlias www.myapp.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myapp.com$ [NC]
RewriteRule ^(.*)$ http://www.myapp.com$1 [R=301,L]

<Directory "/home/folivi/rails/myapp/production/current/public">
allow from all
Options None
Require all granted

@folivi
Copy link
Author

folivi commented Jul 19, 2016

Solution

In my apache virtual dir config, I had to allow apache to serve files which are not inside the app root, by adding the directive

Options FollowSymlinks instead of Options None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants