Custom Vhost configurations

NethServer Version: 8
Module: Webserver

Greetings - I’m finally getting around to moving from Nethserver 7 to Nethserver 8, and am trying to set up Ampache. There area a few things I can’t work out.

Ampache recmmends using composer - but I can’t see how to run php from the command line.

Ampache also needs the document root to be set to a folder called ‘public’. I’ve tried putting configuration settings into the vhost.custom file in the /home/webserver1/.config/state/conf.d directory, but whatever I put in there causes both my vhosts to return ‘bad gateway’. If I try removing the configuration, I get 404 not found. The only way to get back to the working configuration is to go to the web admin page and save the settings for the vhost.

What do I need in the custom configuration file to change the root directory, and whats the best way to reload the configuration for the vhosts?

You may also check out ns8-lamp/README.md at main · stephdl/ns8-lamp · GitHub instead of using webserver as it provides a single apache php container which could be easier to configure as regards ampache.

If PHP 8.3 is enabled for the vhost in UI then following should work to use php:

runagent -m webserver1 podman exec -ti php8.3-fpm php -v

Could you please share a link to the documentation about configuring document root and what you exactly tried?

nginx

  • add a dyn-9001.custom to /home/webserver1/.config/state/conf.d/
  • vim /home/webserver1/.config/state/conf.d/dyn-9001.custom and write a valid nginx configuration
  • set the file ownership to webserver1 : chown webserver1:webserver1 /home/webserver1/.config/state/conf.d/dyn-9001.custom

I have tried

    location / {
        root   /usr/share/nginx/html/9002/public;
        index  index.html index.htm index.php;
        autoindex on;
    }
    location / {
        root   /usr/share/nginx/html/9002/public;
    }

Then

      root   /usr/share/nginx/html/9002/public;
     
server {

    location / {
        root   /usr/share/nginx/html/9002;
        index  index.html index.htm index.php;
        autoindex on;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html/9002;
    }



    location ~ \.php$ {
        root   /usr/share/nginx/html/9002;
        try_files $uri =404;
        fastcgi_pass 127.0.0.1:9002;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  /app/9002$fastcgi_script_name;
    }

}

And various variations. I see today

 [1:webserver1:nginx] nginx: [emerg] duplicate location "/" in /etc/nginx/conf.d/dyn-9002.conf:8

in the logs.

using

systemctl restart --user --now webserver.service

to restart the webserver. Just deleted the .custom config file, restarted, and get a 404 error for the vhost. Saving the vhost configuration in the web console fixes it.

I’m sorry. that’s not possible.

The .custom file is included inside the server option of nginx:

server {
    listen	 80;
    listen  [::]:80;
    server_name joomla.ns8rockytest.com;

    include /etc/nginx/conf.d/dyn-9001[.]custom;

So it’s intended to add options but not to change the default location as that will be seen as

On the one hand it should be possible to install it in webserver, on the other hand there’s also an ampache docker project: https://hub.docker.com/r/ampache/ampache
@stephdl is an NS8 app of ampache [NethServer & NethSecurity] on your todo list?

1 Like

ns8-lamp gives you access to php cli

1 Like

That looks interesting. I might take a look at that when I get time :slight_smile:

The php command above works as well. I might just try the Nextcloud music app - if it has improved performance, it might be enough for me.

There is a version of Ampache that doesn’t need the root to be set to public. Might just go with that.

1 Like