Skip to content

Commit d1f386c

Browse files
committed
published blog entry about laravel setup, removed duplicate entries in sitemap.xml
1 parent 5e0ea2d commit d1f386c

File tree

5 files changed

+269
-22
lines changed

5 files changed

+269
-22
lines changed

2025/02/06/laravelSetupOnPi.html

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<!DOCTYPE html>
2+
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
<title>
7+
8+
Setup Raspberry Pi to serve a Laravel based website &middot; xargas.eu
9+
10+
</title>
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5">
12+
<link rel="shortcut icon" href="/favicon.ico">
13+
<link rel="stylesheet" href="/public/style.css">
14+
<link rel="stylesheet" href="/public/syntax.css">
15+
</head>
16+
17+
<body>
18+
<div class="navbar">
19+
<h1>Xargas.eu</h1>
20+
<p>Private website to write about my hobbies</p>
21+
<a class="navbar-item" href="/">Home</a>
22+
23+
<a class="navbar-item" href="/blog/">Blog</a>
24+
25+
<a class="navbar-item" href="/3dprint/index.html">3D Printing</a>
26+
27+
<a class="navbar-item" href="/3dmodel/index.html">3D Modeling</a>
28+
29+
<a class="navbar-item" href="/embeddedsw/index.html">Embedded Software</a>
30+
31+
32+
<a class="navbar-item" href="/pages/impressum.html">Impressum</a>
33+
34+
<p>&copy; 2025. All rights reserved.</p>
35+
</div>
36+
<div class="content">
37+
<div class="post post-entry">
38+
<h1 class="post-title">Setup Raspberry Pi to serve a Laravel based website</h1>
39+
<span class="post-date">06.02.2025</span>
40+
<hr>
41+
<div class="post-content"><p>The official website of Laravel has already a <a href="https://laravel.com/docs/11.x">documentation</a> on howto install it on a Linux OS, but it requires to trust the installer script. This would have been run directly on the local machine without prior checking the contents and what is really done.
42+
Of course I manually checked the install script and did not like what I found. The installed elements would not be tracked by the package manager, it would install another certificate authority list for the local installation. Things I consider non-maintainable or unsafe. So I wanted to go another (more clean?) way on a Raspberry Pi.</p>
43+
44+
<ol>
45+
<li>First I needed to install the necessary tools using the commandline.
46+
<ul>
47+
<li>I wanted to use <code class="language-plaintext highlighter-rouge">nginx</code> to serve the websites.</li>
48+
<li>I wanted to use <code class="language-plaintext highlighter-rouge">php-fpm</code> because it is faster than the apache and/or cgi combinations. And of course because it runs on a Raspberry Pi.</li>
49+
<li>I needed <code class="language-plaintext highlighter-rouge">composer</code> for php packages.</li>
50+
</ul>
51+
52+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>aptitude <span class="nb">install </span>nginx php-fpm composer
53+
</code></pre></div> </div>
54+
</li>
55+
<li>
56+
<p>I then configured nginx to serve a new site by adding a file <code class="language-plaintext highlighter-rouge">/etc/nginx/sites-available/laravel-www</code>:</p>
57+
58+
<div class="language-nginx highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">server</span> <span class="p">{</span>
59+
<span class="kn">listen</span> <span class="mi">80</span> <span class="s">default_server</span><span class="p">;</span>
60+
<span class="kn">listen</span> <span class="s">[::]:80</span> <span class="s">default_server</span><span class="p">;</span>
61+
62+
<span class="kn">root</span> <span class="n">/var/www/laravel-www</span><span class="p">;</span>
63+
64+
<span class="kn">index</span> <span class="s">index.html</span> <span class="s">index.php</span><span class="p">;</span>
65+
66+
<span class="kn">server_name</span> <span class="s">_</span><span class="p">;</span>
67+
68+
<span class="kn">location</span> <span class="n">/</span> <span class="p">{</span>
69+
<span class="c1"># First attempt to serve request as file, then</span>
70+
<span class="c1"># as directory, then fall back to displaying a 404.</span>
71+
<span class="kn">try_files</span> <span class="nv">$uri</span> <span class="nv">$uri</span><span class="n">/</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
72+
<span class="p">}</span>
73+
74+
<span class="kn">location</span> <span class="p">~</span> <span class="sr">\.php$</span> <span class="p">{</span>
75+
<span class="kn">fastcgi_split_path_info</span> <span class="s">^(.+?</span><span class="err">\</span><span class="s">.php)(/.*)</span>$<span class="p">;</span>
76+
<span class="kn">try_files</span> <span class="nv">$fastcgi_script_name</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
77+
<span class="kn">set</span> <span class="nv">$path_info</span> <span class="nv">$fastcgi_path_info</span><span class="p">;</span>
78+
<span class="kn">fastcgi_param</span> <span class="s">PATH_INFO</span> <span class="nv">$path_info</span><span class="p">;</span>
79+
<span class="kn">fastcgi_index</span> <span class="s">index.php</span><span class="p">;</span>
80+
<span class="kn">include</span> <span class="s">fastcgi.conf</span><span class="p">;</span>
81+
<span class="kn">fastcgi_pass</span> <span class="s">unix:/run/php/php-fpm.sock</span><span class="p">;</span>
82+
<span class="p">}</span>
83+
<span class="p">}</span>
84+
</code></pre></div> </div>
85+
<p>This already contains the necessary parts for serving on a HTTP server (no SSL here at the moment!) using the installed PHP version.
86+
I used the version-free <code class="language-plaintext highlighter-rouge">php-fpm</code> symlink so updating/changing to another PHP version is easier later.</p>
87+
</li>
88+
<li>The site was then activated to be served already, as it was not public on the internet:
89+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> /etc/nginx/sites-available/laravel-www /etc/nginx/sites-enabled/laravel-www
90+
nginx <span class="nt">-s</span> reload
91+
</code></pre></div> </div>
92+
</li>
93+
<li>Now I used <code class="language-plaintext highlighter-rouge">composer</code> to get the basic laravel installation:
94+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> /var/www/
95+
<span class="nb">mkdir </span>laravel-www
96+
composer create-project laravel/laravel laravel-www
97+
</code></pre></div> </div>
98+
</li>
99+
<li>For the installation to work, I needed to setup some access rights, as <code class="language-plaintext highlighter-rouge">nginx</code> is running as <code class="language-plaintext highlighter-rouge">www-data</code> user:
100+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">chown</span> <span class="nt">-R</span> www-data.www-data /var/www/laravel-www
101+
</code></pre></div> </div>
102+
</li>
103+
<li>For the Laravel project itself, my first start should used the <code class="language-plaintext highlighter-rouge">sqlite</code> database to just show that the laravel part is working. So I initialized it using the default configurations in the <code class="language-plaintext highlighter-rouge">/var/www/laravel-www/.env</code> file via:
104+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> /var/www/laravel-www
105+
php artisan migrate
106+
</code></pre></div> </div>
107+
</li>
108+
<li>Now I had the basic laravel project up and running (For later reference: Laravel v11.41.3 (PHP v8.2.7))</li>
109+
</ol>
110+
</div>
111+
</div>
112+
113+
114+
</div>
115+
</body>
116+
</html>
117+

blog/index.html

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,82 @@ <h1>Xargas.eu</h1>
3636
<div class="content">
3737
<div class="blog">
3838

39+
<div class="blog-entry">
40+
<h1 class="blog-title"><a href="/2025/02/06/laravelSetupOnPi.html">Setup Raspberry Pi to serve a Laravel based website</a></h1>
41+
<span class="blog-date">06.02.2025</span>
42+
<hr>
43+
<div class="blog-content"><p>The official website of Laravel has already a <a href="https://laravel.com/docs/11.x">documentation</a> on howto install it on a Linux OS, but it requires to trust the installer script. This would have been run directly on the local machine without prior checking the contents and what is really done.
44+
Of course I manually checked the install script and did not like what I found. The installed elements would not be tracked by the package manager, it would install another certificate authority list for the local installation. Things I consider non-maintainable or unsafe. So I wanted to go another (more clean?) way on a Raspberry Pi.</p>
45+
46+
<ol>
47+
<li>First I needed to install the necessary tools using the commandline.
48+
<ul>
49+
<li>I wanted to use <code class="language-plaintext highlighter-rouge">nginx</code> to serve the websites.</li>
50+
<li>I wanted to use <code class="language-plaintext highlighter-rouge">php-fpm</code> because it is faster than the apache and/or cgi combinations. And of course because it runs on a Raspberry Pi.</li>
51+
<li>I needed <code class="language-plaintext highlighter-rouge">composer</code> for php packages.</li>
52+
</ul>
53+
54+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>aptitude <span class="nb">install </span>nginx php-fpm composer
55+
</code></pre></div> </div>
56+
</li>
57+
<li>
58+
<p>I then configured nginx to serve a new site by adding a file <code class="language-plaintext highlighter-rouge">/etc/nginx/sites-available/laravel-www</code>:</p>
59+
60+
<div class="language-nginx highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">server</span> <span class="p">{</span>
61+
<span class="kn">listen</span> <span class="mi">80</span> <span class="s">default_server</span><span class="p">;</span>
62+
<span class="kn">listen</span> <span class="s">[::]:80</span> <span class="s">default_server</span><span class="p">;</span>
63+
64+
<span class="kn">root</span> <span class="n">/var/www/laravel-www</span><span class="p">;</span>
65+
66+
<span class="kn">index</span> <span class="s">index.html</span> <span class="s">index.php</span><span class="p">;</span>
67+
68+
<span class="kn">server_name</span> <span class="s">_</span><span class="p">;</span>
69+
70+
<span class="kn">location</span> <span class="n">/</span> <span class="p">{</span>
71+
<span class="c1"># First attempt to serve request as file, then</span>
72+
<span class="c1"># as directory, then fall back to displaying a 404.</span>
73+
<span class="kn">try_files</span> <span class="nv">$uri</span> <span class="nv">$uri</span><span class="n">/</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
74+
<span class="p">}</span>
75+
76+
<span class="kn">location</span> <span class="p">~</span> <span class="sr">\.php$</span> <span class="p">{</span>
77+
<span class="kn">fastcgi_split_path_info</span> <span class="s">^(.+?</span><span class="err">\</span><span class="s">.php)(/.*)</span>$<span class="p">;</span>
78+
<span class="kn">try_files</span> <span class="nv">$fastcgi_script_name</span> <span class="p">=</span><span class="mi">404</span><span class="p">;</span>
79+
<span class="kn">set</span> <span class="nv">$path_info</span> <span class="nv">$fastcgi_path_info</span><span class="p">;</span>
80+
<span class="kn">fastcgi_param</span> <span class="s">PATH_INFO</span> <span class="nv">$path_info</span><span class="p">;</span>
81+
<span class="kn">fastcgi_index</span> <span class="s">index.php</span><span class="p">;</span>
82+
<span class="kn">include</span> <span class="s">fastcgi.conf</span><span class="p">;</span>
83+
<span class="kn">fastcgi_pass</span> <span class="s">unix:/run/php/php-fpm.sock</span><span class="p">;</span>
84+
<span class="p">}</span>
85+
<span class="p">}</span>
86+
</code></pre></div> </div>
87+
<p>This already contains the necessary parts for serving on a HTTP server (no SSL here at the moment!) using the installed PHP version.
88+
I used the version-free <code class="language-plaintext highlighter-rouge">php-fpm</code> symlink so updating/changing to another PHP version is easier later.</p>
89+
</li>
90+
<li>The site was then activated to be served already, as it was not public on the internet:
91+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">ln</span> <span class="nt">-s</span> /etc/nginx/sites-available/laravel-www /etc/nginx/sites-enabled/laravel-www
92+
nginx <span class="nt">-s</span> reload
93+
</code></pre></div> </div>
94+
</li>
95+
<li>Now I used <code class="language-plaintext highlighter-rouge">composer</code> to get the basic laravel installation:
96+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> /var/www/
97+
<span class="nb">mkdir </span>laravel-www
98+
composer create-project laravel/laravel laravel-www
99+
</code></pre></div> </div>
100+
</li>
101+
<li>For the installation to work, I needed to setup some access rights, as <code class="language-plaintext highlighter-rouge">nginx</code> is running as <code class="language-plaintext highlighter-rouge">www-data</code> user:
102+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">chown</span> <span class="nt">-R</span> www-data.www-data /var/www/laravel-www
103+
</code></pre></div> </div>
104+
</li>
105+
<li>For the Laravel project itself, my first start should used the <code class="language-plaintext highlighter-rouge">sqlite</code> database to just show that the laravel part is working. So I initialized it using the default configurations in the <code class="language-plaintext highlighter-rouge">/var/www/laravel-www/.env</code> file via:
106+
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> /var/www/laravel-www
107+
php artisan migrate
108+
</code></pre></div> </div>
109+
</li>
110+
<li>Now I had the basic laravel project up and running (For later reference: Laravel v11.41.3 (PHP v8.2.7))</li>
111+
</ol>
112+
</div>
113+
</div>
114+
39115
<div class="blog-entry">
40116
<h1 class="blog-title"><a href="/2025/02/06/gnuScreenSshLogin.html">Using GNU Screen upon SSH login</a></h1>
41117
<span class="blog-date">06.02.2025</span>
@@ -155,17 +231,6 @@ <h1 class="blog-title"><a href="/2025/01/23/buildFreeCAD.html">Building FreeCAD
155231
<li>After some time, the build finished and let me start FreeCAD.exe (In my case “C:/_public/GitHub/FreeCAD/build/release/bin/FreeCAD.exe”).</li>
156232
</ol>
157233

158-
</div>
159-
</div>
160-
161-
<div class="blog-entry">
162-
<h1 class="blog-title"><a href="/2025/01/22/start.html">xargas.eu goes online</a></h1>
163-
<span class="blog-date">22.01.2025</span>
164-
<hr>
165-
<div class="blog-content"><p>This is a private website, where I document my hobbies. The reason why I started this website is that I often find hints, tips or clues, but I rarely find “complete information”. And of course, I also want to later find that info myself again.</p>
166-
167-
<p>So in case you have similar interests you could find something here!</p>
168-
169234
</div>
170235
</div>
171236

@@ -175,10 +240,10 @@ <h1 class="blog-title"><a href="/2025/01/22/start.html">xargas.eu goes online</a
175240
<span class="previous">Previous</span> |
176241

177242
<span class="page_number ">
178-
Page: 1 of 1
243+
Page: 1 of 2
179244
</span>
180245

181-
<span class="next ">| Next</span>
246+
| <a href="/blog/page2" class="next">Next</a>
182247

183248
</div>
184249
</div>

blog/page2/index.html

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8">
6+
<title>
7+
8+
Blog &middot; xargas.eu
9+
10+
</title>
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5">
12+
<link rel="shortcut icon" href="/favicon.ico">
13+
<link rel="stylesheet" href="/public/style.css">
14+
<link rel="stylesheet" href="/public/syntax.css">
15+
</head>
16+
17+
<body>
18+
<div class="navbar">
19+
<h1>Xargas.eu</h1>
20+
<p>Private website to write about my hobbies</p>
21+
<a class="navbar-item" href="/">Home</a>
22+
23+
<a class="navbar-item" href="/blog/">Blog</a>
24+
25+
<a class="navbar-item" href="/3dprint/index.html">3D Printing</a>
26+
27+
<a class="navbar-item" href="/3dmodel/index.html">3D Modeling</a>
28+
29+
<a class="navbar-item" href="/embeddedsw/index.html">Embedded Software</a>
30+
31+
32+
<a class="navbar-item" href="/pages/impressum.html">Impressum</a>
33+
34+
<p>&copy; 2025. All rights reserved.</p>
35+
</div>
36+
<div class="content">
37+
<div class="blog">
38+
39+
<div class="blog-entry">
40+
<h1 class="blog-title"><a href="/2025/01/22/start.html">xargas.eu goes online</a></h1>
41+
<span class="blog-date">22.01.2025</span>
42+
<hr>
43+
<div class="blog-content"><p>This is a private website, where I document my hobbies. The reason why I started this website is that I often find hints, tips or clues, but I rarely find “complete information”. And of course, I also want to later find that info myself again.</p>
44+
45+
<p>So in case you have similar interests you could find something here!</p>
46+
47+
</div>
48+
</div>
49+
50+
51+
<div class="pagination">
52+
53+
<a href="/blog/" class="previous">
54+
Previous
55+
</a> |
56+
57+
<span class="page_number ">
58+
Page: 2 of 2
59+
</span>
60+
61+
<span class="next ">| Next</span>
62+
63+
</div>
64+
</div>
65+
66+
</div>
67+
</body>
68+
</html>
69+

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ <h1 id="xargaseu">Xargas.eu</h1>
4545
<p>Latest blog entries:</p>
4646

4747
<div class="blog-entry blog-entry-preview">
48-
<a href="/2025/02/06/gnuScreenSshLogin.html">Using GNU Screen upon SSH login</a>
48+
<a href="/2025/02/06/laravelSetupOnPi.html">Setup Raspberry Pi to serve a Laravel based website</a>
4949
</div>
5050

5151
<div class="blog-entry blog-entry-preview">
52-
<a href="/2025/02/05/nginxWithPihole.html">Using nginx combined with Pi-hole to block server site tracking</a>
52+
<a href="/2025/02/06/gnuScreenSshLogin.html">Using GNU Screen upon SSH login</a>
5353
</div>
5454

5555
<div class="blog-entry blog-entry-preview">
56-
<a href="/2025/02/05/bashPromptMachineIcon.html">Icon/emoji in bash prompt for easier machine identification</a>
56+
<a href="/2025/02/05/nginxWithPihole.html">Using nginx combined with Pi-hole to block server site tracking</a>
5757
</div>
5858

5959
</div>

sitemap.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
<url><loc>https://xargas.eu/pages/impressum.html</loc></url>
44
<url><loc>https://xargas.eu/blog/</loc></url>
55
<url><loc>https://xargas.eu/</loc></url>
6-
7-
<url><loc>https://xargas.eu/2025/02/06/gnuScreenSshLogin.html</loc></url>
8-
<url><loc>https://xargas.eu/2025/02/05/nginxWithPihole.html</loc></url>
9-
<url><loc>https://xargas.eu/2025/02/05/bashPromptMachineIcon.html</loc></url>
10-
<url><loc>https://xargas.eu/2025/01/23/buildFreeCAD.html</loc></url>
11-
<url><loc>https://xargas.eu/2025/01/22/start.html</loc></url>
6+
<url><loc>https://xargas.eu/blog/page2/</loc></url>
127

138

149
<url><loc>https://xargas.eu/3dmodel/index.html</loc></url>
@@ -23,5 +18,6 @@
2318
<url><loc>https://xargas.eu/2025/02/05/bashPromptMachineIcon.html</loc></url>
2419
<url><loc>https://xargas.eu/2025/02/05/nginxWithPihole.html</loc></url>
2520
<url><loc>https://xargas.eu/2025/02/06/gnuScreenSshLogin.html</loc></url>
21+
<url><loc>https://xargas.eu/2025/02/06/laravelSetupOnPi.html</loc></url>
2622

2723
</urlset>

0 commit comments

Comments
 (0)