Publishing interpreted languages like PHP, Ruby, and Python is less difficult than publishing compiled languages. In general, you can broadcast on ready-made shared servers with no additional settings. However, if you want to publish compiled languages like C, C++, Golang, Haskell, or Rust, you'll need at least a VPS server because it's difficult to do these things without root access via ssh. Despite the fact that there are other options, it will be highly expensive.
You understand the significance of performance because you are developing a web service in a compiled language. The languages with the best backend performance in this field are C++, Rust, and Golang, in that order.
You can set up the web service you created with a programming language on your server by following the steps below:
Your binary output should now be uploaded to your server. For example, you can use scp
to upload files to your server.
To launch the binary on the server, use the binary's path and parameters from the command line. For instance, ./web-server --port 5689
While the web service is running, the server should not be shut down. As a result, you may need to create a daemon to resume the web service automatically.
To make a daemon, follow the instructions below:
Make a configuration file for the service. /etc/systemd/system/web-server.service
, for example.
Fill up the blanks with the following information.
[Unit]
Description=WebServer
[Service]
ExecStart=/path/to/web-server --port 5689
restart=always
User=yourusername
[Install]
WantedBy=multi-user.target
Register the service in the system: sudo systemctl enable web-server
Start the service: sudo systemctl start web-server
When the system is switched on, the daemon you construct with these processes will run automatically, and if the server is shut off, it will automatically start the web service when it is turned back on. You can then utilize the online service without interruption. If a problem occurs on the server, the daemon will restart the web service automatically.
You will also need to use a reverse proxy to connect this local address and port to your domain. This will be addressed in another article.