Recent

Author Topic: Deploying a Lazarus web server in cloud web hosting  (Read 13632 times)

jeffp

  • New Member
  • *
  • Posts: 15
Deploying a Lazarus web server in cloud web hosting
« on: July 17, 2021, 03:22:20 am »
Let's say I have written a working FPC/Lazarus web server to serve JSON data from a data store.

Can I deploy this Windows executable in cloud web hosting services, say like, DigitalOcean?

If not, then where or how is this kind of app deployed, so that it is accessible by similar Lazarus clients across the internet?

Thanks in advance.

bobkos

  • New Member
  • *
  • Posts: 32
    • Personal Finance Manager
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #1 on: July 17, 2021, 05:38:48 am »
Hi,

Yes, you can develop and deploy you executable file on vps. I'm not familiar with DigigtalOcean services, but I have same on Oracle's cloud services. You should have an access to deployed OS (windows or linux) and vps managmenet console in order to configure firewall.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #2 on: July 17, 2021, 06:28:28 am »
Hey JeffP,

First of all the answer is Yes you can deploy a Lazarus/FPC web server on the Cloud. just like @bobkos said.

Second, you need to understand the difference between a web-hosting service and a VPS.

Web-Hosting: Usually deployed on a LAMP Stack(Linux/Apache/MySQL/PHP) and DigitalOcean, probably, has great prices for this. This will not work for a Lazarus/FPC web server

VPS: These are Virtual Private Servers, that are virtualized on a mega scale. It's not quite VMWare, but you get the idea.
I'm not sure if DigitalOcean has VPS services but if it has, I can guarantee you that the linux VPS will always be 1/2 price or even less than the Windows VPS.
This is exactly what you need for a deployment of any custom piece of software that you want to live in the Cloud.

Please Google for "DigitalOcean VPS" or "DigitalOcean Virtual Private Server" in order to see if they have anything in a good price range.

From my last look at it I got prices from £1 to £30 a month for Linux VPS starting from 2GB RAM and 1 Virtual CPU.
On that same search, all Windows VPS started at around £10 or more. Not quite sure about the Windows values, but I have a spreadsheet with those values if you want a better list.

Hope this helps.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

jeffp

  • New Member
  • *
  • Posts: 15
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #3 on: July 17, 2021, 09:18:24 am »
Hi @bobkos. Hi @Gus.

Thanks for clarifying for me the difference between a VPS and web-hosting.

Obviously VPS is what I need for the desired Lazarus server application. DigitalOcean does have a VPS for such purpose. Now since cost is a major consideration for me, the Linux VPS is more desirable being less costlier. However, since I develop in Windows and produce Win32 Lazarus apps, should the VPS be running Wine then, or is there a different approach to this?

And since database would definitely part of the ecosystem, say Postgresql, I'm guessing a Postgresql will add to the cost of the VPS, right? And I could probably circumvent this by developing something that provides its own light database like mORMmot with SQLite. I'm being ambitious. :)

Thanks again.

zamronypj

  • Full Member
  • ***
  • Posts: 133
    • Fano Framework, Free Pascal web application framework
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #4 on: July 17, 2021, 10:30:17 am »
However, since I develop in Windows and produce Win32 Lazarus apps, should the VPS be running Wine then, or is there a different approach to this?
I do not think Wine is suitable for this purpose. Different approach:

 - cross compiling
 - Compile your program inside virtual machine or docker, i.e you run Linux on top of Windows and compile source code inside Linux.
 -  Run in seperate Linux.

And since database would definitely part of the ecosystem, say Postgresql, I'm guessing a Postgresql will add to the cost of the VPS, right?


I do not think VPS provider will charge  based on software you install. You will mostly be charged by CPU type, RAM and storage size and  bandwidth. So installing Postgresql will not incur additional cost. But to be sure, check VPS provider terms and conditions.
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Apache module executes Pascal program like scripting language https://zamronypj.github.io/mod_pascal/
Github https://github.com/zamronypj

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #5 on: July 17, 2021, 10:57:01 am »
Hey JeffP,

If you use fpcupdeluxe you can install the necessary libraries and binaries to cross compile into Linux.

I myself use it and I'm now cross compiling into Windows 32/64, Linux 32/64 and ARM 32(Raspberry Pie). I can also do some cross compiling into Arduino but with the constraints of an embedded system and not an app on top of an OS. And all this from an Ubuntu 21.04 64b.

So, in your DEV environment you can develop in Win32 with a PostgreSQL server and then you can ask me to set up your Linux VPS with all the code cross-compiled into Linux 64b.

Or you can ask me for pointers on how to manage a Linux server and you can install it all yourself. After all, the Ubuntu Server is not that hard to manage via SSH. But you do have to have a bit of knowledge in the command line for it to be managed.

If you want, and you get your code in a GIT repo, private or public, I would be willing to aid you on the cross-compiling tips.
Like I said, I have a Linux box that can mimic a Linux VPS and I can be your guinea pig, of sorts, of course :P

In terms of cost, both Ubuntu Server and PostgreSQL are open source and cost absolutely nothing. Just the trouble to install it and setting it up.

In terms of using wine: I wouldn't advise on this approach for a custom web server.

A friend of mine is developing a crypto currency using Indy10 as the Internet Package and from all the tests we've made, the app performs very badly under wine.
It runs for ever on Windows with no leaks, but somehow leaks like a sieve when ran under Wine. Don't ask me why cuz I haven't done a deep dive on the code to assert why such a big difference from Windows and Wine.

So you now have a dilemma, right?
  • Linux VPS are cheaper and most, if not all, of the software is free, but you have small to no expertize in managing a Linux Server.
  • Windows Server is more inside your knowledge and you can install, most of the times, the same free software with a bit more hassle but the price may be a bit too high.

Have a good think and have a look at other VPS providers, so you don't just have one option, and then ponder your next move!!

And make sure you also follow the advice @zamronypj gave about the type of VPS you're gonna invest.

Make sure it has at least 2GB Ram, 1 Virtual CPU and is not charged by the CPU usage, but instead it's charged on a flat monthly rate.
Also make sure that you either have unlimited bandwidth or, after some tests, you know how much it will use so you don't have extra charges due to the fact that the VPS has a bandwidth limit.
Sometimes a cheap option with limited bandwidth can come back and bite you in the arse because of exceeding your bandwidth quota.

So have a good think about it and I'll be around if you need it.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

jeffp

  • New Member
  • *
  • Posts: 15
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #6 on: July 17, 2021, 03:31:33 pm »

Or you can ask me for pointers on how to manage a Linux server and you can install it all yourself. After all, the Ubuntu Server is not that hard to manage via SSH. But you do have to have a bit of knowledge in the command line for it to be managed.

If you want, and you get your code in a GIT repo, private or public, I would be willing to aid you on the cross-compiling tips.
Like I said, I have a Linux box that can mimic a Linux VPS and I can be your guinea pig, of sorts, of course :P


You sir, just made me an offer that is hard to pass up. I'll be keeping that in mind, thank you. Meanwhile, I'll go put together that mORMot server app (you are welcome to comment here) I've been meaning to do. This may take a while, though. Lots of things to first try to learn.

Quote
So you now have a dilemma, right?
  • Linux VPS are cheaper and most, if not all, of the software is free, but you have small to no expertize in managing a Linux Server.
  • Windows Server is more inside your knowledge and you can install, most of the times, the same free software with a bit more hassle but the price may be a bit too high.

I have a wee bit of experience setting up some linux. One thing I haven't tried is to setup a database (Firebird and Postgres are my fav), open this port, close that one, and then listen for connections from the internet. And I have almost zero experience trying to secure it, aside from setting up password.

Thank you for those wonderful pieces of advice.

jeffp

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #7 on: July 17, 2021, 04:02:41 pm »
Web-Hosting: Usually deployed on a LAMP Stack(Linux/Apache/MySQL/PHP) and DigitalOcean, probably, has great prices for this. This will not work for a Lazarus/FPC web server

As long as the web hoster supports executing CGI binaries you can use FPC binaries there as well (obviously you need to compile for the correct platform and OS then and know which libraries the server provides). I used the same approach on a personal website in the past.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #8 on: July 18, 2021, 01:42:27 am »
Hey JeffP and PascalDragon,

You sir, just made me an offer that is hard to pass up. I'll be keeping that in mind, thank you. Meanwhile, I'll go put together that mORMot server app (you are welcome to comment here) I've been meaning to do. This may take a while, though. Lots of things to first try to learn.

Well, I'll be around for quite a while and whenever you feel that you need my help, just drop me a message from my profile. Those show up on my email and I'll answer you on a more private setting.

I have a wee bit of experience setting up some linux. One thing I haven't tried is to setup a database (Firebird and Postgres are my fav), open this port, close that one, and then listen for connections from the internet. And I have almost zero experience trying to secure it, aside from setting up password.

Well, to be honest you're what I consider a moderate DevOps. I'm not that advanced either but I guess that having tinkered with Linux since 1996 and finally choosing Linux has my OS of choice since 2010 I'm a bit more familiar with stuff. But AGAIN, I'm no expert and I've been spoiling myself with an Ubuntu Desktop that takes away a lot of the command line pain :)

Thank you for those wonderful pieces of advice.

No problem, that's what we're for!!

As long as the web hoster supports executing CGI binaries you can use FPC binaries there as well (obviously you need to compile for the correct platform and OS then and know which libraries the server provides). I used the same approach on a personal website in the past.

First of all, many thanks PascalDragon for mentioning the CGI aspect of things!! I must be loosing my faculties for leaving this one out, really sorry peeps!!

There's also, of course, the ability to make Apache 2.0 module, just like how the PHP language is run. I tried it once as a learning experiment and I was amazed at how easy it was, well, after you figure out what version of Apache you're targetting. That was the most pain, but after that was settled, it was a breeze. I'm also guessing that the process is now a lot smoother since my troubles with it were around 6 to 7 years ago.

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #9 on: July 18, 2021, 01:20:55 pm »
There's also, of course, the ability to make Apache 2.0 module, just like how the PHP language is run. I tried it once as a learning experiment and I was amazed at how easy it was, well, after you figure out what version of Apache you're targetting. That was the most pain, but after that was settled, it was a breeze. I'm also guessing that the process is now a lot smoother since my troubles with it were around 6 to 7 years ago.

An Apache module is obviously a nicer solution than a CGI one, though your typical web hoster won't allow you to install such while a CGI binary will usually just work. ;)

egsuh

  • Hero Member
  • *****
  • Posts: 1266
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #10 on: July 19, 2021, 01:05:02 am »
This is interesting as I have the same issue. Here in Korea, they do not allow uploading executable (CGI, etc.) on a shared server (just hosting some space on Hard Disk --- like 500 megabytes, etc.).

Another option is server-hosting, renting a whole server. This is actually like buying a server, and store it in data center. Windows is charged abolut $30 more per month. The costs vary much depending on speed, number of CPUs, etc.  But we can start from around $100~200 per month.

jeffp

  • New Member
  • *
  • Posts: 15
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #11 on: July 19, 2021, 05:50:02 am »
I think I'll try the VPS route.
  • On the VPS, install linux (I think its an option from the host)
  • Install my cross-compiled FPC app server
  • Install Postgresql, though optional
... and, what about the server? Do I need to install Apache or nginx, something like that?

Somebody please be kind enough to outline the requirements? Thank you.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #12 on: July 19, 2021, 06:40:40 am »
Somebody please be kind enough to outline the requirements? Thank you.

Depends a lot on what they offer you. If they just say: "OK, here is your 'machine', do what you will with it" (i.e. they give you an empty "machine"), then think of what you would have to install in a real machine, say, at your home, and do the same for the virtual one: install OS, install database server, install web server, install your app and you're (basically) done.

Otherwise, take what they give you (probably OS + web server + optional DB server) and complement it with what is lacking, which in this case would be just your app.

Oh! And remember to install, if they're not there, any tool you might need for the maintenance of the server: SSH (or similar) for easy access to the "machine", DB maintenance tools, etc. Though you can (presumably) just add them as you need them.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #13 on: July 19, 2021, 09:47:22 am »
Hey JeffP and all,

From my experience, limited I have to admit, this is what you have when you go the VPS route:
  • In the process of bying it you are asked for RAM, CPU and the Linux image you want
  • Minimum, from my research is 2Gb or RAM, 1 vCPU(virtual CPU) and Ubuntu 16.04(Rather ancient) or Ubuntu 18.04(Better but still ancient)
  • Once you decide that and the virtualization software install the image you have a working Ubuntu server that you can access via
    • A crappy VNC connection that is even possible in the browser
    • SSH into the box
  • This means that you have an entire Linux system to play with. It's no different than SSHing into a box sitting in your office.
  • You can now upgrade the system to Ubuntu 20.04 LTS (I've done this for https://nosoexplorer.yz317.com/)
  • Then you can install a Postgres server from the main Ubuntu repository and, if needed, an Apache server also.(Do you need an Apache instance with mORMot???)
  • If anything get's stuck, you have the web panel with all kinds of buttons, including forcing a reboot.
  • You can even change network stuff on the web panel. So the web panel will get you unstuck 99% of the times.
  • You can then either buy or use the scripts(Let's encrypt) to get an SSL certificate

As you can see, the only difference between a box you install next to you and the VPS is just distance and a Web Panel :)
Oh, and the fact that the server is virtualized on, probably, a blade server with a ton of RAM and about 36 cores or there abouts.

Ask me more about other details and I'll see if I can clear them out!!

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1090
  • Professional amateur ;-P
Re: Deploying a Lazarus web server in cloud web hosting
« Reply #14 on: July 19, 2021, 09:49:59 am »
Hey egsuh,

Another option is server-hosting, renting a whole server. This is actually like buying a server, and store it in data center. Windows is charged abolut $30 more per month. The costs vary much depending on speed, number of CPUs, etc.  But we can start from around $100~200 per month.

Are you sure your local providers don't have VPS offers?

It's now so wide spread that I find that difficult, even for Korea :) Darn, even any country less fortunate than Korea !!

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

 

TinyPortal © 2005-2018