๐ Apache
Apache is one of the most widely used web servers. Monitron SaaS works perfectly with Apache 2.4+ when configured correctly.
๐ Requisitos Previosโ
- Apache 2.4+ installed
mod_rewriteenabledmod_sslenabled (for HTTPS)- PHP 8.2+ as mod_php or via PHP-FPM
๐ง Enable Required Modulesโ
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2enmod headers
sudo systemctl restart apache2
๐ VirtualHost Configurationโ
Create a new VirtualHost:
sudo nano /etc/apache2/sites-available/monitron.conf
Paste this configuration:
<VirtualHost *:80>
ServerName your-domain.com
Redirect permanent / https://your-domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName your-domain.com
# โโโ Document Root โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ๐จ IMPORTANT: Point to the /public directory!
DocumentRoot /var/www/monitron/public
# โโโ SSL Configuration โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/your-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your-domain.com/privkey.pem
# โโโ Directory Settings โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
<Directory /var/www/monitron/public>
AllowOverride All
Require all granted
Options -Indexes +FollowSymLinks
# Laravel URL rewriting
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
</Directory>
# โโโ Block Access to Sensitive Files โโโโโโโโโโโโโโโโโโ
<FilesMatch "^\.env">
Require all denied
</FilesMatch>
# โโโ Security Headers โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
Header always set X-XSS-Protection "1; mode=block"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
# โโโ Logging โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ErrorLog ${APACHE_LOG_DIR}/monitron-error.log
CustomLog ${APACHE_LOG_DIR}/monitron-access.log combined
# โโโ PHP Timeout for AI requests โโโโโโโโโโโโโโโโโโโโโ
<IfModule mod_php.c>
php_value max_execution_time 120
php_value upload_max_filesize 100M
php_value post_max_size 100M
</IfModule>
</VirtualHost>
๐ง Step-by-Step Setupโ
1. Replace Placeholdersโ
| Marcador | Reemplazar Con |
|---|---|
your-domain.com | Your actual domain |
/var/www/monitron | Your installation path |
| SSL certificate paths | Your actual paths |
2. Enable the Siteโ
# Enable the site
sudo a2ensite monitron.conf
# Disable the default site (optional)
sudo a2dissite 000-default.conf
# Test configuration
sudo apachectl configtest
# Restart Apache
sudo systemctl restart apache2
๐ SSL with Let's Encryptโ
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d your-domain.com
sudo certbot renew --dry-run
๐ The .htaccess Fileโ
Monitron includes a .htaccess file in the public/ directory. It handles:
- URL rewriting (pretty URLs)
- HTTP to HTTPS redirect
- Security headers
- CORS headers
aviso
Make sure AllowOverride All is set! Without it, Apache ignores .htaccess files and you'll get 404 errors on all pages except the homepage.
๐ Using PHP-FPM Instead of mod_phpโ
PHP-FPM is faster than mod_php for most workloads. To use it:
# Disable mod_php
sudo a2dismod php8.3
# Enable PHP-FPM proxy
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php8.3-fpm
# Restart
sudo systemctl restart apache2
๐ ๏ธ Solucion de Problemasโ
"Not Found" on all pages except homepageโ
mod_rewrite isn't enabled or AllowOverride isn't set:
sudo a2enmod rewrite
# And make sure AllowOverride All is in your VirtualHost
sudo systemctl restart apache2
500 Internal Server Errorโ
Check the Apache error log:
tail -50 /var/log/apache2/monitron-error.log
Common causes:
- Missing
.htaccessfile inpublic/ - Wrong file permissions
- PHP error (check
storage/logs/laravel.log)