LoRa

Raspberry Pi LAMP Stack

The “LAMP” stack is a group of open-source software (Apache, MariaDB and PHP) that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP or Python on Debian Linux.

LAMP to support simple web interface and restful API. This is not an in-depth step by step process. There are other sites with detailed instructions. Google  will help, these this are my notes as how I have successfully installed.

So first install the base packages;

#sudo apt install apache2 -y
#sudo apt install php -y
#sudo service apache2 restart
#sudo apt install mariadb-server php-mysql -y

Then setup MariaDB;

#sudo mysql_secure_installation

setup DB user as root can’t login root. Use admin;

sudo mysql --user=root —password
>create user admin@localhost identified by 'your_password';
>grant all privileges on *.* to admin@localhost;
>FLUSH PRIVILEGES;
>exit;

continue installing phpmyadmin to administer the database;

#sudo apt install phpmyadmin -y
#sudo phpenmod mysqli

There are comparability issues with phpmyadmin and PHP 7.2. The version in the Debian archives is not as current as it could be. Not a big concern. Google the errors returned and with a couple of quick updates it runs as expected.

Ok now setup Apache to support API.

Create .htaccess in /var/www

RewriteOptions inherit
DirectoryIndex index.php
php_flag log_errors On
php_value error_log /tmp/API.log

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/(.*)$ api/api.php?request=$1 [QSA,NC,L]
RewriteRule (recipe/.*) api/app.php?request=$1 [QSA,NC,L]
</IfModule>

then update 000-default.conf in /etc/apache2/sites-available with the following;

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

reload apache and away you go.

Tags :