# Antragsgruen

# Preparation

## Database

Install MySQL
```
sudo apt install mysql-server -y
sudo systemctl enable mysql
sudo systemctl start mysql
```
Setup the installation with ``sudo mysql_secure_installation`` and choose:
- VALIDATE PASSWORD component: Y
- Password Validation Policy: 3
- Remove anonymous users?: Y
- Disallow root login remotely?: Y
- Remove test database and access to it?: Y
- Reload privilege tables now?: Y

Enter MySQL with ``sudo mysql -u root -p`` and create Database and user:
```
CREATE DATABASE antragsgruen;
CREATE USER '<my_user>'@'localhost' IDENTIFIED BY '<my_password>';
GRANT ALL PRIVILEGES ON antragsgruen.* TO '<my_user>'@'localhost';
FLUSH PRIVILEGES;
Exit
```
## PHP8.4

Add PHP8.4 Repository and install it:
```
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php8.4 php8.4-cli php8.4-fpm php8.4-intl php8.4-gd php8.4-mysql php8.4-opcache php8.4-curl php8.4-xml php8.4-mbstring php8.4-zip php8.4-iconv
```

## Apache2

Install Apache2:
```
sudo apt install apache2
```
Change the default apache2 site (``/etc/apache2/sites-available/000-default.conf``) to:
```
RewriteEngine On

<Directory /var/www/antragsgruen/web>
    AllowOverride all
    Require all granted
</Directory>

<VirtualHost *:80>
    DocumentRoot /var/www/antragsgruen/web
    ServerName antragsgruen.example.org

    # Other directives here
</VirtualHost>
```
Enable the RewriteEngine and restart Apache2:
```
sudo a2enmod rewrite && sudo service apache2 restart
```

# Nodejs 20 & npm

Download ans execute the NodeSource setup script:
```
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
```
Install Node.js and npm:
```
sudo apt-get install -y nodejs
```

# Install

Install the sources and dependencies from the repository:
```
sudo git clone https://github.com/CatoTH/antragsgruen.git
sudo chmod 777 antragsgruen
cd antragsgruen
curl -sS https://getcomposer.org/installer | php
./composer.phar install --prefer-dist
npm install
npm run build
```
To enable the web-based installer:
```
touch config/INSTALLING
```
Set the permissions:
```
sudo chown -R www-data:www-data web/assets
sudo chown -R www-data:www-data runtime
sudo chown -R www-data:www-data config
```

# Sources
- [MySQL Guide](https://docs.vultr.com/how-to-install-mysql-on-ubuntu-24-04)
- [PHP 8.4](https://www.tecmint.com/install-php-ubuntu-24-04)
- [Nodejs 20 & npm](https://zahiralam.com/blog/installing-node-js-20-x-on-ubuntu-24-04-lts-a-comprehensive-guide/)
- [Antragsgruen](https://github.com/CatoTH/antragsgruen)