add support for multiple php versions

This commit is contained in:
Matthew Saunders Brown 2024-09-18 12:36:22 -07:00
parent 44ab5759a8
commit 48f80379a4
7 changed files with 51 additions and 12 deletions

View File

@ -63,6 +63,18 @@ class Panel {
echo \Template::instance()->render('home.html');
}
public static function setPHPVersions($f3) {
$phpFPMVersion = readlink("/etc/alternatives/php-fpm.sock");
$phpFPMVersion = str_replace('/run/php/php', '', $phpFPMVersion);
$phpFPMVersion = str_replace('-fpm.sock', '', $phpFPMVersion);
exec("/usr/bin/update-alternatives --list php-fpm.sock | sed 's|/run/php/php||g' | cut -d \- -f 1", $phpFPMVersionsArray);
$f3->set('PHP.fpm_version', $phpFPMVersion);
$f3->set('PHP.fpm_versions_array', $phpFPMVersionsArray);
$f3->set('PHP.fpm_version_count', count($phpFPMVersionsArray));
}
public static function validateEmail($email) {
global $f3;

View File

@ -35,6 +35,12 @@ class VhostsAdd extends \Panel\Vhost {
$deploy['showwriteinfo'] = 0;
}
/* set php fpm version vars */
$f3->call('\Panel::setPHPVersions', $f3);
$deploy['fpm_version'] = $f3->get('PHP.fpm_version');
$deploy['fpm_versions_array'] = $f3->get('PHP.fpm_versions_array');
$deploy['fpm_version_count'] = $f3->get('PHP.fpm_version_count');
$f3->set('deploy', $deploy);
/* check if VHOSTLIMIT is set */
@ -76,7 +82,8 @@ class VhostsAdd extends \Panel\Vhost {
$f3->set('SESSION.messages', $messages);
$f3->reroute("/Websites/Add");
} else {
$cmd = "/usr/local/bin/vhost-deploy.sh -d $domain";
$fpm_version = $_POST['fpm_version'];
$cmd = "/usr/local/bin/vhost-deploy.sh -d $domain -f $fpm_version";
}
} else {
$f3->reroute("/Websites/Add");

View File

@ -8,4 +8,5 @@
/ [sync] = Panel\Vhost\Vhosts
/Login [sync] = Panel\Login
/Logout [sync] = Panel\Logout
/Websites/@vhost/Edit [sync] = Panel\Vhost\VhostsEdit
/Users/@username/Edit [sync] = Panel\Vhost\UsersEdit

View File

@ -41,6 +41,7 @@
/Websites [sync] = Panel\Vhost\Vhosts
/Websites/Add [sync] = Panel\Vhost\VhostsAdd
/Websites/@vhost [sync] = Panel\Vhost\Vhosts
/Websites/@vhost/Edit [sync] = Panel\Vhost\VhostsEdit
/Websites/@vhost/Disable [sync] = Panel\Vhost\VhostsDisable
/Websites/@vhost/Enable [sync] = Panel\Vhost\VhostsEnable
/Websites/@vhost/Delete [sync] = Panel\Vhost\VhostsDelete

View File

@ -30,6 +30,7 @@
<th>Website</th>
<th>Username</th>
<th>Status</th>
<th>PHP Version</th>
<th>Action</th>
</tr>
@ -39,6 +40,7 @@
<td><a href="{{@BASE}}/Websites/{{ @vhost_domain.virtualhost }}">{{ @vhost_domain.virtualhost }}</a></td>
<td>{{ @vhost_domain.username }}</td>
<td>{{ @vhost_domain.status }}</td>
<td>{{ @vhost_domain.php }}</td>
<td><a href="{{@BASE}}/Websites/{{ @vhost_domain.virtualhost }}/Disable">Disable</a> <a href="{{@BASE}}/Websites/{{ @vhost_domain.virtualhost }}/Delete">Delete</a></td>
</tr>

View File

@ -7,6 +7,20 @@
<label for="domain">Domain Name <small>(Do not include 'www', that will be aliased to the main domain)</small></label>
<input id="domain" name="domain" type="text" placeholder="example.com" value="" required>
<label for="fpm_version">PHP Version <small>(Version of PHP to enable for this website - default is {{ @deploy.fpm_version }})</small></label>
<select id="fpm_version" name="fpm_version">
<repeat group="{{ @deploy.fpm_versions_array }}" value="{{ @fpm_version }}">
<check if="{{ @fpm_version==@deploy.fpm_version }}">
<true>
<option value="{{ @fpm_version }}" selected>{{ @fpm_version }}</option>
</true>
<false>
<option value="{{ @fpm_version }}">{{ @fpm_version }}</option>
</false>
</check>
</repeat>
</select>
<label for="username">Username <small>(Used for SSH & SFTP access, leave empty to auto-create new user)</small></label>
<select id="username" name="username">
<check if="{{ @deploy.username=='' }}">
@ -44,6 +58,7 @@
<p>
<b>Domain Name</b> Enter the website domain name without the leading www.<br>
<b>PHP Version</b> It's recommended to either use the default version (listed above) or the very latest version (highest number) if that works for your website. Only use an older version if you absolutely must do so to make your website code work.<br>
<b>Username</b> By default this should be left blank which will create a new (unique) username just for this site. Optionally you can pick from a list of existing users, or first go to the User admin and create a specific username &amp; password.<br>
</p>

View File

@ -1,30 +1,31 @@
<include href="header.html" />
<check if="{{ @NAV.mapping=='vpanel' }}">
<table>
<tr>
<th>Website</th>
<th>Status</th>
<th>PHP Version</th>
<th>Action</th>
</tr>
<tr>
<td>{{ @vhost_array.virtualhost }}</td>
<td>{{ @vhost_array.status }}</td>
<td>{{ @vhost_array.php }}</td>
<td>
<a href="{{@BASE}}/Websites/{{ @vhost_array.virtualhost }}/Edit">Edit</a>
<check if="{{ @NAV.mapping=='vpanel' }}">
<check if="{{ @vhost_array.status=='Enabled' }}">
<true><a href="{{@REALM}}/Disable">Disable</a></true>
<false><a href="{{@REALM}}/Enable">Enable</a></false>
</check>
<a href="{{@REALM}}/Delete">Delete</a>
</check>
</td>
</tr>
</table>
<br><br>
</check>
<table>
<tr>
<th>System User</th>