System recovery and environment setup - grzegorzsobocinski2397/wsei-projektowanie-profesjonalnej-aplikacji Wiki

Clean-up process

  1. Remove hosting directories of the back-end and front-end.
  2. Back-up and remove database.
  3. Remove hosting services (e.g. IIS website)

Environment setup

Windows environment

  1. Install Internet Information Services (IIS) on the server machine.
  2. Install URL rewrite module for IIS.

Linux environment

  1. Install nginx by running dnf install -y nginx command.

Back-end setup

  1. Install php
  2. Install composer
  3. In the console, run composer install.
  4. To start the application run the sail service with the command ./vendor/bin/sail up -d

Database setup

  1. When you have the sail service running, all you need to do is run the migration - ./vendor/bin/sail artisan migrate

Front-end setup

  1. Download and install NodeJS LTS.
  2. Open command line in .\PPA-WSEI\ppa-wsei-front directory.
  3. Run npm install.
  4. Run npm run build.
  5. Build files are available in the ./dist/ppa-wsei-front directory.

IIS

  1. Create new website for front-end part.
  2. Copy the output of the ./dist/ppa-wsei-front directory to your hosted directory.
  3. Add web.config file for the routing.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
  <rewrite>
    <rules>
      <rule name="Angular Routes" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAll">
          <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
        <action type="Rewrite" url="./index.html" />
      </rule>
    </rules>
  </rewrite>
  </system.webServer>
</configuration>
  1. Front-end application should be available on the given port.

nginx

  1. Copy the output of the ./dist/ppa-wsei-front directory to your hosted directory.
  2. Make sure nginx user has read permission to read the directory. Use chmod and/or chown if necessary on the final destination.
  3. Create a config in /etc/nginx/conf.d/. For example: /etc/nginx/conf.d/mysite.conf. The most important part for Angular in particular is to include the try_files line which will ensure that even if someone visits a URL directly, the server will rewrite it properly so the Angular app behaves properly.
# /etc/nginx/conf.d/mysife.conf

server {
  listen 0.0.0.0:80;
  root /srv/mysite;
  location / {
    try_files $uri $uri/ /index.html;
  }
}