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?

  2. One of the first results:
  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.”

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.


According to the GitHub ToS ( 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.


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.


What would you guys recommend to use instead?

1 Like



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.

1 Like

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 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:

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.


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!


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.

1 Like

Here’s a pointer