diff --git a/README.md b/README.md index 2738d002..2d4a0c30 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ Get the latest stable release and build it: git clone https://github.com/epoupon/lms.git lms cd lms mkdir build +cd build cmake .. -DCMAKE_BUILD_TYPE=Release ``` __Note__: in order to customize the installation directory, you can use the _-DCMAKE_INSTALL_PREFIX_ option (defaults to `/usr/local`). @@ -163,6 +164,19 @@ All other settings are set using the web interface (user management, scan settin If a setting is not present in the configuration file, a hardcoded default value is used (the same as in the [default.conf](https://github.com/epoupon/lms/blob/master/conf/lms.conf) file) +### Deploy on non root path +If you want to deploy on non root path (e.g. https://mydomain.com/newroot/), you have to set the `deploy-path` option accordingly in `lms.conf`. + +As static resources are __not__ related to the `deploy-path` option, you have to perform the following steps if you want them to be on a non root path too: +* Create a new intermediary `newroot` directory in `/usr/share/lms/docroot` and move everything in it. +* Symlink `/usr/share/lms/docroot/newroot/resources` to `/usr/share/Wt/resources`. +* Edit `lms.conf` and set: +``` +wt-resources = "" # do not comment the whole line +docroot = "/usr/share/lms/docroot/;/newroot/resources,/newroot/css,/newroot/images,/newroot/js,/newroot/favicon.ico";` +deploy-path = "/newroot/"; # ending slash is important +``` + ### Reverse proxy settings _LMS_ is shipped with an embedded web server, but it is recommended to deploy behind a reverse proxy. You have to set the _behind-reverse-proxy_ option to _true_ in the `lms.conf` configuration file. diff --git a/conf/lms.conf b/conf/lms.conf index 04d48d54..e1666f60 100644 --- a/conf/lms.conf +++ b/conf/lms.conf @@ -18,19 +18,18 @@ listen-port = 5082; listen-addr = "0.0.0.0"; behind-reverse-proxy = false; -# Location for deployment -deploy-path = "/"; - # If enabled, these files have to exist and have correct permissions tls-enable = false; tls-cert = "/var/lms/cert.pem"; tls-key = "/var/lms/privkey.pem"; tls-dh = "/var/lms/dh2048.pem"; -# Path to the resources used by the web interface +# Path to the resources used by the web interface. wt-resources = "/usr/share/Wt/resources"; docroot = "/usr/share/lms/docroot/;/resources,/css,/images,/js,/favicon.ico"; approot = "/usr/share/lms/approot"; +# Location for deployment (See README if you want to deploy on a non root path) +deploy-path = "/"; # Acoustic brainz's root API acousticbrainz-api-url = "https://acousticbrainz.org/api/v1/"; diff --git a/src/lms/main.cpp b/src/lms/main.cpp index 39d7eb15..bbaa1985 100644 --- a/src/lms/main.cpp +++ b/src/lms/main.cpp @@ -43,13 +43,15 @@ std::vector generateWtConfig(std::string execPath) const std::filesystem::path wtConfigPath {ServiceProvider::get()->getPath("working-dir") / "wt_config.xml"}; const std::filesystem::path wtLogFilePath {ServiceProvider::get()->getPath("log-file", "/var/log/lms.log")}; const std::filesystem::path wtAccessLogFilePath {ServiceProvider::get()->getPath("access-log-file", "/var/log/lms.access.log")}; + const std::filesystem::path wtResourcesPath {ServiceProvider::get()->getPath("wt-resources", "/usr/share/Wt/resources")}; args.push_back(execPath); args.push_back("--config=" + wtConfigPath.string()); args.push_back("--docroot=" + ServiceProvider::get()->getString("docroot")); args.push_back("--approot=" + ServiceProvider::get()->getString("approot")); args.push_back("--deploy-path=" + ServiceProvider::get()->getString("deploy-path", "/")); - args.push_back("--resources-dir=" + ServiceProvider::get()->getString("wt-resources")); + if (!wtResourcesPath.empty()) + args.push_back("--resources-dir=" + wtResourcesPath.string()); if (ServiceProvider::get()->getBool("tls-enable", false)) { diff --git a/src/lms/ui/LmsApplication.cpp b/src/lms/ui/LmsApplication.cpp index 1dfb5b30..f4435008 100644 --- a/src/lms/ui/LmsApplication.cpp +++ b/src/lms/ui/LmsApplication.cpp @@ -153,9 +153,9 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, messageResourceBundle().use(appRoot() + "tracksinfo"); // Require js here to avoid async problems - requireJQuery("/js/jquery-1.10.2.min.js"); - require("/js/mediaplayer.js"); - require("/js/bootstrap-notify.js"); + requireJQuery("js/jquery-1.10.2.min.js"); + require("js/mediaplayer.js"); + require("js/bootstrap-notify.js"); setTitle("LMS"); @@ -293,7 +293,7 @@ LmsApplication::handleException(LmsApplicationException& e) btn->clicked().connect([this]() { setConfirmCloseMessage(""); - redirect("/"); + redirect("."); }); } @@ -302,7 +302,7 @@ LmsApplication::goHomeAndQuit() { setConfirmCloseMessage(""); WApplication::quit(""); - redirect("/"); + redirect("."); } enum IdxRoot