Deploying PHP to GitHub Pages - is it possible?

I’m trying to deploy an index.php file to my GitHub Pages site, but I have absolutely no idea how-to! Any pointers?

8 Likes
  1. https://www.google.nl/search?q=github+pages+php
  2. One of the first results: https://help.github.com/articles/what-is-github-pages/
  3. Quote from page: “GitHub Pages is a static site hosting service and doesn’t support server-side code such as, PHP, Ruby, or Python.”
17 Likes

I’ve realised that it doesn’t provide default PHP hosting :smiley: It’s just that I was wondering if there is anyway to host PHP on GitHub - be it using a script or something (I honestly don’t know, I’m barely a developer)?

Of course, it wouldn’t be in anyway that would pose a threat to GitHub Pages or violate any Terms of Service/Terms of Use.

1 Like

According to the GitHub ToS (https://help.github.com/articles/github-terms-of-service/) section I:

  1. ”This hosting service is intended to host static web pages for GitHub users.”, PHP is not static
  2. You should follow the GitHub Pages guidelines, and as you can see in my previous post these guidelines say again that PHP is not availible

 So you can’t run PHP without violating the ToS.

25 Likes

Thanks for your thoughts, and for quoting that excerpt of the GItHub Terms of Service.

Of course, just to be clear, you CAN host php scripts, and essestially anything, in a github REPO.

1 Like

It is not working.  When load php page getting download prompt for the file.

Is it working for you?

Did you read the thread? You surely can host the PHP file in GH repos as a static file but it won’t execute on the GH Pages platform.

5 Likes

What would you guys recommend to use instead?

Javascript                

4 Likes

Why do you even want to host your PHP site on Github when you have proper servers like DigitalOcean, AWS and others. If it is the server hassles that you want to avoid, then there are services that provides managed PHP site hosting on these servers. As for github pages, I don’t think it supports non-static sites.

No, you cannot do that on Github Pages as it only supports static websites, i.e. sites built on html, css, JS.

You can add php file in github repo, but it won’t execute or compile your php code this is the same with google drive

The good thing is that you can place your php in other server then use github repo html, javascript and call the php via ajax  to load content result so you can have a dynamic page in github.

1 Like

umm if i put a single cgi file? will work?

@mckaygerhard No, it won’t. Read the thread - hosting PHP both isn’t possible and isn’t allowed on GitHub pages.

You however can, and should, host your PHP code with GitHub.

How to do this, this is what I’m looking for. Any links or something…

I badly want the github.io to be my main portal as it sounds cool and professional. lol. All I need is for my website to be maintainable and dynamic.

1 Like

Hi @designdust ,

There are a million ways to accomplish that. But the idea always is that you have the static stuff on GitHub and that uses JavaScript to load dynamic data from some place else.

An example would be: https://medium.freecodecamp.org/from-zero-to-deploy-how-i-created-a-static-website-from-scratch-using-netlify-gatsby-ebca82612ffd

However, if you have any ideas about what kind of technologies/frameworks you’d like to use, we may be able to offer a few tutorials that better fit your needs.

3 Likes

Presenting the project in  GitHub Pages using php is not - as mentioned in the previous response regarding ToS.

As also mentioned:

Deploying php source to GitHub for project management, and even posting to the destination hosted server is possiible.  Nothing in GitHub prevents this.

For me, this was the solution to the conundrum:

Alternate Solution: Don’t use GitHub Pages for working with php projects.

 - Develop php locally using an OracleVM Virtual Machine configured to match your hosting server resources.

For me it was what to me seems alterately referenced as a LAMP or LEMP stack.

(Google “how to create an Oracle VM LAMP stack” for examples using your favorite Linux flavor). 

 - Use Git to manage the project files to be pushed to your registered domain on demand.

 - When you need to make changes to the live site - create a pull request and merge.

Hope this helps!

1 Like

Hi, Github pages only provides static page hosting. You need to buy a web hosting or Vps server for this. PHP needs a server to run the php pages. On localhost you have the option of internal servers in frameworks.

Here’s a pointer

0x8765adsa665dd5e