RecipeApp
Recipe App
1. Install Packages
sudo apt update sudo apt install apache2 sqlite3 libsqlite3-dev libapache2-mod-php php-sqlite3
If your Apache uses a specific PHP version, install SQLite for that version. Check Apache PHP:
apachectl -M | grep -i php ls -la /etc/apache2/mods-enabled/php*.load
Example: if Apache uses PHP 8.1:
sudo apt install php8.1-sqlite3 sudo phpenmod -v 8.1 -s apache2 pdo_sqlite sqlite3 sudo systemctl restart apache2
Verify SQLite support:
php -m | grep -i sqlite ls -la /etc/php/*/apache2/conf.d/ | grep sqlite
You should see:
pdo_sqlite sqlite3
2. Copy App Files Example location:3. Set Permissions Apache must write to SQLite and image upload folders:
cd /var/www/html/11square sudo mkdir -p data uploads/recipes sudo chown -R www-data:www-data data uploads sudo chmod -R 775 data uploads
Do not make the whole app writable unless needed. Only data/ and uploads/ need write access. 4. Apache Virtual Host Create a site config:
sudo nano /etc/apache2/sites-available/mysite.conf
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/html/mysite
<Directory /var/www/html/mysite>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined
</VirtualHost>
Enable the site:
sudo a2ensite mysite.conf sudo a2enmod rewrite sudo apachectl configtest sudo systemctl restart apache2
If config test says Syntax OK, Apache is good. 5. Test App From Server From the app folder: '
cd /var/www/html/mysite php -l index.php php -l lib/Database.php
7. Optional HTTPS
Install Certbot:
sudo apt install certbot python3-certbot-apache
Issue certificate:
sudo certbot --apache -d mysite.com -d www.mysite.com
Then test:
sudo apachectl configtest sudo systemctl restart apache2
8. Common Troubleshooting Check Apache/PHP errors:
sudo tail -n 100 /var/log/apache2/mysite-error.log sudo tail -n 100 /var/log/apache2/error.log
Watch live while refreshing the browser:
sudo tail -f /var/log/apache2/mysite-error.log
If you see:
PDOException: could not find driver Install SQLite for Apache’s active PHP version:
ls -la /etc/apache2/mods-enabled/php*.load sudo apt install php8.1-sqlite3 sudo phpenmod -v 8.1 -s apache2 pdo_sqlite sqlite3 sudo systemctl restart apache2
If you see permission errors for SQLite or uploads:
sudo chown -R www-data:www-data /var/www/html/mysite/data /var/www/html/mysite/uploads sudo chmod -R 775 /var/www/html/mysite/data /var/www/html/mysite/uploads
Back up these folders/files:
/var/www/html/mysite/data/cocktails.sqlite /var/www/html/mysite/uploads/
Those contain your saved recipes and uploaded images.