add vhost-php-fpm-socket-helper.service, recreates /run/php/php-fpm-vpanel.sock on reboot
This commit is contained in:
parent
8960fb9ae7
commit
be9310ae7e
|
@ -3,6 +3,10 @@ apt-get install -y sudo
|
||||||
useradd --no-create-home --home-dir /srv/www/html/panel --shell /usr/sbin/nologin --system --user-group vpanel
|
useradd --no-create-home --home-dir /srv/www/html/panel --shell /usr/sbin/nologin --system --user-group vpanel
|
||||||
cp bin/vpanel-verify-access.sh /usr/local/bin/
|
cp bin/vpanel-verify-access.sh /usr/local/bin/
|
||||||
chmod 755 /usr/local/bin/vpanel-verify-access.sh
|
chmod 755 /usr/local/bin/vpanel-verify-access.sh
|
||||||
|
cp sbin/vhost-php-fpm-socket-helper.sh /usr/local/sbin
|
||||||
|
chmod 755 /usr/local/sbin/vhost-php-fpm-socket-helper.sh
|
||||||
|
cp systemd/vhost-php-fpm-socket-helper.service /usr/local/lib/systemd/system/
|
||||||
|
chmod 644 /usr/local/lib/systemd/system/vhost-php-fpm-socket-helper.service
|
||||||
# set PHP version
|
# set PHP version
|
||||||
PHP_MAJOR_VERSION=`php -r "echo PHP_MAJOR_VERSION;"`
|
PHP_MAJOR_VERSION=`php -r "echo PHP_MAJOR_VERSION;"`
|
||||||
PHP_MINOR_VERSION=`php -r "echo PHP_MINOR_VERSION;"`
|
PHP_MINOR_VERSION=`php -r "echo PHP_MINOR_VERSION;"`
|
||||||
|
@ -19,6 +23,7 @@ update-alternatives --install /run/php/php-fpm-vpanel.sock php-fpm-vpanel.sock /
|
||||||
a2enconf vpanel
|
a2enconf vpanel
|
||||||
service php$phpVersion-fpm restart
|
service php$phpVersion-fpm restart
|
||||||
service apache2 restart
|
service apache2 restart
|
||||||
|
systemctl enable vhost-php-fpm-socket-helper.service
|
||||||
cp -a panel /srv/www/html/
|
cp -a panel /srv/www/html/
|
||||||
mkdir /srv/www/html/panel/tmp
|
mkdir /srv/www/html/panel/tmp
|
||||||
git clone https://github.com/bcosca/fatfree-core.git /srv/www/html/panel/f3
|
git clone https://github.com/bcosca/fatfree-core.git /srv/www/html/panel/f3
|
||||||
|
|
32
sbin/vhost-php-fpm-socket-helper.sh
Executable file
32
sbin/vhost-php-fpm-socket-helper.sh
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# vhost-stack
|
||||||
|
# https://git.stack-source.com/msb/vhost-stack
|
||||||
|
# Copyright (c) 2024 Matthew Saunders Brown <matthewsaundersbrown@gmail.com>
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
# check for missing /run/php/php-fpm-vpanel.sock link
|
||||||
|
if [[ ! -L /run/php/php-fpm-vpanel.sock ]]; then
|
||||||
|
# check for existing alternatives and use that if it's set
|
||||||
|
if [[ -L /etc/alternatives/php-fpm-vpanel.sock ]]; then
|
||||||
|
SOCKET=`readlink /etc/alternatives/php-fpm-vpanel.sock`
|
||||||
|
if [[ -S $SOCKET ]]; then
|
||||||
|
/usr/bin/update-alternatives --quiet --set php-fpm-vpanel.sock $SOCKET
|
||||||
|
else
|
||||||
|
echo "ERROR: Socket $SOCKET does not exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# alternatives not set for php-fpm-vpanel.sock, get current php-cli version and use that
|
||||||
|
PHP_MAJOR_VERSION=`php -r "echo PHP_MAJOR_VERSION;"`
|
||||||
|
PHP_MINOR_VERSION=`php -r "echo PHP_MINOR_VERSION;"`
|
||||||
|
SOCKET=/run/php/php$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION-fpm-vpanel.sock
|
||||||
|
PRIORITY=$PHP_MAJOR_VERSION$PHP_MINOR_VERSION
|
||||||
|
if [[ -S $SOCKET ]]; then
|
||||||
|
update-alternatives --quiet --install /run/php/php-fpm-vpanel.sock php-fpm-vpanel.sock $SOCKET $PRIORITY
|
||||||
|
else
|
||||||
|
echo "ERROR: Socket $SOCKET does not exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
12
systemd/vhost-php-fpm-socket-helper.service
Normal file
12
systemd/vhost-php-fpm-socket-helper.service
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[Unit]
|
||||||
|
After=network.target local-fs.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
# sleep to give time for php-fpm to start first
|
||||||
|
# testing showed 2 seconds enough, using 5 for exra buffer
|
||||||
|
ExecStartPre=sleep 5
|
||||||
|
ExecStart=/usr/local/sbin/vhost-php-fpm-socket-helper.sh
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user