Skip to content
agovena.
agovena.
Get started
Community

Merchant & operations

Apache and PHP-FPM

Put Agovena behind Apache and PHP-FPM with a safe virtual host, PHP handler and HTTPS.

On this page

Use this guide when you chose Apache for a native Ubuntu or Debian installation. Use Nginx instead if that is the web server you selected. A native installation needs one web server, not both.

1. Install Apache and PHP-FPM

If you have not installed the packages yet, use the tab for your operating system:

bash
sudo apt update
sudo apt install -y apache2 libapache2-mod-fcgid php-cli php-fpm php-mysql php-mbstring php-xml php-curl php-zip php-intl php-bcmath
sudo a2enmod rewrite proxy proxy_fcgi setenvif
sudo systemctl enable --now apache2

Start the FPM service for the PHP version installed on the server:

bash
systemctl list-unit-files 'php*-fpm.service'
sudo systemctl enable --now php8.3-fpm

Replace php8.3-fpm with php8.4-fpm when that is your installed version.

2. Create the Apache virtual host

Copy Agovena's starting template and edit the hostname:

bash
sudo cp /var/www/agovena/deploy/apache.conf /etc/apache2/sites-available/agovena.conf
sudo nano /etc/apache2/sites-available/agovena.conf

Set the document root to:

apache
ServerName store.example
DocumentRoot /var/www/agovena/public

The template denies access to the application root and allows only the public directory. Keep AllowOverride All, Require all granted for public/ and Options -Indexes +FollowSymLinks so Laravel's public/.htaccess can route requests.

Enable the site and disable the default site:

bash
sudo a2ensite agovena.conf
sudo a2dissite 000-default.conf

3. Connect Apache to PHP-FPM

Add this handler inside the virtual host. Match the socket to the PHP-FPM service that is running:

apache
<FilesMatch "\.php$">
    SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>

Find the actual socket with:

bash
ls -l /run/php/php*-fpm.sock

If you use Agovena's optional FPM pool, use /run/php/php8.3-fpm-agovena.sock instead. Keep PHP CLI, PHP-FPM, the queue worker and cron on the same PHP minor version.

Never point DocumentRoot at /var/www/agovena. Do not create an alias for storage/app/private, .env or package source.

4. Set permissions and HTTPS

Give runtime directories to the deployment user and www-data group:

bash
cd /var/www/agovena
DEPLOY_USER="${SUDO_USER:-$USER}"
sudo chown -R "$DEPLOY_USER":www-data /var/www/agovena
sudo chmod -R ug+rwX storage bootstrap/cache

Set APP_URL to the HTTPS origin and follow the HTTPS guide before accepting credentials. Keep the Apache request limit and PHP upload limits aligned at 20 MB unless you deliberately change every layer.

5. Test and reload Apache

Test the configuration before reloading it:

bash
sudo apachectl configtest
sudo systemctl enable --now apache2
sudo systemctl reload apache2

If PHP is downloaded as text, stop and fix the PHP-FPM handler. A route-only 404 usually points to mod_rewrite, AllowOverride or the document root.

6. Check the store

Open these URLs through the real hostname:

  • /
  • /login
  • /admin
  • a public product image under /storage
  • a route that is not a physical file

Requests for .env, Composer files, artisan and private storage must be denied. Finish with the queue worker and scheduler guide.

Search documentation

Search guides, commands and API endpoints

What are you looking for?

Documentation