Difference between revisions of "RecipeApp"
| Line 55: | Line 55: | ||
<pre> | <pre> | ||
sudo nano /etc/apache2/sites-available/ | sudo nano /etc/apache2/sites-available/mysite.conf | ||
</pre> | </pre> | ||
| Line 61: | Line 61: | ||
<pre> | <pre> | ||
<VirtualHost *:80> | <VirtualHost *:80> | ||
ServerName | ServerName mysite.com | ||
ServerAlias www. | ServerAlias www.mysite.com | ||
DocumentRoot /var/www/html/ | DocumentRoot /var/www/html/mysite | ||
<Directory /var/www/html/ | <Directory /var/www/html/mysite> | ||
Options -Indexes +FollowSymLinks | Options -Indexes +FollowSymLinks | ||
AllowOverride All | AllowOverride All | ||
| Line 72: | Line 72: | ||
</Directory> | </Directory> | ||
ErrorLog ${APACHE_LOG_DIR}/ | ErrorLog ${APACHE_LOG_DIR}/mysite-error.log | ||
CustomLog ${APACHE_LOG_DIR}/ | CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined | ||
</VirtualHost></pre> | </VirtualHost></pre> | ||
| Line 79: | Line 79: | ||
<pre> | <pre> | ||
sudo a2ensite | sudo a2ensite mysite.conf | ||
sudo a2enmod rewrite | sudo a2enmod rewrite | ||
sudo apachectl configtest | sudo apachectl configtest | ||
| Line 90: | Line 90: | ||
<pre> | <pre> | ||
cd /var/www/html/ | cd /var/www/html/mysite | ||
php -l index.php | php -l index.php | ||
| Line 106: | Line 106: | ||
Issue certificate: | Issue certificate: | ||
sudo certbot --apache -d | sudo certbot --apache -d mysite.com -d www.mysite.com | ||
'''Then test:''' | '''Then test:''' | ||
| Line 115: | Line 115: | ||
'''Check Apache/PHP errors:''' | '''Check Apache/PHP errors:''' | ||
sudo tail -n 100 /var/log/apache2/ | sudo tail -n 100 /var/log/apache2/mysite-error.log | ||
sudo tail -n 100 /var/log/apache2/error.log | sudo tail -n 100 /var/log/apache2/error.log | ||
'''Watch live while refreshing the browser:''' | '''Watch live while refreshing the browser:''' | ||
sudo tail -f /var/log/apache2/ | sudo tail -f /var/log/apache2/mysite-error.log | ||
'''If you see:''' | '''If you see:''' | ||
| Line 134: | Line 134: | ||
'''If you see permission errors for SQLite or uploads:''' | '''If you see permission errors for SQLite or uploads:''' | ||
sudo chown -R www-data:www-data /var/www/html/ | sudo chown -R www-data:www-data /var/www/html/mysite/data /var/www/html/mysite/uploads | ||
sudo chmod -R 775 /var/www/html/ | sudo chmod -R 775 /var/www/html/mysite/data /var/www/html/mysite/uploads | ||
'''Back up these folders/files:''' | '''Back up these folders/files:''' | ||
/var/www/html/ | /var/www/html/mysite/data/cocktails.sqlite | ||
/var/www/html/ | /var/www/html/mysite/uploads/ | ||
'''Those contain your saved recipes and uploaded images.''' | '''Those contain your saved recipes and uploaded images.''' | ||
Latest revision as of 19:45, 10 June 2026
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.