How to host a web page that was made using Wt(C++ Web toolkit)? - c++

I have created a small project using Wt(C++ Web Toolkit). and I now want to host it.
Since there are very sparse resources for this, I read somewhere that LAMP is required for this(since I am using Linux). So after creating an Ubuntu instance at Digital Ocean, I installed my code in it with Apache2, MySql, and PHP. The Apache2 server is working, but it is used for hosting HTML/CSS/JS files. my web page is written entirely in C++.
I got directed to this website: https://www.webtoolkit.eu/wt/doc/reference/html/overview.html#wthttpd where it mentions "connectors" like libwthttp and libwtfcgi. I tried to install them using apt but I get this error: E: Unable to locate package libwtfcgi-dev (same for libwthttp).
The website mentioned above also does not provide clear steps for using these connectors.
I have also looked at other related answers : Host for Wt C++ web framework, deplowment issue but since I am new to web hosting, I would really appreciate a step-by-step guidance.
Even here: https://redmine.webtoolkit.eu/projects/wt/wiki/Fastcgi_on_apache The language is very unclear ast to where fastcgi.conf is located.

This answer assumes that you have the project running locally and just need to 'get it on the web'. You have a few options...
Reverse Proxy
From the tutorial it looks like there is a built in web-server. One option could be to use this, and then setup a reverse proxy (this can be done through Apache) to map traffic from yourwebsite.com to http://localhost:port, where port is whatever you started the web-server with.
The example they give to start the local webserver is:
$ g++ -std=c++14 -o hello hello.cc -lwthttp -lwt
$ ./hello --docroot . --http-address 0.0.0.0 --http-port 9090
here, port would be 9090.
Fast CGI
From the hello world and this thread it seems like a webserver setup with FastCGI may be able to do what you are looking for. Maybe this doc from Digital Ocean can help you get started?
It seems unlikely that you specifically need the full LAMP stack (Linux, Apache, MySQL, PHP) specifically for this. The doc you link does suggest that you need to link against the appropriate library for whichever approach you take, libhttpd or libwtfcgi, and you are correct that apt would be the place to get them on Ubuntu. This is a separate issue, but maybe this answer could be a starting point?

Is LAMP needed?
LAMP is definitely not required by Wt:
Linux is supported, but Windows too.
Apache could be used as a Reverse Proxy, but some alternatives may be even better (f.ex. HAProxy)
MySQL is supported, but also other database backends such as Postgres.
PHP/Perl/Python: not needed in any way.
Reverse proxy
Using a reverse proxy is a great way to deploy your Wt application (see eisaac's answer). If you already use Apache for other websites on your server. It's perfectly ok to use it as a reverse proxy. If you don't need all the features of Apache, using a HAProxy may be the better choice. See also some deployment configuration mentioned in the Wt docs:
https://redmine.emweb.be/projects/wt/wiki/Wt_Deployment
Easiest solution (but not scalable): let Wt directly listen on port 80 (or port 443)
If Wt is the only site running on your Ubuntu instance, you can also make it listen directly on port 80 (or port 443 in case of https):
./hello --docroot . --http-address 0.0.0.0 --http-port 80
See also the different command line options in the Wt doc: https://www.webtoolkit.eu/wt/doc/reference/html/overview.html#config_wthttpd

Related

How to configure Elastic IP with django app in aws?

I am building an app using django in EC2-ubuntu and i have associated Elastic ip with my instance.
i have done following steps :
1. first created instance of ubuntu in ec2 free tier.
2. installed python.
3. installed pip.
4. installed django.
5. create a django project using django-admin startproject.
6. run server using these commads python manage.py runserver 0.0.0.0:80
7. created an elastic ip and associated to the instance.
8. configure security inbound settings with http 0.0.0.0:80 address.
9. able to ping my project using any browser.
But the problem is when i am closing my putty session where i supplied runserver command, django project is also stopped. i did not stop it manually.
Please, help me to keep on running after closing putty session as well.
Thanks,
Kripa Sharma
Take a look at this Answer
I highly recommend that you start using Elastic Beanstalk (Python instance) to take care of all these steps for you. Very simple to setup, and no need to worry about any of the steps you listed.
You can use this instruction to see how you can deploy a Django app in less than 5 minutes.
The problem
You are trying to persist the debug server for a remotely deployed application.
You probably need to review the runserver command documentation. Here are the relevant parts:
django-admin runserver [addrport]
Starts a lightweight development Web server on the local machine. By default, the server runs on port 8000 on the IP address 127.0.0.1. You can pass in an IP address and port number explicitly.
...
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)
A webserver
Having skimmed the above docs, you may want to look at "How to deploy with WSGI" section, which gives a few recommendations for commonly used Web servers. My favorite, Gunicorn, includes a usage example:
$ pip install gunicorn
$ gunicorn myproject.wsgi
Having decided, and installed a webserver, you'd need to "daemonize" it and expose it to the world.
The former is usually done by creating a service on your OS, for ubuntu it would be either upstart or systemd depending on the version. Gunicorn docs have examples for both.
The latter is usually achieved with an http-server/proxy such as nginx or apache httpd. And again, Gunicorn has an example for us.
You can see why I like it so much ☺️
Epilogue
While technically possible to run the debug server as a service or even in a terminal multiplexer such as GNU screen or tmux, it's not a recommended or stable long term solution.
That said, these are very useful to know about, so read on the above tools and learn to use them, since they would be invaluable to have in your toolset in the future, for example to avoid accidentally terminating a long running command (such as migration), etc.

We couldn't find a server running on this port – are you sure there is a server running? Ruby on Rails at Nitrous.IO

Hi I am complete new to web technologies. I am learning Ruby on rails right now. I am using service from www.nitrous.io. The problem is when I tried to view my work I always get following error:
We couldn't find a server running on this port – are you sure there is
a server running? Make sure to bind your server to host 0.0.0.0
(instead of localhost/127.0.0.1).
Please refer to this support article for more details.
I tried all the ports 3000, 4000, 8080 and it still didn't worked. If some expert can pin point the problem it would be great.
try this command:
rails s -b 0.0.0.0
This might seem obvious, but just in case: you need to actually start your Rails server in the Nitrous console before you hit the preview tab. Type:
rails s
You can have multiple consoles open (just click the + tab), so you'll often have the server running in one console and the other open for typing commands.
I highly recommend you carefully follow this guide through to get up and running. Read it all and read it again if you're not sure what you did. Good luck!
http://guides.rubyonrails.org/getting_started.html
Just use rails s -b 0.0.0.0 and ensure you are in the application directory when tuning Rails.

SVN repo What is difference between http://server/ ... / and svn://server/ .. /

I'm new in Linux world and recently start messing around with ubuntu server. For week or so I was able to understand the basics and now I'm shooting for more difficult tasks like setting up web server, ssh and SVN.
The question is: how to set url to be visible like svn://......../....
I found this and the book http://svnbook.red-bean.com/en/1.7/svn.serverconfig.svnserve.html perhaps i'm not doing something right:
svnserve as daemon
The easiest option is to run svnserve as a standalone “daemon” process. Use the -d option for this:
$ svnserve -d
$
# svnserve is now running, listening on port 3690
When tape this line and restart the service apache2 nothing changes. And I'm not sure is this the way to make it.
When tape this line and restart the service apache2 nothing changes
Apache in any way does not related to handling svn:// protocol
Quote from referenced by you page of SVN Book
Once we successfully start svnserve as explained previously, it makes
every repository on your system available to the network. A client
needs to specify an absolute path in the repository URL. For example,
if a repository is located at /var/svn/project1, a client would reach
it via svn://host.example.com/var/svn/project1.
(Bolded parts is important)

deploy bitnami django

I am quite computer-illiterate, but I have managed to utilize the Django framework on my own machine. I have had an account on Amazon Web Service (AWS) for some time, but it appeared rather complex to set-up and to make use of, so I put it of for a while. Then I decided to give it a try, and it was not so hard as I first thought to load a AMI and connect to the server with PuTTY. But since I were already using BitNami's Django-Stack, I decided to take a look at their hosting offer (which builds on AWS). Since they appeared to offer "one-click deployment", I set up a new server through their interface. But then, it seems like the "one-click deployment"-promise is with regard to the server itself. There does not seem to be any interface for deploying Django projects through their site. Having used PuTTY already, and adding WinSCP to my machine, I can acceess the server and load my Django-code unto the server. But then I am lost. The documentation seems a bit thin (look here).
The crux of this is the following: Can anyone make this part of the process more understandable. I.e., how to deploy a Django project on a Linux server with Apache/mod_WSGI?
The other question is: I want to use Postgres. Am I free to install this on the server. Should I opt for EBM (EMB?) for this, or what is the downside of not having EBM?
I hope I am not too unworthy of your attention, thanks!
how to deploy a Django project on a Linux server with Apache/mod_WSGI The Bitnami AMI already comes with all this configured. Once installed try going to the EC2 public url on the default 8000 port and you will see the demo django project setup there. You can add your own project once you have logged into the machine via putty check the /home/bitnami/ directory for the demo project. Copy your project, configure your database The other question is: I want to use Postgres. Am I free to install this on the server Postgres and Mysql are already installed the same way you would do on your local machine. The in your project do ./manage.py runserver 0.0.0.0:9000 since the 8000 port is already running another application.

Jetty: Mount to a directory on a different host

I'm looking to map to a directory on a different host using Jetty/Maven when working locally. I've found you can do this w/ Apache using mod_jk (JkMount/JkUnMount), but haven't figured it how to do the same on jetty.
On our dev/q/live servers, we have Apache in front of JBoss and use mod_jk to do this. Locally, we're using jetty
To give you an idea of what I'm talking about, this is how you would configure Apache to accomplish this:
in httpd.conf:
JkMount /images/* host2
JkMount /* host2
JkUnMount /images/* host1
workers.properties:
worker.list=host2,host1
worker.host2.host=host-2.theDomain.com
worker.host2.port=46654
worker.host1.host=host-1.theDomain.com
worker.host1.port=46655
Is there a way to configure Jetty to do the same thing?
Btw, locally, I'm using the Maven plugin for Eclipse if that makes a difference.
thanks!
Update:
I tried going a different route here and just added a folder, then Advanced > Link to a folder in the file system and I pointed to a file on the remote server (I believe we use WebDav). The files show up in project explorer, but they aren't served. I'm going to try setting org.mortbay.util.FileResource.checkAliases to true as specified here:
http://docs.codehaus.org/display/JETTY/How+to+enable+serving+aliased+files
...will let you know if that takes care of it.
Are you using the Spring Framework? If so, another solution here is to use tuckey urlrewrite. You can test for your local domain and only run the rules there.
http://www.tuckey.org/urlrewrite/manual/3.0/introduction.html