Difference between revisions of "RecipeApp"

From rbachwiki
Jump to navigation Jump to search
(Created page with "== Recipe App == ''''1. Install Packages '''' <pre> sudo apt update sudo apt install apache2 sqlite3 libsqlite3-dev libapache2-mod-php php-sqlite3 </pre> ''''If your Apache uses a specific PHP version, install SQLite for that version. Check Apache PHP:'''' <pre> apachectl -M | grep -i php ls -la /etc/apache2/mods-enabled/php*.load </pre> '''' Example: if Apache uses PHP 8.1:'''' <pre> sudo apt install php8.1-sqlite3 sudo phpenmod -v 8.1 -s apache2 pdo_sqlite sqlit...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Recipe App ==
== Recipe App ==


''''1. Install Packages ''''
'''1. Install Packages '''


<pre>
<pre>
Line 9: Line 9:
</pre>
</pre>


''''If your Apache uses a specific PHP version, install SQLite for that version. Check Apache PHP:''''
'''If your Apache uses a specific PHP version, install SQLite for that version. Check Apache PHP:'''


<pre>
<pre>
Line 16: Line 16:
</pre>
</pre>


'''' Example: if Apache uses PHP 8.1:''''
''' Example: if Apache uses PHP 8.1:'''


<pre>
<pre>
Line 24: Line 24:
</pre>
</pre>


'''' Verify SQLite support:''''
''' Verify SQLite support:'''


<pre>
<pre>
Line 31: Line 31:
</pre>
</pre>


'''' You should see:''''
''' You should see:'''


<pre>
<pre>
Line 38: Line 38:
</pre>
</pre>


'''' 2. Copy App Files
''' 2. Copy App Files'''
Example location:3. Set Permissions
'''Example location:3. Set Permissions'''
Apache must write to SQLite and image upload folders:''''
'''Apache must write to SQLite and image upload folders:'''


<pre>
<pre>
Line 50: Line 50:
</pre>
</pre>


'''' Do not make the whole app writable unless needed. Only data/ and uploads/ need write access.
''' Do not make the whole app writable unless needed. Only data/ and uploads/ need write access.'''
4. Apache Virtual Host
'''4. Apache Virtual Host'''
Create a site config:''''
'''Create a site config:'''


<pre>
<pre>
sudo nano /etc/apache2/sites-available/11square.conf
sudo nano /etc/apache2/sites-available/mysite.conf
</pre>
</pre>


'''' ''''


<pre>
<pre>
<VirtualHost *:80>
<VirtualHost *:80>
     ServerName 11square.com
     ServerName mysite.com
     ServerAlias www.11square.com
     ServerAlias www.mysite.com


     DocumentRoot /var/www/html/11square
     DocumentRoot /var/www/html/mysite


     <Directory /var/www/html/11square>
     <Directory /var/www/html/mysite>
         Options -Indexes +FollowSymLinks
         Options -Indexes +FollowSymLinks
         AllowOverride All
         AllowOverride All
Line 73: Line 72:
     </Directory>
     </Directory>


     ErrorLog ${APACHE_LOG_DIR}/11square-error.log
     ErrorLog ${APACHE_LOG_DIR}/mysite-error.log
     CustomLog ${APACHE_LOG_DIR}/11square-access.log combined
     CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined
</VirtualHost></pre>
</VirtualHost></pre>


''''Enable the site: ''''
'''Enable the site: '''


<pre>
<pre>
sudo a2ensite 11square.conf
sudo a2ensite mysite.conf
sudo a2enmod rewrite
sudo a2enmod rewrite
sudo apachectl configtest
sudo apachectl configtest
Line 86: Line 85:
</pre>
</pre>


''''If config test says Syntax OK, Apache is good.
'''If config test says Syntax OK, Apache is good.'''
5. Test App From Server
'''5. Test App From Server'''
From the app folder: ''''
'''From the app folder: ''''


<pre>
<pre>
cd /var/www/html/11square
cd /var/www/html/mysite


php -l index.php
php -l index.php
Line 97: Line 96:
</pre>
</pre>


'''' ''''


<pre>
 
 
'''7. Optional HTTPS
'''7. Optional HTTPS
Install Certbot:'''
Install Certbot:'''
Line 107: Line 106:
Issue certificate:
Issue certificate:


  sudo certbot --apache -d 11square.com -d www.11square.com
  sudo certbot --apache -d mysite.com -d www.mysite.com


'''Then test:'''
'''Then test:'''
Line 116: Line 115:
'''Check Apache/PHP errors:'''
'''Check Apache/PHP errors:'''


  sudo tail -n 100 /var/log/apache2/11square-error.log
  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/11square-error.log
  sudo tail -f /var/log/apache2/mysite-error.log


'''If you see:'''
'''If you see:'''
Line 133: Line 132:
  sudo systemctl restart apache2
  sudo systemctl restart apache2


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/11square/data /var/www/html/11square/uploads
 
sudo chmod -R 775 /var/www/html/11square/data /var/www/html/11square/uploads
sudo chown -R www-data:www-data /var/www/html/mysite/data /var/www/html/mysite/uploads
Backup
sudo chmod -R 775 /var/www/html/mysite/data /var/www/html/mysite/uploads
Back up these folders/files:
 
/var/www/html/11square/data/cocktails.sqlite
'''Back up these folders/files:'''
/var/www/html/11square/uploads/
 
Those contain your saved recipes and uploaded images.
/var/www/html/mysite/data/cocktails.sqlite
</pre>
/var/www/html/mysite/uploads/
 
'''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.