Git setup for web development on my personal server - php

I'm going to start working on a web application. The application uses php and the files are going to be hosted on a server I own. Some of my friends will also be working on this project with me.
How exactly should I set up git (using GitHub) so that when me and my friends push our changes to GitHub, our server gets updated automatically with the php files?

git push has a mirror mode that may just be what you want. All you need to do to activate it is to set your remote as --mirror=push and all should be good. IF not, leave a comment and I'll help further.

Another way is to install git on your server, add the settings for github and setup a cron every x period (1 minute) that makes a git fetch and reset to the development branch - that way when you push something to that branch your server will fetch it and reset the filesystem to it.
3rd way - check out the article using Github WebHooks on http://jonathanstark.com/blog/deploying-code-automatically-with-github-webhooks

Related

How can i to deploy my PWA on remote server?

I developed a Progressive Web App (PHP and JavaScript based) and i upload it on remote server LEMP (Debian/Nginx based) through FileZilla.
How can i deploy in future the updates without to use FTP?
What tools exists for to manager the next versions of my web app?
If it is of utility i use VSCode for coding.
Thanks guys!
You can't update your web app without FTP. In order to update a new service worker, it needs to have at least one byte different than the previous version.
And the only way to update the service worker file is via FTP.
If you can't use FileZilla for whatever reason, you can try alternatives like editing files through Cpanel File Editor.
Or you can use free hosting like Github Pages, Netlify or Firebase. And automate the deployment of your front each time you commit something on a git repository.
This solution only works for your static files. not for your backend using PHP.
Thanks guys for your replies.
I found the right solution for me following this article: https://amifactory.team/blog/how-to-deploy-a-website/#simplewayscprsyncftp
In pratice i use lftp utility to sync my local website with my website on remote server.
The good notice is that "lftp" copy changed files only, reducing the uploading time and copying / overwriting the new files only at the end of the "lftp" process.

Can I Link XAMPP Server to Github?

How would I go about starting a XAMPP server that uses files from GitHub instead of htdocs?
The idea is that I have my PC on connected to my router and while I am away I can push or merge updates to GitHub, and they are automatically live as XAMPP would be pointed at my Repo.
Can this be done?
I know you can use gitpages, but php and server side code is critical to what we are doing.
You could use webhooks in combination with your Xamp server in order to:
listen to push events on GitHub, and,
when said push is detected, git pull that repository in order to update your files

How to perform a self-update on a local web system?

I developed a web system (in CodeIgniter) for a client and it runs on a local machine inside his office. Whenever I need to update the system, I perform the following steps:
Access to server machine via TeamViewer;
I open CMDER;
Access my account on Bitbucket to give a git pull;
I run the necessary migrations;
Thinking about these desktop systems that automatically look for a new version and upgrade, is it possible to do a routine in this web system to do the same thing? Search Bitbucket (or another web server) for a new version and then do the update?
Thanks for the suggestions.

automatic pull on production server after push to BitBucket

I develop my code locally, commit it to my local repsoitory and then push it to my Bitbucket server. After that I have to login via ssh to my production server
like this:
ssh my-server#my-host.de
pass: very-secure-passs
cd www/myPage
cd git pull origin master
pass: very-secure-pass
I would like to avoid login to my production server and let him pull automatically.
I want to have 3 repositories (local, BitBucket and production Server), so I cant use this solution: Do an automatic pull request after pushing to server
I found this question A hook that let `pull` from VPS when I `push` to Bitbucket which is exactly what I want, but it is from 2013 and the answer is outdated since BitBucket has changed since then.
I found here https://community.atlassian.com/t5/Answers-Developer-Questions/How-can-I-deploy-my-bitbucket-repo-to-my-production-server/qaq-p/565348 that someone suggested to use a free Plugin called HTTP-Request Hook for Bitbucket Server
set up an automated "Pull": Each time you do a push to your central
repository, your production machine is notified and pulls the
repository on notification. Bitbucket Server offers serval plugins to
support the notification process - the one I use is Http Request Post
Receive Hook: each time a push is made, a configured URL is contacted,
submitting some info. On my production machine I have set up a little
web server, waiting for this HTTP-Request. On receiving the
HTPP-Request I evaluate the given parameters and perform an action
(for example: pulling the repository ...)
Now my questions are:
Is it possible to use a Webhook instead of the HTTP-Request
Hook Plugin?
How should the file on my production server look like so that it will do a pull request when it receives a HTTP-Request? I would be interested in a basic example in PHP.
The webhook documentation you linked is for Bitbucket Cloud (bitbucket.org), not Bitbucket Server (which is self-hosted and has some other URL). If you're using BB Cloud, then the HTTP-Request Hook Plugin won't work, but the documentation you linked will. If you're using BB Server, then you can use https://confluence.atlassian.com/bitbucketserver/managing-webhooks-in-bitbucket-server-938025878.html instead to define a webhook.
For the second half of your question - how to set up your server's end of a webhook - you'll need to have a small service that listens for the incoming webhook, does whatever authentication you want, and then runs your pull method. There are a zillion ways to do this, but most will vary based on your preferred language and security settings and on the network configuration of the server in question. I'd suggest a Google search for "webhook deploy $LANGUAGE" to see how some others have done it with your preferred language, or to see if there's a public repo or gist or snippet out there that you can use.
Instead of directly trying to pull on production server, you can setup a Jenkins job that will push the code to production server on each commit. Using Jenkins you can even customize the solutions to match particular token in commit message.

Heroku "no Cedar-supported app" when pushing, even though app is on cedar stack?

I have never used Heroku before, but our client wants us to use it. An app is already set up on Heroku, and if I log in and check the app info it says that it is on the cedar stack.
Now I want to put some PHP files onto it. I've set up a remote, then used git init, add, commit, but when I try to use "git push heroku master" I get the error:
Heroku push rejected, no Cedar-supported app detected
I don't understand since the app has been set up as a cedar app? I've seen lots of people with the same error message, but all of the solutions seems to say it's something to do with gemfiles (I have no idea what they are), or to run git init again.
Does anyone have any other ideas on what the problem could be? I apologise if there isn't much info here, but as I say I've never used Heroku before, and have only used git for one other project (normally we use our own server which I can just drop PHP files into using a GUI).
Thanks
You need to have an index.php in the root for Heroku to detect the application type as PHP.

Categories