@@ -0,0 +1,96 @@
|
||||
# investemoz.tempo.co.mz — instalação Linux
|
||||
|
||||
Modelos para Linux com systemd, Nginx e PHP-FPM. Caminho assumido:
|
||||
`/var/www/investemoz`; utilizador web `www-data`; PHP 8.5. Confirmar distribuição,
|
||||
binário e socket antes de aplicar (não se assume que os pacotes estejam instalados).
|
||||
Nenhum destes ficheiros foi aplicado remotamente. O `.env` local fica intacto.
|
||||
|
||||
## 1. Preparar o servidor
|
||||
|
||||
Instalar Nginx, PHP CLI/FPM compatível com composer.lock e extensões exigidas por
|
||||
`composer check-platform-reqs --no-dev`, incluindo pdo_pgsql, mbstring, xml, curl
|
||||
e intl. Instalar PostgreSQL/PostGIS ou provisionar uma instância externa.
|
||||
Usar o gestor de pacotes e versões suportados pela distribuição escolhida.
|
||||
Verificar `php -v`, `php -m`, `nginx -v` e o socket em `/run/php/`.
|
||||
|
||||
Apontar o registo DNS A de investemoz.tempo.co.mz para o IP do servidor. Publicar
|
||||
AAAA apenas se IPv6 estiver configurado (os modelos fornecidos escutam IPv4).
|
||||
Permitir HTTPS/HTTP e o acesso administrativo necessário no firewall. Não expor
|
||||
PostgreSQL publicamente por defeito.
|
||||
|
||||
Publicar o projecto em `/var/www/investemoz`, excluindo .env local, public/hot,
|
||||
node_modules e dados locais de storage. Preservar storage nas actualizações.
|
||||
O código pertence ao utilizador de implantação; www-data só necessita de escrita
|
||||
em storage e bootstrap/cache. O .env deve ser legível pelo PHP, sem acesso público
|
||||
nem permissões globais (por exemplo proprietário de implantação, grupo www-data, 0640).
|
||||
|
||||
## 2. Aplicação e base de dados
|
||||
|
||||
Usar production.env.example como ponto de partida apenas numa instalação nova.
|
||||
Preencher os segredos no servidor e criar base/utilizadores com privilégios revistos.
|
||||
Provisionar PostGIS com a conta administrativa. Seguir
|
||||
[o guia de publicação](../../docs/investmoz/deployment.md) para dependências,
|
||||
build, APP_KEY, migrations e backups. Não sobrescrever APP_KEY nem .env numa
|
||||
actualização. Manter configurações de migração e execução separadas.
|
||||
|
||||
O build precisa de PHP para gerar as rotas Wayfinder. Não copiar vendor gerado
|
||||
para Windows sem reinstalar/verificar dependências na plataforma de destino.
|
||||
Não activar notificações até validar o correio. MAIL_MAILER=log é provisório:
|
||||
não entrega verificações de conta; os logs podem conter ligações sensíveis.
|
||||
|
||||
## 3. Certificado e Nginx
|
||||
|
||||
Instalar Certbot pelo método indicado para a distribuição. Criar
|
||||
`/var/www/letsencrypt` e instalar nginx-http.conf como o virtual host deste domínio.
|
||||
Em Debian/Ubuntu pode usar sites-available/sites-enabled; noutras distribuições
|
||||
usar o directório incluído pelo nginx.conf. Não activar ambos os modelos ao mesmo tempo.
|
||||
|
||||
```sh
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
sudo certbot certonly --webroot -w /var/www/letsencrypt -d investemoz.tempo.co.mz
|
||||
```
|
||||
|
||||
Depois de existir o certificado, substituir o virtual host pelo nginx-https.conf,
|
||||
ajustando o socket fastcgi_pass. Validar com nginx -t antes de recarregar. Confirmar
|
||||
o mecanismo de renovação do Certbot e configurar um deploy hook que execute
|
||||
`systemctl reload nginx` após cada renovação bem sucedida. Testar renovação com
|
||||
`sudo certbot renew --dry-run`. Não activar o modelo HTTPS antes do certificado.
|
||||
|
||||
## 4. Fila
|
||||
|
||||
Rever utilizador, caminhos e PHP em investemoz-queue.service. Instalar a unidade
|
||||
em `/etc/systemd/system/investemoz-queue.service` e executar:
|
||||
|
||||
```sh
|
||||
sudo systemd-analyze verify /etc/systemd/system/investemoz-queue.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now investemoz-queue
|
||||
sudo systemctl status investemoz-queue
|
||||
sudo journalctl -u investemoz-queue -n 50
|
||||
```
|
||||
|
||||
O serviço lê o .env pelo Laravel, não por EnvironmentFile. Recarregar config e
|
||||
executar `php artisan queue:restart` após alterações. Não executar outro supervisor
|
||||
para este mesmo worker. Configurar rotação de logs Laravel e monitorização de jobs
|
||||
falhados e espaço em disco; a aplicação não remove o histórico de auditoria.
|
||||
|
||||
## 5. Verificação final
|
||||
|
||||
```sh
|
||||
cd /var/www/investemoz
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
php artisan portal:readiness
|
||||
curl --fail https://investemoz.tempo.co.mz/up
|
||||
curl --fail https://investemoz.tempo.co.mz/api/v1/home
|
||||
```
|
||||
|
||||
Confirmar redireccionamento HTTP, certificado, página inicial, ficheiro estático,
|
||||
ligação directa de oportunidade e login. `/acesso-gestao` permite configurar a
|
||||
conta mais tarde. Readiness continuará a indicar correio pendente enquanto usar log.
|
||||
Testar restauração de backup numa instância separada antes de colocar dados reais.
|
||||
|
||||
Referências: [Nginx try_files](https://nginx.org/en/docs/http/ngx_http_core_module.html#try_files),
|
||||
[systemd.service](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html).
|
||||
@@ -0,0 +1,26 @@
|
||||
[Unit]
|
||||
Description=InvestMoz Laravel database queue
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/var/www/investemoz
|
||||
ExecStart=/usr/bin/php8.5 /var/www/investemoz/artisan queue:work database --queue=default --sleep=3 --tries=3 --timeout=30 --max-time=3600
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
TimeoutStopSec=60
|
||||
KillSignal=SIGTERM
|
||||
UMask=0027
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/var/www/investemoz/storage /var/www/investemoz/bootstrap/cache
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,10 @@
|
||||
# Bootstrap only: obtain the certificate before enabling nginx-https.conf.
|
||||
server {
|
||||
listen 80;
|
||||
server_name investemoz.tempo.co.mz;
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/letsencrypt;
|
||||
try_files $uri =404;
|
||||
}
|
||||
location / { return 503; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name investemoz.tempo.co.mz;
|
||||
location ^~ /.well-known/acme-challenge/ {
|
||||
root /var/www/letsencrypt;
|
||||
try_files $uri =404;
|
||||
}
|
||||
location / { return 301 https://investemoz.tempo.co.mz$request_uri; }
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name investemoz.tempo.co.mz;
|
||||
root /var/www/investemoz/public;
|
||||
index index.php;
|
||||
charset utf-8;
|
||||
server_tokens off;
|
||||
client_max_body_size 10m;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/investemoz.tempo.co.mz/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/investemoz.tempo.co.mz/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header X-Frame-Options SAMEORIGIN always;
|
||||
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
||||
|
||||
location / { try_files $uri $uri/ /index.php?$query_string; }
|
||||
location = /index.php {
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root/index.php;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
fastcgi_param HTTPS on;
|
||||
# Match the installed PHP-FPM socket before enabling.
|
||||
fastcgi_pass unix:/run/php/php8.5-fpm.sock;
|
||||
}
|
||||
location ~ \.php(?:/|$) { return 404; }
|
||||
location ~ /\. { deny all; }
|
||||
location = /hot { return 404; }
|
||||
location /build/ { try_files $uri =404; }
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
APP_NAME="Investe Moçambique"
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=false
|
||||
APP_URL=https://investemoz.tempo.co.mz
|
||||
APP_LOCALE=pt
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_LEVEL=warning
|
||||
DB_CONNECTION=pgsql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=investemoz
|
||||
DB_USERNAME=investemoz_app
|
||||
DB_PASSWORD=
|
||||
SESSION_DRIVER=database
|
||||
SESSION_SECURE_COOKIE=true
|
||||
SESSION_HTTP_ONLY=true
|
||||
SESSION_SAME_SITE=lax
|
||||
SESSION_DOMAIN=null
|
||||
CACHE_STORE=database
|
||||
QUEUE_CONNECTION=database
|
||||
DB_QUEUE_RETRY_AFTER=90
|
||||
PORTAL_MANAGER_EMAILS=comercial@tempo.co.mz
|
||||
PORTAL_NOTIFICATIONS_ENABLED=false
|
||||
PORTAL_NOTIFICATION_RECIPIENTS=
|
||||
MAIL_MAILER=log
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=587
|
||||
MAIL_USERNAME=
|
||||
MAIL_PASSWORD=
|
||||
MAIL_TIMEOUT=15
|
||||
MAIL_FROM_ADDRESS=comercial@tempo.co.mz
|
||||
MAIL_FROM_NAME="Investe Moçambique"
|
||||
VITE_APP_NAME="Investe Moçambique"
|
||||
Reference in New Issue
Block a user