Ciao
Ho fatto una web application basata su Angular per il lato Frontend e Laravel per il lato Backend.
In locale, sulla macchina di sviluppo (visual studio code) funziona a meravoiglia.
Ho fatto il deploy e, completato l'installazione su Altervista, mi da errori strani in fase si utilizzo.
Vorrei illustrare i passi fatti e le conseguenti personalizzazioni per capire dove sbaglio.
Sullo spazio altervista assegnatomi (morenowork.altervista.org) ho creato 3 cartelle e precisamente:
- laravel --> identifica il backend (Laravel)
- messanatale --> identifica il frontend
- messapi --> identifica ail backend (cartella Public)
nella root ho creato il file .htaccess
e il file index.php<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php[L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# # av:php5-engine
AddHandler av-php73 .php
--------- cartella messanatale (Frontend) in Angular<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Messa di Natale - Test - on line </title>
<base href="http://morenowork.altervista.org/messanatale/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.abd0e528e6e91ea207c8.css"></head>
<body>
<app-root></app-root>
<!-- per gestire la popup di cancellazione 2020/11/14 -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<!-- per gestire la popup di cancellazione -- fine -- 2020/11/14 -->
<script src="runtime.acf0dec4155e77772545.js" defer></script><script src="polyfills.5c8033dfb7c3b4aa1601.js" defer></script><script src="scripts.4b8610c36b0ede43b206.js" defer></script><script src="main.f5dfdad7eab981ff6233.js" defer></script></body>
</html>
per il deploy in Visual Studio code ho utilizzato il comando
in modo da impostare correttamente il base href.- ng build –prod –base-href http://morenowork.altervista.org/messanatale
la cartella messanatale contiene quanto creato nella cartella "dist" con il build a cui ho aggiunto il file .htaccess che riporto
la riga RewriteBase /messanatale/ si rende necessaria per il corretto utilizzo della cartella.<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /messanatale/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
# # av:php5-engine
AddHandler av-php73 .php
--------- cartella laravel [U](Backend) in Laravel/U]
ho copiato tutto il contenuto del progetto laravel da visual studio code a meno della cartella "public"
Personalizzazioni eseguite:
file .env
Ho personalizzato le righe evidenziate in blu e precisamente URL e le credenziali del database mysql.APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:06wroKKP3OR966ExYzzF/rXOjitJsSV8acHLvYlzqng=
APP_DEBUG=true
APP_URL=http:sanfrarovigo.altervista.org/messanatale/
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_sanfrarovigo
DB_USERNAME=sanfrarovigo
DB_PASSWORD=
---- Cartella Config file Database
le credenziali del Database MySql'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'my_sanfrarovigo'),
'username' => env('DB_USERNAME', 'sanfrarovigo'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
--------- cartella messeapi [U](Backend - parte public) in Laravel/U]
ho copiato tutto il contenute della cartella "public" presente nel progetto laravel
personalizzazioni fatte:
- file .htaccess
la modifica RewriteBase /messeapi/ si rende necessaria per il corretto uso della cartella.<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /messeapi/
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
-- file index.php
le istruzioni originarie<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../laravel/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
sono state aggiornate nella Path per il corretto funzionamento del sito inrequire __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
allego screenshotrequire __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
ecco la procedura eseguita in localhost
https://ibb.co/RBQyVhf
Domande: sbaglio o dimentico qualche cosa nel deploy su altervista ?
Perchè sovrascrivo il sito altervista con "localhost:8000" come da screenshot ?
Grazie
Moreno
ps facendo anteprima non vengono visualizzati alcuni screenshot; non so se un problema dell'inserimento.
nel caso fatemi saperecome poterli inserire.
grazie