Skip to content

Commit

Permalink
πŸ”€ Backported changes from 0.3 to 0.2 (#4)
Browse files Browse the repository at this point in the history
 - πŸ“ Improved install / usage instructions
 - πŸ’‘ Added deprecation notice in comments
 - βž– Dropped support of `tcpserver`
 - This will make the local server much faster on remote access
  • Loading branch information
Jiab77 committed Nov 17, 2021
1 parent 8554c30 commit d401739
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ _If you were looking for a `nodejs` version: <https://github.com/Jiab77/libvirt-

The installation process is pretty simple and will require only few dependencies.

The web interface should be able to run on desktops and servers.
The web interface should be able to run on any desktops and servers.

## Dependencies

Expand Down Expand Up @@ -53,8 +53,11 @@ sudo apt install libvirt-bin virt-viewer virtinst libguestfs-tools php-cli php-g
# For server
sudo apt install libvirt-bin virtinst libguestfs-tools php-cli php-gd php-xml php-json

# For PHP < 7.4
sudo apt install ucspi-tcp
# Restart
sudo reboot

# Check services status
systemctl status libvirt-bin.service libvirt-guests.service libvirtd.service -l
```

> I still need to validate the packages list so this might change later.
Expand All @@ -76,14 +79,26 @@ cd libvirt-web
./start-local-server.sh
```

If you want to run the server on another interface / port, you can also do the following:

```bash
# Set another listen interface (it will catch the first IP address in this case)
LISTEN_INTERFACE=`hostname -I | awk '{ print $1 }'` ./start-web-server.sh

# Set another listen interface (it will catch the FQDN in this case)
LISTEN_INTERFACE=`hostname -f` ./start-web-server.sh

# Set another list port
LISTEN_PORT=8888 ./start-web-server.sh

# Set another listen interface and port
LISTEN_INTERFACE=`hostname -f` LISTEN_PORT=8888 ./start-web-server.sh
```

> `sudo` is not required to run the server. It is required only if you want to run the server on a port below **1024**.
>
> You can also choose any other ports than **8000**.
Then navigate to [http://localhost:8000](http://localhost:8000) with your internet browser.

> I'm using Chromium but it should work on any other modern browser.
### Apache / nginx

This setup is not tested yet and will be documented later.
Expand Down Expand Up @@ -111,6 +126,10 @@ Here will be listed missing features / those not working correctly.
* This is due to access restricted to `sudoers` with filesystem permissions.
* Graphics are still missing.

## Supported Browsers

I'm using Chromium but it should work on any other modern browser.

## Thanks

Thanks to the respective developers for their amazing work.
Expand Down
4 changes: 4 additions & 0 deletions proxy-to-php-server.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash -x

# Proxy requests from tcpserver (ucspi-tcp)
#
# Deprecated and not used anymore
#
# Increasing local web server performances as possible
# https://stackoverflow.com/questions/39842170/load-balancing-php-built-in-server/47103758#47103758

Expand Down
17 changes: 10 additions & 7 deletions start-web-server.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash

# Minimal PHP server wrapper script
#
# Increasing local web server performances as possible
# https://stackoverflow.com/questions/39842170/load-balancing-php-built-in-server/47103758#47103758
# https://www.php.net/manual/en/features.commandline.webserver.php

# Config
LISTEN_INTERFACE="localhost"
LISTEN_PORT=8000
LISTEN_INTERFACE=${LISTEN_INTERFACE:-localhost}
LISTEN_PORT=${LISTEN_PORT:-8000}

# Detect server type to use
PHP_SRV_TYPE=$(php -r "if (version_compare(phpversion(), '7.4', '<')) { echo 'tcpserver'; } else { echo 'embedded'; }")
PHP_SRV_TYPE=$(php -r "if (version_compare(phpversion(), '7.4', '<')) { echo 'singlecore'; } else { echo 'multicore'; }")

# Run detected server type
if [[ $PHP_SRV_TYPE == 'embedded' ]]; then
PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php
if [[ $PHP_SRV_TYPE == 'multicore' ]]; then
# PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php
PHP_CLI_SERVER_WORKERS=$(nproc) php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} -t .
else
tcpserver -v -1 0 ${LISTEN_PORT} ./proxy-to-php-server.sh ./libvirtweb.php
# php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} libvirtweb.php
php -S ${LISTEN_INTERFACE}:${LISTEN_PORT} -t .
fi

0 comments on commit d401739

Please sign in to comment.