-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlaravel.sh
136 lines (108 loc) · 2.88 KB
/
laravel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# ======================
# From Debian to Web App
# ======================
# This page contains a list of terminal commands that
# create a Laravel web application with routing, views
# and user accounts.
#
# You can start from a fresh debian installation. Or with a
# fresh debian container:
#
# docker run -v $(pwd):/var/www --rm -it -p 80:80 debian:11-slim
#
# You can copy+paste each command to see the application take
# shape or copy the whole page and paste it in one go.
# You can also download it here: https://...
# ======================
# Let's configure Debian
# ======================
# Do not show dialogs during the upgrade
export DEBIAN_FRONTEND=noninteractive
# Update the packages
apt update -y && apt upgrade -y
# =====================
# Let's install Laravel
# =====================
apt install -y unzip git php php-xml php-curl composer
composer global require laravel/installer
export PATH="$PATH:$HOME/.composer/vendor/bin"
cd /var/www
laravel new mysite
chown -R www-data:www-data mysite
cd mysite
# ====================
# Let's install Apache
# ====================
apt install -y apache2 libapache2-mod-php
cat << 'EOF' > /etc/apache2/sites-enabled/000-default.conf
ServerName mysite.local
<Directory /var/www/mysite/public>
AllowOverride All
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www/mysite/public
</VirtualHost>
EOF
service apache2 start
# Yay, we have a working Laravel instance!
# You can see it at 127.0.0.1
read -p 'Laravel is running! Hit enter to continue.'
# ===================
# Let's use templates
# ===================
cat << 'EOF' > ./resources/views/index.blade.php
<h1>Hello World</h1>
EOF
cat << 'EOF' > ./app/Http/Controllers/MainController.php
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
class MainController extends Controller
{
public function index()
{
return view('index');
}
}
EOF
# Set routing
cat << 'EOF' > ./routes/web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\MainController;
Route::get('/', [MainController::class, 'index']);
EOF
# Yay, we have static site!
read -p 'Serving a static site! Hit enter to continue.'
# =========================
# Let's use a base template
# =========================
# Let's create a base template
mkdir -p resources/views/layouts
cat << 'EOF' > resources/views/layouts/app.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<style>
body {background: #60a060}
</style>
</head>
<body>
@yield('content')
</body>
</html>
EOF
# And use it for the index page:
cat << 'EOF' > ./resources/views/index.blade.php
@extends('layouts.app')
@section('content')
<h1>Hello World</h1>
@endsection
EOF
# Yay, we have a working base template!
read -p 'The base template is live! Hit enter to continue.'
# =======================
# Let's add user accounts
# =======================
# ... To be written ...