Skip to content

Commit fcd4a3e

Browse files
committed
add default content into "package" folder
1 parent 806dc61 commit fcd4a3e

9 files changed

Lines changed: 2114 additions & 52 deletions

File tree

build-packages.sh

100755100644
Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ os="$(uname -s | tr '[:upper:]' '[:lower:]')"
2727
bin="frankenphp-${os}-${arch}"
2828

2929
if [ ! -f "dist/$bin" ]; then
30-
echo "Error: $bin not found. Run './build-static.sh' first"
30+
echo "Error: dist/$bin not found. Run './build-static.sh' first"
3131
exit 1
3232
fi
3333

@@ -36,67 +36,23 @@ if [[ ! "${FRANKENPHP_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
3636
exit 1
3737
fi
3838

39-
cat <<EOF >dist/frankenphp.service
40-
[Unit]
41-
Description=FrankenPHP server
42-
After=network.target
43-
44-
[Service]
45-
Type=notify
46-
User=caddy
47-
Group=caddy
48-
ExecStartPre=/usr/bin/frankenphp validate --config /etc/frankenphp/Caddyfile
49-
ExecStart=/usr/bin/frankenphp run --environ --config /etc/frankenphp/Caddyfile
50-
ExecReload=/usr/bin/frankenphp reload --config /etc/frankenphp/Caddyfile
51-
TimeoutStopSec=5s
52-
LimitNOFILE=1048576
53-
LimitNPROC=512
54-
PrivateTmp=true
55-
ProtectHome=true
56-
ProtectSystem=full
57-
AmbientCapabilities=CAP_NET_BIND_SERVICE
58-
59-
[Install]
60-
WantedBy=multi-user.target
61-
EOF
62-
63-
cat <<EOF >dist/Caddyfile
64-
# The Caddyfile is an easy way to configure your Caddy web server.
65-
#
66-
# https://caddyserver.com/docs/caddyfile
67-
# https://frankenphp.dev/docs/config
68-
{
69-
# enable the frankenphp module, otherwise "php_server" and "php" directives do not work
70-
frankenphp {
71-
# optionally set max_threads, num_threads and create workers here
72-
}
73-
}
74-
75-
http:// {
76-
root * /usr/share/caddy
77-
php_server
78-
file_server
79-
}
80-
81-
# As an alternative to editing the above site block, you can add your own site
82-
# block files in the Caddyfile.d directory, and they will be included as long
83-
# as they use the .caddyfile extension.
84-
85-
import Caddyfile.d/*.caddyfile
86-
EOF
87-
8839
iteration="1"
8940
cd dist
9041
glibc_version=$(ldd -v "$bin" | awk '/GLIBC_/ {gsub(/[()]/, "", $2); print $2}' | grep -v GLIBC_PRIVATE | sort -V | tail -n1)
9142
cxxabi_version=$(strings "$bin" | grep -oP 'CXXABI_\d+\.\d+(\.\d+)?' | sort -V | tail -n1)
9243

9344
fpm -s dir -t rpm -n frankenphp -v "${FRANKENPHP_VERSION}" \
9445
--config-files /etc/frankenphp/Caddyfile \
46+
--config-files /etc/frankenphp/php.ini \
9547
--depends "libc.so.6(${glibc_version})(64bit)" \
9648
--depends "libstdc++.so.6(${cxxabi_version})(64bit)" \
9749
"$bin=/usr/bin/frankenphp" \
98-
"./frankenphp.service=/usr/lib/systemd/system/frankenphp.service" \
99-
"./Caddyfile=/etc/frankenphp/Caddyfile"
50+
"../package/frankenphp.service=/usr/lib/systemd/system/frankenphp.service" \
51+
"../package/Caddyfile=/etc/frankenphp/Caddyfile" \
52+
"../package/etc/php.ini=/etc/frankenphp/php.ini" \
53+
"../package/etc/php.d/=/etc/frankenphp/php.d" \
54+
"../package/content/=/usr/share/frankenphp" \
55+
"../package/modules/=/usr/lib/frankenphp/modules"
10056

10157
rpm_file="frankenphp-${FRANKENPHP_VERSION}-${iteration}.${arch}.rpm"
10258

caddy/frankenphp/Caddyfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
{
24
{$CADDY_GLOBAL_OPTIONS}
35

@@ -43,3 +45,9 @@
4345

4446
php_server
4547
}
48+
49+
# As an alternative to editing the above site block, you can add your own site
50+
# block files in the Caddyfile.d directory, and they will be included as long
51+
# as they use the .caddyfile extension.
52+
53+
import Caddyfile.d/*.caddyfile

package/Caddyfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# The Caddyfile is an easy way to configure your Caddy web server.
2+
#
3+
# https://caddyserver.com/docs/caddyfile
4+
# https://frankenphp.dev/docs/config
5+
6+
{
7+
{$CADDY_GLOBAL_OPTIONS}
8+
9+
frankenphp {
10+
worker /usr/share/frankenphp/index.php
11+
{$FRANKENPHP_CONFIG}
12+
}
13+
}
14+
15+
{$CADDY_EXTRA_CONFIG}
16+
17+
{$SERVER_NAME:localhost} {
18+
#log {
19+
# # Redact the authorization query parameter that can be set by Mercure
20+
# format filter {
21+
# request>uri query {
22+
# replace authorization REDACTED
23+
# }
24+
# }
25+
#}
26+
27+
root * /usr/share/frankenphp
28+
encode zstd br gzip
29+
30+
# Uncomment the following lines to enable Mercure and Vulcain modules
31+
#mercure {
32+
# # Transport to use (default to Bolt)
33+
# transport bolt {
34+
# mercure.db
35+
# }
36+
# # Publisher JWT key
37+
# publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
38+
# # Subscriber JWT key
39+
# subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
40+
# # Allow anonymous subscribers (double-check that it's what you want)
41+
# anonymous
42+
# # Enable the subscription API (double-check that it's what you want)
43+
# subscriptions
44+
# # Extra directives
45+
# {$MERCURE_EXTRA_DIRECTIVES}
46+
#}
47+
#vulcain
48+
49+
{$CADDY_SERVER_EXTRA_DIRECTIVES}
50+
51+
php_server
52+
}
53+

package/content/example.php

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?php
2+
$requestCount = $i ?? 0;
3+
$requestTime = $duration ?? 0;
4+
?>
5+
6+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
7+
8+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
9+
<head>
10+
<title>Test Page for FrankenPHP on AlmaLinux</title>
11+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
12+
<style type="text/css">
13+
body {
14+
background-color: #FAF5F5;
15+
color: #000;
16+
font-size: 0.9em;
17+
font-family: sans-serif,helvetica;
18+
margin: 0;
19+
padding: 0;
20+
}
21+
:link, :visited {
22+
color: #0B2335;
23+
}
24+
a:hover {
25+
color: #0069DA;
26+
}
27+
h1 {
28+
text-align: center;
29+
margin: 0;
30+
padding: 0.6em 2em 0.4em;
31+
background-color: #0B2335;
32+
color: #fff;
33+
font-weight: normal;
34+
font-size: 1.75em;
35+
border-bottom: 2px solid #000;
36+
}
37+
h1 strong {
38+
font-weight: bold;
39+
}
40+
h2 {
41+
font-size: 1.1em;
42+
font-weight: bold;
43+
}
44+
hr {
45+
display: none;
46+
}
47+
.content {
48+
padding: 1em 5em;
49+
}
50+
.content-columns {
51+
position: relative;
52+
padding-top: 1em;
53+
}
54+
.content-column-left, .content-column-right {
55+
width: 47%;
56+
float: left;
57+
padding-bottom: 2em;
58+
}
59+
.content-column-left {
60+
padding-right: 3%;
61+
}
62+
.content-column-right {
63+
padding-left: 3%;
64+
}
65+
.logos {
66+
text-align: center;
67+
margin-top: 2em;
68+
}
69+
img {
70+
border: 2px solid #fff;
71+
padding: 2px;
72+
margin: 2px;
73+
}
74+
a:hover img {
75+
border: 2px solid #f50;
76+
}
77+
.footer {
78+
clear: both;
79+
text-align: center;
80+
font-size: xx-small;
81+
}
82+
.runtime-info {
83+
background: #efefef;
84+
padding: 0.5em;
85+
margin-top: 1em;
86+
font-size: 0.85em;
87+
border-left: 3px solid #0B2335;
88+
}
89+
</style>
90+
</head>
91+
92+
<body>
93+
<h1>FrankenPHP <strong>Test Page</strong></h1>
94+
95+
<div class="content">
96+
<div class="content-middle">
97+
<p>This page confirms that the HTTP server powered by FrankenPHP (via the Caddy web server) is operating correctly on this system.</p>
98+
</div>
99+
<hr />
100+
101+
<div class="content-columns">
102+
<div class="content-column-left">
103+
<h2>If you are a visitor:</h2>
104+
105+
<p>This default page means the site you tried to access is set up, but no specific content has been deployed yet.</p>
106+
107+
<p>If you were expecting a different site, it's possible the owner hasn't uploaded any content, or they’re currently making updates.</p>
108+
109+
<p>If you wish to notify the site administrator, try contacting "webmaster" at the domain you visited. For example: webmaster@example.com.</p>
110+
111+
<p>Learn more about FrankenPHP at the <a href="https://frankenphp.dev/">official website</a>.</p>
112+
<hr />
113+
</div>
114+
115+
<div class="content-column-right">
116+
<h2>If you are the administrator:</h2>
117+
118+
<p>Your server is running and serving requests using FrankenPHP, integrated as a module within Caddy.</p>
119+
120+
<p>To replace this page, simply deploy your application files to the configured web root directory in your Caddy setup. If you’re using PHP, FrankenPHP will handle it natively.</p>
121+
122+
<p>Configuration is handled in your <code>Caddyfile</code>. Make sure your <code>root</code> and <code>php_server</code> directives are properly set for your site.</p>
123+
124+
<div class="runtime-info">
125+
<strong>Requests handled:</strong> <?php echo htmlspecialchars($requestCount); ?><br />
126+
<strong>Last request time:</strong> <?php echo $requestTime; ?> microseconds
127+
</div>
128+
129+
<div class="logos">
130+
<a href="https://frankenphp.dev/"><img src="assets/frankenphp.png" height="56" width="174" alt="[ Powered by FrankenPHP ]" /></a>
131+
<a href="https://caddyserver.com/"><img src="assets/caddy.png" alt="[ Powered by Caddy ]" /></a>
132+
</div>
133+
</div>
134+
</div>
135+
</div>
136+
<div class="footer">
137+
<a href="https://frankenphp.dev">FrankenPHP</a> is an open-source web server module for PHP built on top of <a href="https://caddyserver.com">Caddy</a>.
138+
</div>
139+
</body>
140+
</html>
5.37 KB
Loading
176 KB
Loading

package/content/public/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$i = 0;
4+
$duration = 0;
5+
do {
6+
$ok = frankenphp_handle_request(function () use ($i, &$duration): void {
7+
$startTime = microtime(false);
8+
echo include __DIR__ . '/../example.php';
9+
$endTime = microtime(false);
10+
$duration = (float)$endTime - (float)$startTime;
11+
});
12+
13+
$i++;
14+
} while ($ok);

0 commit comments

Comments
 (0)