© 2015-2024 mister3D.fr - Signaler un bug - Mentions légales - Contact
L'objectif de ce pas à pas est d'expliquer comment installer Laravel et VueJS dans leurs dernière version sur un unique serveur Apache.
Votre développement Laravel pourra être fait en directe, pour Vue il faudra passer par "npm run dev" mais une fois terminé avec une commande le contenue serra transpile et fonctionnera par le biais d'Apache.
Je n'aborde pas ici les notions de sécurité si vous passer cette configuration en production.
apt update
apt dist-upgrade
apt-get install ca-certificates apt-transport-https software-properties-common wget curl lsb-release
curl -sSL https://packages.sury.org/php/README.txt | bash -x
apt-get update
apt install apache2 mariadb-server
apt install php8.1 libapache2-mod-php8.1 php8.1-mbstring php8.1-xmlrpc php8.1-soap php8.1-gd php8.1-xml php8.1-cli php8.1-zip php8.1-bcmath php8.1-tokenizer php8.1-mysql php8.1-curl zip unzip
mysql_secure_installation
> Enter current password for root (enter for none): Tapez Enter
> Switch to unix_socket authentication : n
> Change the root password? : Y
> New password: Mot de passe à noter pour la suite
> Re-enter new password: ...
> Remove anonymous users? Y
> Disallow root login remotely? n
> Remove test database and access to it? Y
> Reload privilege tables now? Y
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
curl -sL https://deb.nodesource.com/setup_16.x | bash -
apt update
apt install nodejs
apt upgrade
npm install -g npm@latest
rm -rf /var/www/*
composer create-project --prefer-dist laravel/laravel /var/www/back/
cd /var/www/back/
php artisan key:generate --ansi
cd /var/www/
mkdir front
cd front
npm create vue@latest .
npm install
npm run dev
npm run build
mkdir /var/www/mysql/
cd /var/www/
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
tar -zxvf phpMyAdmin-latest-all-languages.tar.gz
rm phpMyAdmin-latest-all-languages.zip
mv phpMyAdmin-5.2.1-all-languages/ ./mysql/
nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/front/dist
<Directory /var/www/front/dist>
AllowOverride All
</Directory>
Alias /mysql "/var/www/mysql"
<Directory /var/www/mysql>
AllowOverride All
</Directory>
Alias /api "/var/www/back/public"
<Directory /var/www/back/public>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
a2enmod rewrite
chgrp -R www-data /var/www/
chmod -R 775 /var/www/
systemctl restart apache2
nano /var/www/back/app/Providers/RouteServiceProvider.php
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('api')
->group(base_path('routes/api.php'));
nano /var/www/back/.env
php artisan make:model NomModele -mc
public function up(): void
{
Schema::create('todos', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->date('deadline');
$table->integer('order');
$table->unsignedBigInteger('user_id');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->timestamps();
});
}
php artisan migrate