Deploy website built on personal computer

I want to know how I should deploy a real website to the web when I have finished it on my personal computer? For example all the PHP-stuff and so on works on my computer at the moment.

So how will this change and get processed when I upload everything to a hosting company? Since they have their own CPANEL and things like that won’t the code get changed in some way?

I also want to know what the best way is if I want to upload projects(websites and apps) that I have built on my personal computer, without having to deploy it to the real web, with a hosting company?

For example, I have heard that GitHub has a function which enables a noob coder to upload its projects there? :slight_smile:
And then the PHP would work like on a normally deployed website, for the people that views it, I guess?

Also, what are some alternatives to GitHub, for uploading projects like that, to show of a portfolio?

in github you can upload the code in a repository, it would be like having the files on your computer. (aside: if you are not yet using Git, it’s a great thing to learn, even without github).
github offers github pages where you can deploy front-end projects, which means php can’t work there

but there are free services for full stack apps, like Netlify, Heroku, etc… I don’t know if they support php but you can check

I have no experience with a custom domanain and an hosting company

Hmm ok.

By the way. Do you know if there are any websites where small business owners and such seek help for their code challenges from volunteers/developers? I want to try to do other people’s code problems for them. Just to see if I can. And for the learning experience.

For example, building out their CSS, HTML and Javascript. I could do that for free. In that way I would have something to show to potential employers. But I am not sure where to look for customers in need of assistance.

GitHub is the world of open source

freeCodeCamp itself: https://github.com/freeCodeCamp/freeCodeCamp

or you can check this guide on how to contribute to open source: https://github.com/freeCodeCamp/how-to-contribute-to-open-source/blob/master/README.md

if yuo start contributing substantially to an open source project you can put it in your resume

Look up freelancing websites online.

For example, I’ve used fiverr in the past for some basic html/css stuff I was too lazy to build myself :wink:

1 Like

Ah cool :slight_smile: I will check it out.

Do you know of any others like that? I guess they won’t care in what part of the world you are working from either. If you do it for free :slight_smile:

Also send me a message if anyone wants me to do this for them for free. Since I am just trying to learn I want to have code challenges related to the normal world.

Yeah if someone knew where I could upload PHP-projects that would be great.

Hmm, why is is good to learn GIT you say? This might be a stupid question but I don’t quite know the difference between Git and GitHub. I thought Github was just a place where people could upload projects to display a portfolio?

GitHub is mostly for webdesigner then? For people who work in frontend? But people who work with full stack will normally upload their projects to other display-sites?

github is an hosting service that uses git, which is a version control

for example this is the freeCodeCamp repository: https://github.com/freeCodeCamp/freeCodeCamp

you can see the code, front-end and back-end logic, the history of how each file was changed over time, issues (bug reports, feature requests…), and Pull Requests to update the code

1 Like

Hmm ok. I will watch that one. Thanks.

If I learn everything in that video would that set me on my way to learn this in a good way?

Off topic: When creating a website with php, html, javascript and so on. Is there any reason why I should not use index.html as the main file?
Or when creating stuff with php, should the mother-file always be index.php?
Or could it just as well be index.html?

I see they are both showing up in the XAMPP-server, when I paste them in the URL. But what would be the reason for using only php-files? Or could I change and intermix them just as well because it does not matter if some posts/pages are html, and some are PHP?

The best way to learn git is to use it, so maybe you can start showcasing your websites on GitHub too

I don’t know php, so I don’t know technical details but:

  • the browser can’t open php files, only html files
  • you can’t write php in html files
  • to serve a php file you need a server that does that, a website done only with html/css/javascript doesn’t always need a back-end, it can be front-end only

Ok

I did not know it was not possible to write php-code in HTML-pages. Maybe it just works the other way around then? Because it is possible to write html in php-pages for some reason.

About the finished product, how do people normally deploy a website like the one you describe, which only uses frontend-languages, to a Hosting company?

For example, I know how to buy a domain name and throw up a website with Wordpress, through a Hosting.

But when doing this they will normally fix the Wordpress password and such things. (But I am not sure I remember it correctly)

But what happens when I create a website… Let’s say it does not use any PHP. But I create it through Visual Studio code, using only CSS, HTML and Javascript.

What do I do when I am happy with that website and I want to deploy it to a hosting?
Will I first buy a domain name and then contact them to have them put it up on the web? Do I send the files to them in that case or something?

It is probably a dumb question but I am thinking a lot about this.

For example, in Wordpress it is possible to see where all the viewers of that website is coming from with different plugin, within that website. But how would that be done with a website that has been created through a text-editor? Would the backend there look like it does in the text-editor when it is up and running or what does it look like?

Or do people normally upload their finished products to Wordpress, when they are happy with the code and layout of their websites?
I am not sure how people do this so I don’t quite understand all the steps.

I have zero experience with wordpress, but if you’d like to deploy a website that you’ve built in your local environment, you’d need a webhoster and a domain name.
The webhoster will then give you access to a folder on their server, where you can upload all your files via FTP. The folder would look exactly the same as the one in your VS Code. And because it’s a server, you can also upload PHP files.

Not off the top of my head, but I’m sure you can google around.

Off topic: When creating a website with php, html, javascript and so on. Is there any reason why I should not use index.html as the main file?
Or when creating stuff with php, should the mother-file always be index.php?
Or could it just as well be index.html?

The nature of PHP can be pretty confusing because it can be used in a lot of ways.

It originally started as a server-side templating language that could be mixed with HTML. Later it became a fully featured general purpose language that you can use to build complete applications with.

PHP is also a powerful scripting language. With a properly configured web server you can visit www.yoursite.com/send-mail.php which will just begin executing a one-off script that sends an email and maybe redirects the user back to another page.

Since you can redirect back to whatever you want including a page that just serves a static HTML file, technically, yes you can build an application where you have both HTML and PHP files. It’s important to understand your app will always be serving HTML even if your URL looks like yousite.com

Typically when you use PHP to build an application you have a single entry point index.php which your web server is configured to send all requests to that file. We call that file a “front controller” as it bootstraps the application, parses the URL and then figures out which controller file to load, which then that controller is responsible for figuring out which page the user should see.

PHP runs on your server and the output can be HTML. This is when you use PHP as a template language, which is a common thing to do. However, you can use PHP to build a JSON API that could be consumed by a SPA in which case your app wouldn’t even return any HTML at all.

Even in the case where you are building a brochure type website where you might feel inclined to have HTML files as well as PHP files you will usually find that you just make every page a PHP file. Mainly because the reason you’re using PHP in the first place is to either have some templating or add a bit of dynamic content to your site. So it’s only natural, and more consistent if each file is just PHP.

To clarify, “hosting” can mean a couple things.

When people say “host your project on GitHub” they really mean that you can store your source code on GitHub in the same way you might store your file on Dropbox or Google Drive.

GitHub and Git are two different things. Git is a version control software. Think of it as a crazy advanced history of your code. GitHub is just one among many services that you can use to store your git projects safely in the cloud so that a) they don’t get lost if your computer ever dies and b) you can collaborate with teams of developers.

This is used by teams of developers all over the world to manage and collaborate on software systems written in anything from A to Z (literally those are programming languages). Frontend, backend, middlend it doesn’t matter. GitHub is for hosting code.

The other definition of “hosting” is the one you’re thinking of. That’s where you host your source code files on a web server somewhere and people can visit your site through a web browser.

GitHub also has a solution for that second definition of “hosting” and it’s called “GitHub Pages”. This service is free but it can only host “static websites”. By that I mean it can only serve files that don’t need to be processed on a web server somewhere. So it wouldn’t work for a PHP site, since PHP is a server-side language.

It’s a great option to host a single page application, a static site, or even a site built with a static site generator.

To host an application written in PHP you need to look at services that provide the ability to run your application server-side. More old school but valid options would be using one of the hosting companies you’re talking about where you get access to either a shared server or a virtual private server and it comes installed with a bunch of junk you’ll probably never use including CPANEL.

CPANEL is cool when you’re just starting out, and I know there are plenty of agencies that still use it. But if you keep up with the times you’ll find yourself gravitating away from thinking about servers at all.

That’s where services like Heroku are really nice as they handle managing the server for you and give you tools that allow you to set up automated deployments of your application, usually with a generous free tier making them great options for portfolio or pet projects.

There’s also more involved options like Digital Ocean, Linode, AWS etc. You can get super cheap virtual private servers from these companies to host your PHP applications but you have to set up the server yourself.

So how will this change and get processed when I upload everything to a hosting company? Since they have their own CPANEL and things like that won’t the code get changed in some way?

No your code will not get changed when uploading the files to a web server. However, you usually have configuration files that are not checked into your version control software (Git) that are different on your local environment (your personal computer) and your production environment (the web server).

For example, in local development you might have a configuration setting that dumps stack traces in the browser when something goes wrong. Obviously you would never want this behaviour in production so you would have that switched off on your server.

Aha great answer. it makes a little more sense now.

I have some more dummie-questions. And those are the following:

  1. When I open a site with a Hosting through Wordpress, I am able to download things like Yoast-plugin and WP Statistics. This makes it simple to look at viewers to the site and SEO and so on.

But how is that done if the website is created on my server through a text editor? When I upload the site to a hosting company. Will it start to run on Wordpress automatically most often? And if not, how do people manage things like looking at SEO and statistics of viewers if they don’t have kind of a backstage-area like you do in Wordpress? Where one can look at statistics and so on through different plugins.

  1. I have heard the word Heroku before but I don’t really quite know what it is. Will this make PHP and other server-side languages obsolete in the future or something?

  2. Setting up a server can be done quite cheaply today? Is that hard to do? I know what is hard to do is relative. But compare it to learning frontend, maybe setting up your own server is a real pain in da butt? :slight_smile: