ASP.NET Core Solution Template which works on Centos 7

Github Url: https://github.com/huseyindeniz/EnterpriseAppTemplateForDotNetCore

Test App Url: http://dotnetcore.huseyindeniz.net

Test App Notes:

  • running on Centos 7
  • code first with fluent api (with postgresql provider)

Development Notes

dot net core install on centos 7

  • yum install libunwind libicu
  • curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=835019 ( dotnet core 1.0)
  • mkdir -p /home/opt/dotnet
  • tar zxf dotnet.tar.gz -C /home/opt/dotnet
  • ln -s /home3/opt/dotnet/dotnet /usr/local/bin
  • curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?LinkID=836297
    (extract only 1.1.0 dir to /home/opt/dotnet/shared/Microsoft.NETCore.App, so you would get 1.0.3 and 1.1.0 at the same time)
  • to test if it is working
    • mkdir hwapp
    • cd hwapp
    • dotnet new
    • dotnet restore
    • dotnet run ( after this if you see hello world, it is working)

apache proxy conf

add this to apache conf

<VirtualHost yourappdomain:80>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/
ErrorLog /var/log/httpd/yourappname-error.log
CustomLog /var/log/httpd/yourappname-access.log common
</VirtualHost>

if you are using cpanel you need something like this

  • create dir /etc/apache2/conf.d/userdata/std/2_4/cpanelusername/yourdomainname
  • add proxy.conf file to this dir and add following lines to that file
    • ProxyPreserveHost On
      ProxyPass / http://127.0.0.1:5000/
      ProxyPassReverse / http://127.0.0.1:5000/
      ErrorLog /home3/log/dotnetcore-yourdomainname-error.log
      CustomLog /home3/log/dotnetcore-yourdomainname-access.log common
  • /scripts/ensure_vhost_includes –all-users
  • systemctl restart httpd

publish your app

  • in your mvc app right click an publish
  • copy publish dir to /home/patthoyourpublishdir/ in server

Create service for your app

  • create file as /etc/systemd/system/kestrel-yourdomainname.service and fill it with the following
    • [Unit]
      Description=Example .NET Web API Application running on CentOS 7[Service]
      ExecStart=/usr/local/bin/dotnet /home/patthoyourpublishdir/yourappname.dll
      WorkingDirectory=/home/patthoyourpublishdir/
      Restart=always
      RestartSec=10                                          # Restart service after 10 seconds if dotnet service crashes
      SyslogIdentifier=dotnet-example
      User=root or cpanel username
      Group=root or cpanel username
      Environment=ASPNETCORE_ENVIRONMENT=Production[Install]
      WantedBy=multi-user.target
  • systemctl enable kestrel-hdnet.service (if something goes wrong disable it)
  • systemctl start kestrel-hdnet.service
  • systemctl status kestrel-hdnet.service

and your dotnetcore mvc application should work.

I will add detailed documentation later.

ASP.NET Core, ASP.NET MVC, Genel kategorisine gönderildi

Bir Cevap Yazın