Blocksy

Host API in Apache Linux

In this section we describe in general terms the steps for hosting the GIST Web API on Apache Linux.
Especially those related to the settings in the GSIT Web API.
We have used Ubuntu version 18.04 .
The folder and application name is crm, and the name of the web site is www.crm.id.
This will need to be customized for your own application.

  1. Meng-compile file crm project (kami masih menggunakan windows untuk bekerja dengan visual studio dan compile file)
    Gunakan perintah ini di DOS commant Prompt:
    >cd C:\GSIT-LEARN\Backend\crm <tekan enter>
    >dotnet publish --self-contained -c Release -r linux-x64 <tekan enter>
  2. Meletakkan file-file publish ke dalam folder di linux, copy ke ke folder /var/www/crm/publish
  3. nano /etc/systemd/system/crm.service
    Write a configuration like this in that file:

    [Service]
    WorkingDirectory=/var/www/crm/publish
    ExecStart=/usr/bin/dotnet /var/www/crm/publish/crm.dll
    Restart=always
    Restart service after 10 seconds if the dotnet service crashes:
    RestartSec=10
    KillSignal=SIGINT
    SyslogIdentifier=dotnet-example
    User=root
    Environment=ASPNETCORE_ENVIRONMENT=Production
    Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
    [Install]
    WantedBy=multi-user.target
  4. Enable Service
    sudo systemctl enable crm.service
  5. Start Service
    sudo systemctl stop crm.service
  6. Create Apache website configuration
    sudo nano /etc/apache2/sites-available/crm.conf
    Write a configuration like this in that file:
    <VirtualHost *:80>
    ServerName crm.id
    ServerAlias www.crm.id
    ProxyPreserveHost On
    ProxyPass "/" "http://localhost:5000/"
    ProxyPassReverse "/" "http://localhost:5000/"
    ErrorLog /var/log/apache2/apptrinil-error.log
    CustomLog /var/log/apache2/apptrinil-access.log common
    </VirtualHost>
  7. Match the proxyPass port settings with appsetting.json in the CRM visual studio project.
    port proxy is 5000.
    ProxyPass "/" "http://localhost:5000/"
    paramater and value in appsetting.json :
    "Urls": "http://localhost:5000",
    see section Change Value in appsettings.json.
  8. run the following commands,
    sudo ln -sf /etc/apache2/sites-available/crm.conf /etc/apache2/sites-enabled/crm.conf
    sudo a2ensite crm.conf
    sudo systemctl restart apache2.service
  9. Everything is ready to be tested using Postman