Skip to content

LAMP Stack: Apache, MySQL, PHP (Ubuntu 22)

Alexander Elchlepp edited this page Aug 6, 2023 · 5 revisions

Install Packages

sudo apt install apache2

sudo apt install mysql-server

sudo apt install php8.1-fpm php8.1 libapache2-mod-php8.1 php8.1-common php8.1-mysql php8.1-xml php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-mbstring php8.1-opcache php8.1-zip php8.1-intl php8.1-bcmath unzip -y

sudo apt install composer

Remember the version of MySQL (will be needed later in the file .env)

sudo mysql -V

MySQL

Set a password for the root user

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'securepassword'

Logout from MySQL console and continue with the final setup

sudo mysql_secure_installation

Create the database for FewohBee

mysql -u root -p
CREATE DATABASE fewohbee CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

PHP

sudo nano /etc/php/8.1/apache2/php.ini

and adjust/enable settings according to this example: https://github.com/developeregrem/fewohbee-dockerized/blob/master/conf/php/conf.ini

Set the correct time zone of your location (e.g. "Europe/Berlin") (You can ignore the two lines for the session)

Setup FewohBee

cd /var/www/html
sudo git clone https://github.com/developeregrem/fewohbee.git && cd fewohbee
sudo cp .env.dist .env
sudo chown -R www-data:www-data /var/www/html/fewohbee/

Adjust settings in the .env file according to the docu from here: Configuration. Afterwards run the following commands:

sudo -u www-data composer install --no-dev --optimize-autoloader
sudo -u www-data php bin/console doctrine:migration:migrate
sudo -u www-data php bin/console app:first-run
sudo -u www-data php bin/console doctrine:fixtures:load --append
sudo -u www-data composer require symfony/apache-pack

Apache

Create a config file for FewohBee

sudo nano /etc/apache2/sites-available/fewohbee.conf

<VirtualHost *:80>
     ServerAdmin [email protected]
     ServerName domainname.com
     ServerAlias www.domainname.com

     DocumentRoot /var/www/html/fewohbee/public

     <Directory /var/www/html/fewohbee/public>
         Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 
 </VirtualHost>

Disable apache default landing page

sudo a2dissite 000-default

Enable FewohBee config

sudo a2ensite fewohbee.conf
sudo systemctl reload apache2

Done. You should be now ready to open the application via http://yourdomainname

Remark: This is a basic installation guide. When using FewohBee productively make sure to configure Apache using HTTPS!