zsx

zsx

先作为主站备份 源站:https://my.toho.red

Heroku Tutorial - Building a PHP Dynamic Blog with Zero Cost

#Preface

As we all know, most static website hosting services (such as Vercel, Netlify) are completely free. My MC official website is hosted on Vercel. But is there a completely free dynamic website hosting service (i.e., virtual hosting)? [This link][1] introduces such a method. However, when I followed this tutorial to build it, I encountered some issues:

  1. Heroku can no longer import projects through GitHub when I used it. I have to set up my own Heroku Git. This article will explain the solution.
  2. The setup requires the use of a Linux system, which includes an additional step of registering GoormIDE. This article will use Windows throughout the process.
  3. It is not necessary to provide credit card verification when using only one plugin. This article will eliminate this misconception.

Without further ado, let's get started.

Note: This article will refer to some content from the previous article in certain places, please ignore it.

#Getting Started
##Preparation

  • Heroku account without the need for credit card verification
  • A computer running the Windows operating system
  • Intermediate level of English or translation software
  • Brain

##Registering Heroku

Click the [link][2] to register, and an email will be sent to receive the verification code.

After successful registration, click New → Create APP to create a project. Fill in a name and click Create APP (the name is not important, as it will be used with your own domain name).

In the Settings, set the Buildpacks to PHP:
![Heroku Setting 1-1024x177.png][3]

In the Resources, add the Postgres component (choose Hobby Dev to avoid credit card verification prompt):
![Screenshot of QQ 20220512132019.png][4]

##Deploying Typecho

Download Heroku-Git by clicking [here][5] and install it (just click Next all the way, there is nothing to configure), then open the command prompt and perform the following operations:

What? You haven't installed Git? Then please click [here][6] to install it before continuing:

Is it ready to use after pushing? Obviously not, you still need to obtain the database address. Go back to Heroku, click on the Postgres component in Resources, and record the database information here:

![Screenshot of QQ 20220512134324.png][7]

Click Open app in Heroku, and then install it on the webpage (if the installation page does not pop up, assuming the opened URL link is abc.com, then please change abc.com to abc.com/install.php to start the installation)

![Screenshot of QQ 20220512134442.png][8]

After the installation is complete, refresh the page. If everything is normal, then you have your own personal blog, and it is theoretically permanent free.

##Using a Custom Domain Name

Don't like the provided domain name? No problem, Heroku supports custom domain names, but...it's not free, it requires credit card verification (whispering)

But it's okay, you can still use Cloudflare Workers to reverse proxy your website and achieve the effect of a custom domain name. However, it usually only allows browsing, and you still need to log in through Heroku's link to access the backend.

Setting up reverse proxy: [Click here to view][9]
Custom domain name: [Click here to view][10]

#Afterword

[This is the finished product I built][11]. Currently, due to the theme not supporting the new version, it cannot be fully displayed, so the default theme is used as a demo.

Special thanks to www.itansuo.info for providing reference tutorials for this article.

2022.5.12

Additional update:

The database provided by Heroku may experience credential resets, but it has been tested and found that it only occurs when the application is restarted, so there is usually no need to worry about it.

However, sometimes there may be compatibility issues with certain plugins or themes when using PostgreSQL. What should you do in that case? By using a cloud MySQL database, you can partially solve this problem.

After some searching, I found a [free database][12] that is quite useful, although it has a capacity of only 5MB. However, even if this site has been in operation for two years, the database size is less than 500KB, so it is completely sufficient.

This tutorial is only suitable for users who are both poor and like to tinker. If you have some spare money, it is still recommended to purchase virtual hosting for a more reliable solution. Of course, backup should also be taken into consideration, otherwise, there may be situations where data is inexplicably lost and cannot be recovered, just like this site.

Wishing you a successful free ride.

2022.6.6
[1]: https://www.itansuo.info/429
[2]: https://heroku.com
[3]: https://my.toho.red/usr/uploads/2022/05/3959255973.png
[4]: https://my.toho.red/usr/uploads/2022/05/2459223332.png
[5]: https://cli-assets.heroku.com/heroku-x64.exe
[6]: https://git-scm.com/
[7]: https://my.toho.red/usr/uploads/2022/05/1251680097.png
[8]: https://my.toho.red/usr/uploads/2022/05/1243310225.png
[9]: https://blog.moej.cn/archives/339/
[10]: https://www.nbmao.com/archives/4979
[11]: https://typecho222.herokuapp.com/
[12]: https://www.freesqldatabase.com/

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.