Giter Site home page Giter Site logo

Comments (3)

smjxpro avatar smjxpro commented on August 23, 2024 15

Here's how you can deploy your get_server or any Dart server-side app on Ubuntu VPS:

Create, Compile and Run Your Project On The Local Machine

  1. Install the Dart SDK on your local machine by following the official docs here: https://dart.dev/get-dart
  2. Create your project: dart create your_project_name
  3. Compile your project in native binary using: dart compile exe bin/your_project_name.dart and you should get a file with .exe extension (your_project_name.exe)
  4. Confirm that your app is running by: ./your_project_name.exe and visiting http://localhost:8080

If everything is ok, then move on to the next part.

On The VPS

  1. Upload the exe file to your VPS. Let's say on /home/user/projects directory.
  2. Optionally you can confirm that it's also working on your server by running ./your_project_name.exe and visiting http://your_vps_ip:8080*

Configure systemd Service

  1. Create a systemd service by sudo nano /etc/systemd/system/your_project_name.service and pasting the following:
[Unit]
Description=My Dart Server App

[Service]
User=user
WorkingDirectory=/home/user/projects
ExecStart=/home/user/projects/your_project_name.exe
Restart=always

[Install]
WantedBy=multi-user.target
  1. Enable the service: sudo systemctl enable your_project_name
  2. Restart systemd daemon: sudo systemctl daemon-reload
  3. Start the service: sudo service your_project_name start
  4. Check if everything is ok and your service is running properly: sudo service your_project_name status

Configure nginx Server Block and Proxy Pass

  1. Create a nginx server block by sudo nano /etc/nginx/sites-available/your_project_name.conf and pasting the following:
server {
  listen 80;
  server_name your_domain_name;
  root /home/user/projects;

  location / {
    try_files $uri @proxy;
  }

  location @proxy {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
  }
}

  1. Enable the server block: sudo ln -s /etc/nginx/sites-available/your_project_name.conf /etc/nginx/sites-enabled/your_project_name.conf
  2. Test your nginx configuration: sudo nginx -t
  3. Restart nginx: sudo service nginx reload

That's it! Now you can visit your_domain_name to see your shiny new get_server dart app in full effect on the web.
Additionally, you can secure your app using Let's Encrypt SSL using certbot: sudo certbot -d your_domain

Here's the live example: http://getxserver.smj.xyz/
And here's the example repo: https://github.com/smjxpro/get_server_boot

  • You may need to change the file permission(sudo chmod 777 your_project_name.exe) and disable firewall or open port 8080.

from get_server.

jonataslaw avatar jonataslaw commented on August 23, 2024 7

Here's how you can deploy your get_server or any Dart server-side app on Ubuntu VPS:

Create, Compile and Run Your Project On The Local Machine

  1. Install the Dart SDK on your local machine by following the official docs here: https://dart.dev/get-dart
  2. Create your project: dart create your_project_name
  3. Compile your project in native binary using: dart compile exe bin/your_project_name.dart and you should get a file with .exe extension (your_project_name.exe)
  4. Confirm that your app is running by: ./your_project_name.exe and visiting http://localhost:8080

If everything is ok, then move on to the next part.

On The VPS

  1. Upload the exe file to your VPS. Let's say on /home/user/projects directory.
  2. Optionally you can confirm that it's also working on your server by running ./your_project_name.exe and visiting http://your_vps_ip:8080*

Configure systemd Service

  1. Create a systemd service by sudo nano /etc/systemd/system/your_project_name.service and pasting the following:
[Unit]
Description=My Dart Server App

[Service]
User=user
WorkingDirectory=/home/user/projects
ExecStart=/home/user/projects/your_project_name.exe
Restart=always

[Install]
WantedBy=multi-user.target
  1. Enable the service: sudo systemctl enable your_project_name
  2. Restart systemd daemon: sudo systemctl daemon-reload
  3. Start the service: sudo service your_project_name start
  4. Check if everything is ok and your service is running properly: sudo service your_project_name status

Configure nginx Server Block and Proxy Pass

  1. Create a nginx server block by sudo nano /etc/nginx/sites-available/your_project_name.conf and pasting the following:
server {
  listen 80;
  server_name your_domain_name;
  root /home/user/projects;

  location / {
    try_files $uri @proxy;
  }

  location @proxy {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
  }
}
  1. Enable the server block: sudo ln -s /etc/nginx/sites-available/your_project_name.conf /etc/nginx/sites-enabled/your_project_name.conf
  2. Test your nginx configuration: sudo nginx -t
  3. Restart nginx: sudo service nginx reload

That's it! Now you can visit your_domain_name to see your shiny new get_server dart app in full effect on the web.
Additionally, you can secure your app using Let's Encrypt SSL using certbot: sudo certbot -d your_domain

Here's the live example: http://getxserver.smj.xyz/
And here's the example repo: https://github.com/smjxpro/get_server_boot

  • You may need to change the file permission(sudo chmod 777 your_project_name.exe) and disable firewall or open port 8080.

Nice tutorial <3

from get_server.

voipworld avatar voipworld commented on August 23, 2024

very nice tuto!

from get_server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.