Nette multisite codebase for the Fyziklani and Online Physics Brawl competitions.
This project uses modified bootstrap file to support multiple websites sharing components and models.
PHP 8.1
Apache
withmod_rewrite
- sql database
As a convenience for podman
based setups, you can use just
command runner for your development environment. For docker
see below. All
commands are documented by running just
in this directory.
If you want to speedrun the setup, here is a tasklist:
- Install
just
andpodman
- Configure your FKSDB login with
just login
(this may break with'
in password) - Download deps via
just setup
- When developing, start with
just dev
- End your session using
just stop
To use docker
instead of podman
, instead of just cmd
write just runner=docker cmd
.
This is untested, so contact @rkuklik if you run into issues.
To access the websites (after running just dev
), following links can be used:
- Clone the repository
git clone --recurse-submodules ...
- Configure the web server (see below for example configuration)
- Create a configuration files and fill all the necessary information
cp app/config/config.local.neon.example app/config/config.fof.local.neon
cp app/config/config.local.neon.example app/config/config.fol.local.neon
cp app/config/config.local.neon.example app/config/config.dsef.local.neon
- Follow the build instructions
Following configuration expects repository located in /var/www/fykos-webs
.
<Directory /var/www/fykos-webs>
AllowOverride All
Require all granted
</Directory>
<VirtualHost online.fyziklani.cz.local online.fyziklani.org.local>
ServerName online.fyziklani.cz.local
ServerAlias online.fyziklani.org.local
DocumentRoot /var/www/fykos-webs/www/fol
SetEnv NETTE_DEVEL 1
</VirtualHost>
<VirtualHost fyziklani.cz.local fyziklani.org.local>
ServerName fyziklani.cz.local
ServerAlias fyziklani.org.local
DocumentRoot /var/www/fykos-webs/www/fof
SetEnv NETTE_DEVEL 1
</VirtualHost>
<VirtualHost dsef.cz.local dsef.org.local>
ServerName dsef.cz.local
ServerAlias dsef.org.local
DocumentRoot /var/www/fykos-webs/www/dsef
SetEnv NETTE_DEVEL 1
</VirtualHost>
<VirtualHost fykos.cz.local fykos.org.local>
ServerName fykos.cz.local
ServerAlias fykos.org.local
DocumentRoot /var/www/fykos-webs/www/fykos
SetEnv NETTE_DEVEL 1
</VirtualHost>
Do not forget to modify your /etc/hosts
file to point to the correct IP address of your server.
127.0.0.1 online.fyziklani.cz.local
127.0.0.1 online.fyziklani.org.local
127.0.0.1 fyziklani.cz.local
127.0.0.1 fyziklani.org.local
127.0.0.1 dsef.cz.local
127.0.0.1 dsef.org.local
127.0.0.1 fykos.cz.local
127.0.0.1 fykos.org.local
These domains need to be configured in app/config/config.*.local.neon
under parameters.domains
in order to work.
You need composer
and npm
with node
to build this project.
- Run
composer install
to install php dependencies. - Run
npm install
to install javascript dependencies and build tools. - Run
npm run build
to compile css and js files.
You can use npm run dev
to automatically rebuild files when they are changed.
Installing Prerequisites
- open wsl
- if not installed, install
apache2
(sudo apt install apache2
) - if not installed, install
php8.1
(sudo apt install php8.1
, you might also needphp8.1-dom
andphp8.1-soap
) - if not installed, install
mysql
(google how to do that - e.g. viasudo apt install mysql-server
) - if not installed, install
composer
(google how to do that - sudo apt install composer does not work as of July 2022) - if not installed, install
node
, version at least 16. Alternatively, install nvm and thennvm use 16
- if not installed, install
gettext
(viasudo apt install gettext
), checklocale -a
if you havecs_CZ
anden_US
installed, otherwise usesudo locale-gen cs_CZ
,sudo locale-gen cs_CZ.UTF-8
and thensudo update-locale
- pull this repository to a location where you want to have it (e.g.
cd C:/data/fykos && git pull <repourl>
)
- Note: you may encounter various problems, e.g. php not being executed (try
sudo apt install libapache2-mod-php
andsudo a2enmod php8.1
) or with "ERROR: Module mpm_event is enabled" (trysudo a2dismod mpm_event
andsudo a2enmod mpm_prefork
, and thensudo service apache2 restart
)
Configuring Apache
- Explanation: the webserver reads all files from
sites-enabled
and loads the configuration from them. Other files in these directories are symlinks which point to files insites-available
(handy for turning off the page by deleting the symlink without deleting the actual configuration)
- open wsl
- create a new file
sudo nano /etc/apache2/sites-enabled/fykos-webs.conf
- paste the example apache configuration (above) into this file
- change the Directory and all DocumentRoots to be where you have downloaded your repo (e.g.
<Directory /mnt/c/data/fykos/webs>
andDocumentRoot /mnt/c/data/fykos/webs/www/fol
) - save it
Configuring hosts file
- Explanation: Since wsl has its own IP adress, and we use a browser over on Windows, we need to configure Windows's DNS to route us over to wsl.
- open the file
C:/Windows/System32/drivers/etc/hosts
as administrator - paste the example contents of
/etc/hosts
and save - open wsl and type
ip a
and find out the IP adress of WSL (usually something like eth0: ... inet 172.22.207.240/20 ...) - replace all occurrences of
127.0.0.1
inC:/Windows/System32/drivers/etc/hosts
with the found IP (e.g.172.22.207.240
) - Sadly, steps 3 and 4 need to be repeated everytime wsl gets restarted, because a new IP is generated every time.
Configuring MySql
- Explanation: some parts of the web need an access to a database to work.
- open wsl
- start mysql (
sudo mysql
). You may encounter errors, in which case google how to solve them. - you are now in mysql shell (the line starts with
mysql>
). - Create databases for FOL and FOF: (a)
create database fol ;
(b)create database fof ;
- Create user with a password, e.g.:
CREATE USER 'fykos'@'localhost' IDENTIFIED BY 'password';
- Set privileges for the newly created user: (a)
GRANT ALL PRIVILEGES ON fol.* TO 'fykos'@'localhost' WITH GRANT OPTION;
(b) same, only with fof - Close mysql by ctrl+D
Inserting tables and data
- Explanation: In FOL, we the database also needs to have some tables and preferably dummy data.
- open wsl terminal and
sudo mysql
- type
use fol
(tells mysql to modify thefol
database) - copy and paste the contents of the file
data/sql/schema_fol.sql
into mysql shell and press Enter (creates tables) - copy and paste the contents of the file
data/sql/example_fol.sql
into mysql shell and press Enter (inserts data)
Configuring neon files
- Explanation: these files contain secret data such as passwords and connection strings. It is something like appsettings.json. These data are then used in the application to connect to various resources, such as the database.
.local
files always override the configurations from files without the.local
. We only edit the.local
files, which are intentionally excluded from git.
- tell somebody to send you at least the
fksdbDownloader
credentials and fill them out - fill out the database name in the connection strings (e.g.
dsn: 'mysql:host=localhost;dbname=fof'
) - fill out the
parameters.database
section with the credentials that you've used in MySql (user: fykos
,password: password
) - set gameApiURL to an empty string:
gameApiURL: ''
- "could not find driver" ... if this error is shown
Nette\Database\ConnectionException could not find driver Caused by PDOException
, it is likely because you do not have something installed, see https://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver