goto https://github.com/dotnet/core/blob/master/release-notes/1.1/1.1.11/1.1.11-download.md and download sdk binaries (or runtime, if you want to build the client server locally and only copy fields)
we use the sdk here (if sdk complains about some `libunwind` is missing install then install `sudo apt-get install libunwind-dev`)
# i use chown to not need to sudo everything inside ClientServer e.g. install dependencies
sudo chown -R ahbxf ClientServer/
sudo chown -R [nutzer] ClientServer/
```
**make sure in `src/ClientServer/ClientServer.csproj`**
- the `RuntimeFrameworkVersion` is set to your installed version (1.1.11), you can see your installed version when going into `cd /opt/dotnet/shared/Microsoft.NETCore.App` and look for a folder with `X.X.X`
-`RuntimeIdentifiers` is set to `linux-x64` (for a list see https://docs.microsoft.com/de-de/dotnet/core/rid-catalog)
>1.1.12 is the dotnet sdk/cli version, 1.1.11 is the runtime version
```
# install dependencies
cd /opt/yapex/ClientServer
dotnet restore
```
**make sure in `src/ClientServer/ClientServer.csproj`**
- the `RuntimeFrameworkVersion` is set to your installed version (1.1.11), you can see your installed version when going into `cd /opt/dotnet/shared/Microsoft.NETCore.App` and look for a folder with `X.X.X`
-`RuntimeIdentifiers` is set to `debian.9-x64` (for a list see https://docs.microsoft.com/de-de/dotnet/core/rid-catalog)
if you changed something in ClientServer.csproj go back to `/opt/yapex/ClientServer` and run `dotnet restore` again!
after that you can build the client server
you can get an idea about the build process from the file `build/build.sh` it should contain something like
---
if you cahnged anything go back to `/opt/yapex/ClientServer` and run `dotnet restore` again!
**before** you build the server (dotnet publish) you should configure the client server... see section *configuring the client server* below
**for the first run** make sure in `appsettings.json`*IsDbBootstrapEnabled* is set to `true` else the db tables will no be created!
---
make sure in `/opt/yapex/ClientServer/src/ClientServer` only you (and the group) has access to the `appsettings.json` because there the db password is stored
```
cd /opt/yapex/ClientServer/src/ClientServer
chmod o-r appsettings.json
# dotnet publish copies this file with it's file permission
```
cd src/ClientServer
after that you can build the client server
you can get an idea about the build process from the file `/opt/yapex/ClientServer/src/ClientServer/build/build.sh` it should contain something like (run this in a terminal)
past the following into the file `runYapex.service`
...
...
@@ -226,7 +261,7 @@ SyslogIdentifier=dotnet-yapex
WantedBy=multi-user.target
```
make sure the file can be executed `chmod +x runYapex.service`
make sure the file can be executed `sudo chmod +x runYapex.service`
then run to reload the daemon because we created/changed a uni
...
...
@@ -234,18 +269,19 @@ then run to reload the daemon because we created/changed a uni
sudo systemctl daemon-reload
```
then you can `systemctl status unYapex.service` to get the status
`systemctl start unYapex.service` to start
`systemctl stop unYapex.service` to stop
`systemctl enable unYapex.service` to enable auto start when the server boots
`systemctl disable unYapex.service` to disable auto start when the server boots
then you can `systemctl status runYapex.service` to get the status
`systemctl start runYapex.service` to start
`systemctl stop runYapex.service` to stop
`systemctl enable runYapex.service` to enable auto start when the server boots
`systemctl disable runYapex.service` to disable auto start when the server boots
when you first start the server you might see `system settings not found, cannot run submissions scheduler.NextRun` in the logs
this is because the scheduler (which runs every X mins) tries to access the system settings (first row in table in the db) but we have no data yet
you can run `curl -i -X GET http://localhost:5000/api/init` to init the basic structure needed or import an old db dump
**on the first start** there are no data in the database. to fill in the default data open the browser at http://localhost:5000/api/init (some browsers display an json error, this can be ignored) OR run
`curl -i -X GET http://localhost:5000/api/init`
*this will only fill in the default data (first user, default group, default role, ...) when there are no (yapex) users in the database!*
cd /opt/yapex/ClientServer/src/ClientServer/output/ClientServer/wwwroot
rm -R nocopy
```
after this you can start (if it is not running) the client server and open the browser at http://localhost:5000/index_deploy.html (assuming you didn't change the port)
## test server
when the app is running (backend & frontend) you may need to change the test server settting (if you changed the port).
When you open http://localhost:5000 on the server you will see the yapex site then login with
the default admin login is
>id: j
>pw: j
and goto menu > system settings and change `Test server*` settings to match the port you want to use.
later we will setup nginx and use it as the webserver and run our site on port 8002 so we would need to set
## test server
start the client server and open http://localhost:5000/index_deploy.html and login
and goto menu > `system settings` and change `Test server (urls)` settings to match the port you want to use.
later we will setup nginx and use it as a (reverse proxy) webserver and run our site on port 8002 and the test server on port 8003 so we would need to set
-`Test server url` to `http://localhost:8003/api.php`
-`Submit test server url` to `http://localhost:8003/api.php`
-`Test server stats url` to `http://localhost:8003/api.php`
-`Test server stats url` to `http://localhost:8003/stats/`
-`Test server config ui url` to `http://localhost:8003` (should point to phpmyadmin to manage the test server settings)
### install mysql
(https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/ OR https://dbahire.com/how-to-install-mysql-server-on-debian-stretch/)
```
sudo apt-get install mysql-server
#then setup
sudo mysql_secure_installation
```
if some post processing fails you may need to first clear all running mysql processes with
```
...
...
@@ -372,8 +419,28 @@ sudo phpenmod mbstring
>Warning: When the prompt appears, “apache2” is highlighted, but not selected. If you do not hit SPACE to select Apache, the installer will not move the necessary files during installation. Hit SPACE, TAB, and then ENTER to select Apache.
then there should be a config for phpmyadmin in `/etc/apache2/conf-enabled/phpmyadmin.conf`
create a user called `yapex` you need to set the later in the `/opt/yapex/TestServer/config.json`
if not you probably no selected `apache2` in the configuration...
to rerun the configuration you can uninstall and reinstall phpmyadmin
```
sudo apt-get remove --purge phpmyadmin
sudo apt-get install phpmyadmin
```
you probably want to create a new user to manage the mysql database
```
sudo mysql --user=root mysql
#mysql>
CREATE USER '[DB user]'@'localhost' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON *.* TO '[DB user]'@'localhost' WITH GRANT OPTION;
then we need to edit the settings in `/opt/yapex/TestServer/config.json`
...
...
@@ -395,12 +462,12 @@ e.g.
"dbName":"yapexTestDb",
"dbUser":"yapex",
"dbPw":"[PW]",
"dbTableName":"plangs",
"dbPLangTableName":"plangs",
"dbTransactionTableName":"transactions",
"useConfigFromDb":true,
"dbConfigServer":"localhost",
"dbConfigName":"yapexTestDb",
"dbConfigUser":"yapex",
"dbConfigUser":"[DB user]",
"dbConfigPw":"[PW]",
"dbTableNameConfig":"config",
...
...
@@ -408,14 +475,30 @@ e.g.
}
```
the user `yapextester` is created via
```
sudo adduser yapextester
#pw: tester
```
you can read the `readme.md` for more information about the settings
now make sure only the correct users can access `/opt/yapex/TestServer/config.json`
```
sudo chmod o-r config.json
sudo chown yapextester config.json
#then try http://localhost:8003/config.json in thr browser should given 403 forbidden (because it has .json as file extension and we only forward .php)
```
then open phpmyadmin and create a new db e.g. `yapexTestDb`
then open phpmyadmin (http://localhost/phpmyadmin/) and create a new db e.g. `yapexTestDb`
you can create the tables as described in the `readme.md` in the test server or import the table from `TestServer/backup/*_server.sql`
the above config specifies that we use the table `config`over the local `config.json` file.
the above config specifies that we use the table `config`instead of the local `config.json` file.
You probably need to change the value for `environmentVars` to match your system/needs.
you will need to edit the table `config` and change `workingDirFullPath` to point the the dir used to run tests (the user files will be created there...)
...
...
@@ -437,7 +520,7 @@ then you only need to start a *server* in the directory `/opt/yapex/TestServer/`
you can also use the `DefaultTestRunnerFullThreaded` (https://gitlab.informatik.uni-halle.de/Syndrom/DefaultTestRunnerFullThreaded.git) but this is only for local testing because it does not run sandboxing commands
...
...
@@ -458,7 +541,7 @@ cd /opt/yapex/LinuxSafeTestRunner/src
javac -encoding "UTF-8" Main.java
```
output will be `.class files`
output will be `.class` files
then we can set this in the configuration of the `TestServer`
open the table `config` in the `yapexTestDb` and edit the column `runner`
...
...
@@ -488,10 +571,12 @@ then comment out all lines in `/etc/nginx/sites-available/default`
create a new entry for our site/app in `/etc/nginx/sites-enabled` (or in /etc/nginx/sites-available/ and then create a symlink)
```
sudo touch /etc/nginx/sites-enabled/yapex
sudo touch /etc/nginx/sites-available/yapex
ls /var/run/php/
# there should be a file phpX.Y-fpm.sock
```
and configure the site e.g.
and configure the site (at `/etc/nginx/sites-available/yapex`) e.g.
@@ -537,15 +628,28 @@ sudo systemctl status nginx.service
then you can open http://localhost:8002 and should see the yapex site (you can use e.g. a ssh tunnel for that)
To get the real user ip (e.g. for exams) we need to add the X-Forwarded-For header via nginx (because else we ould get 127.0.0.1 because nginx is our reverse proxy).
Open `/etc/nginx/nginx.conf` and add to the `http` section
```
...
proxy_set_header X-Forwarded-For $remote_addr;
...
```
this will replace or set the X-Forwarded-For with the real remote addr... (the user might spoof the address badly, see https://serverfault.com/questions/314574/nginx-real-ip-header-and-x-forwarded-for-seems-wrong [ngx_http_realip_module] to prevent this)
you can also check the test-server is running properly when you open `http://localhost:8003/[a test-server.php file]` in the browser e.g. `http://localhost:8003/index.php`
### we switch from apach2 to nginx as webserver for phpMyAdmin