I: Cài đặt Apache

sudo apt-get update
sudo apt-get install apache2

Thiết lập firewall:

sudo ufw app list
sudo ufw allow ‘Apache’

Kiểm tra trạng thái:

sudo ufw status

Kiểm tra lại Web Server:

sudo systemctl status apache2

II. Adjusting Apache’s Configuration to Allow for .htaccess Overrides and Rewrites:

  1. Enabling .htaccess Overrides
  • write content to /etc/apache2/sites/sites-available/ladizone.co.conf:
    cd /etc/apache2/sites-available
    sudo nano bida69.conf
    -> Write content to ladizone.co.conf:
    ServerName sothuchi.site ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ProxyPass / ProxyPassReverse /
  • Allow Proxy:
    sudo a2enmod proxy
    sudo a2enmod proxy_http
    sudo a2enmod proxy_ajp
    sudo a2enmod proxy_balancer
    sudo a2enmod proxy_connect
    sudo a2enmod proxy_html
  1. Enabling the Rewrite Module:
    sudo a2enmod rewrite
  2. Enabling the Changes
    sudo apache2ctl configtest
    sudo a2ensite sothuchi.site

-> restart apache:
sudo systemctl restart apache2

III. Build container .NetCore App to Docker:

  1. Create Soluton .Netcore Project with Docker support for Linux.
  2. Create docker-compose.yml file into Project Root folder with content: version: ‘3’ networks: nvmanh-network: external: true services: misa.ladizone: image: ladizone container_name: ladizone_container restart: always networks:
    • nvmanh-network
    • ‘8001:80’
      context: .
      dockerfile: MISA.Ladizone.Web/Dockerfile
  3. DockerFile:
    FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
    WORKDIR /app
    EXPOSE 80
    EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
COPY [“MISA.Ladizone.Web/MISA.Ladizone.Web.csproj”, “MISA.Ladizone.Web/”]
COPY [“MISA.Ladizone.Infrastructure/MISA.Ladizone.Infrastructure.csproj”, “MISA.Ladizone.Infrastructure/”]
COPY [“MISA.Ladizone.Core/MISA.Ladizone.Core.csproj”, “MISA.Ladizone.Core/”]
RUN dotnet restore “MISA.Ladizone.Web/MISA.Ladizone.Web.csproj”
COPY . .
WORKDIR “/src/MISA.Ladizone.Web”
RUN dotnet build “MISA.Ladizone.Web.csproj” -c Release -o /app/build

FROM build AS publish
RUN dotnet publish “MISA.Ladizone.Web.csproj” -c Release -o /app/publish

FROM base AS final
COPY –from=publish /app/publish .
ENTRYPOINT [“dotnet”, “MISA.Ladizone.Web.dll”]

  1. Copy Solution Folder and build in Docker:
    Build Project in Docker
    sudo docker-compose build
    Up container:
    sudo docker-compose up
    Create network if not exit
    sudo docker network create nvmanh-network