Errors Occurrs Each Time "GIT pushing" to remote.

October 10, 2017 470 views
Nginx PHP Frameworks Ubuntu 16.04

Hello everyone,

I encounter two issues with my laravel web app each time I "git push" to the server. Everything works fine on the local machine (Mac). I am running nginz server on DigitalOcean.

1- Each time I "git push" to remote, all the pictures only the website get broken. The only way I solve this is, cd to public/storage, delete the storage folder and then run php artisan storage:link. This is tedious because I have to do it every time I "git push" to remote.

2- Each time I "git push" to remote and when I try to updating/populating any of my tables, I receive this error after the table has been updated/populated:
(1/1) PDOException SQLSTATE[HY000]: General error: 8 attempts to write a readonly database

Sinc,e I am using TNTSearch package, I notice it tries to write to the index file. I figured out that I need to give permission to the database, so I solve this issue using: chmod -R 0777 /path/to/index . This solves the problem but it recurs when I "git push" to the remote.

How can I give a permanent write permission to public/storage (in the first case) so that I do not have to run the command each time I push to remote?
Also, How do I give a permanent write permission to the database, so that I do not have to do that each time I push to remote?

Thank you in advance.

1 Answer

If you have specific tasks that must be completed (e.g. running php artisan storage:link) after each push to your production server, you might consider using git hooks to automate them. Placing a script at .git/hooks/post-receive will cause it to run on the git remote each time it receives a push.

Find out more details about using git hooks in this tutorial:

by Justin Ellingwood
Git is a very robust and mature version control system that has seen great adoption in recent years. One of git's great features is its ability to use "hooks" to call arbitrary scripts when certain git events occur. In this guide, we'll discuss the general idea behind git hooks, talk about how to work around some of its inconsistencies, and demonstrate some implementations that you can use in your development process.
Have another answer? Share your knowledge.