Code Monkey home page Code Monkey logo

ubuntu-nginx-lucee's Introduction

ubuntu-nginx-lucee

CI

A set of bash scripts for standing up a Lucee server using nginx and Tomcat on Ubuntu. Uses the Tomcat from the Ubuntu distribution so you can update Tomcat using apt-get update tomcat9

Important Note

The master branch is now using Ubuntu 20.04 (and is currently a bit unstable). For Lucee 5 on Ubuntu 16.04 or 18.04 see the branch lucee5-ubuntu18, for Lucee 4.5 see the lucee45-ubuntu14 branch.

Why would I use this instead of the offical Lucee installers?

  • You want to run nginx as your web server
  • You want to update Tomcat via apt-get

Note: when this script was first created Tomcat was part of the main repository on Ubuntu, it is now part of universal which means it is community updated. I've noticed that it is not getting updated with security patches frequently like it did when it was part of main. This means you will still want to keep an eye on Tomcat Security. You can use HackMyCF (made by foundeo) to help you monitor when your server needs to be updated. Even if you use the default lucee installer, you will still need to keep an eye on the version of Tomcat you are running.

What does it do?

  1. Updates Ubuntu - simply runs apt-get update and apt-get upgrade
  2. Downloads Lucee - uses curl to download lucee jars from BitBucket places jars in /opt/lucee/current/
  3. Installs & Configures Tomcat 8 - runs apt-get install tomcat9 updates the web.xml server.xml and catalina.properties to configure Lucee servlets and mod_cfml Valve. (Tomcat/Lucee run on port 8080 by default).
  4. JVM - in previous versions this step installed an Oracle JVM, but now we just use OpenJDK.
  5. Installs & Configures nginx - runs apt-get install nginx to install nginx. Creates a web root directory. Creates a lucee.config file so you can just include lucee.config for any site that uses CFML
  6. Set Default Lucee Admin Password - uses cfconfig to set the Lucee server context password and default web context password. If environment variable ADMIN_PASSWORD exists that is used, otherwise a random password is set.

Take a look in the scripts/ subfolder to see the script for each step.

How do I run it?

  1. Download this repository - curl -Lo /root/ubuntu-nginx-lucee.tar.gz https://api.github.com/repos/foundeo/ubuntu-nginx-lucee/tarball/master
  2. Extract repository - tar -xzvf /root/ubuntu-nginx-lucee.tar.gz
  3. Configuration - You can either Edit the install.sh and change any configuration options such as the Lucee Version or JVM version - or you can use environment variables (see below).
  4. Run install.sh - make sure you are root or sudo and run ./install.sh you may need to chmod u+x install.sh to give execute permissions to the script.

Limitations / Known Issues

  • The servlet definitions and mappings (located in /etc/tomcat9/web.xml) are slimmed down, so if you need things like REST web services, flash/flex remoting support see the Railo docs for web.xml config
  • The /lucee/ uri is blocked in /etc/nginx/lucee.conf you must add in your ip address and restart nginx.
  • There is no uninstall option
  • This version of the script has been tested on Ubuntu 20.04 LTS only. See the branches of this repository for older versions of Ubuntu / Lucee.

Environment Variables

The script can be configured with the following environment variables:

  • LUCEE_VERSION - sets the version of Lucee that it will attempt to install (eg 5.2.4.37).
  • JVM_MAX_HEAP_SIZE - sets the amount of memory that java / tomcat can use (eg 512m).
  • ADMIN_PASSWORD - sets the Lucee server context password and default web context password. If variable is not defined a random password is generated and set.
  • WHITELIST_IP - if specified this IP will be whitelisted to allow access to /lucee/
  • LUCEE_JAR_SHA256 - if specified checks the sha256sum of the the downloaded lucee.jar

Setting up a Virtual Host

By default nginx on Ubuntu looks in the folder /etc/nginx/sites-enabled/ for configuration nginx files. To setup a site create a file in that folder (another technique you can use is to create the file in /etc/nginx/sites-available/ and then create a symbolic link in sites-enabled to enable the site), for example /etc/nginx/sites-enabled/me.example.com.conf at a minimum it will look like this:

server {
	listen 80;
	server_name me.example.com;
	root /web/me.example.com/wwwroot/;
	include lucee.conf;
}

You may also want to break logging for this site out into its own file, like this:

server {
	listen 80;
	server_name me.example.com;
	root /web/me.example.com/wwwroot/;
	access_log /var/log/nginx/me.example.com.access.log;
	error_log /var/log/nginx/me.example.com.error.log;
	include lucee.conf;
}

If you don't need Lucee/CFML for a given site, simply omit the include lucee.conf; line, like this:

server {
	listen 80;
	server_name img.example.com;
	root /web/img.example.com/wwwroot/;
}

Create the symbolic link in sites-enabled to enable the site:

sudo ln -s /etc/nginx/sites-available/me.example.com.conf /etc/nginx/sites-enabled/

After making changes you need to restart or reload nginx:

sudo service nginx restart

For more information on configuring nginx see the nginx Wiki

Thanks go to Booking Boss for funding the initial work on this script.

ubuntu-nginx-lucee's People

Contributors

andrew-dixon avatar blusol850 avatar jonaseriksson avatar lxcodes avatar mvanleest avatar paulklinkenberg avatar pfreitag avatar ryanalbrecht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ubuntu-nginx-lucee's Issues

Allow env vars to be used instead of editing sh files

To make this more automated without people needing to edit the files, read settings from environment variables and then default to what's in the file. That will allow people to set env vars, clone this repo and just run it.

Is there a simple step-by-step tutorial

I have tried to get this going several times. I have even hired system's admins who have experience with nginx and tomcat (but not lucee) and none of us can get this going. I can't believe that there are not some tutorials on the web. Do you happen to have guidance for what to do after we install everything?

The server.xml file doesn't seem to be connecting to the nginx vhost at all. I can server up an index.html file fine but the index.cfm file does not work.

Any help out there?

Custom web folder

Not sure if I'm doing anything wrong but I cannot get Lucee to process CF files from my custom web folder. It continually wants to look in /webapps/ROOT of tomcat8!

Page /index.cfm [/var/lib/tomcat8/webapps/ROOT/index.cfm] not found

I literally copy verbatim the example.com conf file for nginx

Would updating the Lucee version affect what's been initially configured in web.xml ?

server {
listen 80;
server_name mywebsite.com;
root /web/mywebsite.com/;
set $lucee_context "mywebsite.com";
include lucee.conf;
}

Write access?

How do I give Lucee write access to the web root? Been messing with permissions etc... with no love.

Tomcat9

Any thoughts or plans to update the installer for Tomcat 9? Wanted to try Ubuntu 20 LTS and that doesn't support Tomcat 8...Going to back down to 16 and pretty sure everything will work from there

Running the Dockerfile image - can't run systemctl daemon-reload

Happens during setup in 300-tomcat.sh when executing systemctl daemon-reload. Tomcat ends up not running anymore and causes issues further down the line.

----------------------------------LOG------------------------------------
Setting Permissions on Lucee Folders
Setting JVM Max Heap Size to 512m
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down


Tomcat / Lucee Configuration Done, Starting Tomcat

No WEB-INF directory created

First, thank you Mr. Freitag! This script saved me a lot of time!

I'm accustomed to using Web.cfc in WEB-INF/lucee/context/ to load some server variables. But it seems that with the web.xml settings putting the lucce-web-directory in /opt/lucee/config/web - I'm not seeing WEB-INF being created anywhere. Does this make sense or am I way off base?

I've tried placing a Web.cfc in various places but no server vars seem to get set on server restarts.

The Web.cfc contains something like this:

component {
     public function onWebStart() {
	server.server_name = "IL1LBIBISON09";
	server.dsn = "LBDataHub";
	server.farmserver = "BISON09";
	server.devserver = FALSE;
	server.appRoot = "/vol1/clips/";
    }
}

Is there some other place that runs onWebStart()?

script hangs after 400-jvm.sh (service tomcat9 status)? i.e. 500-nginx.sh is not run

Hi, I just run this on a fresh Ubuntu 20.04 LTS on ssdnodes with 32 GB RAM. The scripts fails to go on to step 500-nginx.sh?

`
● tomcat9.service - Apache Tomcat 9 Web Application Server
Loaded: loaded (/lib/systemd/system/tomcat9.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-06-10 13:00:25 UTC; 19ms ago
Docs: https://tomcat.apache.org/tomcat-9.0-doc/index.html
Process: 1535 ExecStartPre=/usr/libexec/tomcat9/tomcat-update-policy.sh (code=exited, status=0/SUCCESS)
Main PID: 1542 (java)
Tasks: 1 (limit: 38434)
Memory: 1.3M
CGroup: /system.slice/tomcat9.service
└─1542 /usr/lib/jvm/java-11-openjdk-amd64/bin/java -Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties -Djava.util.loggin>

Jun 10 13:00:25 ssd4.myserver.se systemd[1]: Starting Apache Tomcat 9 Web Application Server...
Jun 10 13:00:25 ssd4.myserver.se systemd[1]: Started Apache Tomcat 9 Web Application Server.
Jun 10 13:00:25 ssd4.myserver.se tomcat9[1542]: NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io>
~`

How is OpenJDK used/setup?

I have run the scripts as suggested (commenting out the $JVM_FILE env variable) and everything seemingly installs however LUCEE will not run, the nginx web server is up and available. I have a feeling that there is no JVM available. Tomcat is saying it cannot start Lucee

What am I doing wrong here in regards to simply running these scripts?

This is on a fresh Ubuntu installation on Digital Ocean.

webroot question

I ran thru the install, and attempted to configure the default site for lucee: https://gist.github.com/jstrong1/9f280c4d27b57dfa17eeee70b4e64e59

I created an index.cfm file in /web/default/wwwroot/

http://12.34.567.8/ returns the "hello" index.html file as expected. However, http://12.34.567.8/index.cfm returns: Lucee 5.2.6.59 Error (missinginclude) Page /index.cfm [/var/lib/tomcat8/webapps/ROOT/index.cfm] not found

My expectation was that nginx would server static files from /web/default/wwwroot/, and pass .cfm files to lucee for a response. Is this not how it is designed to work?

When I copy my index.cfm file to /var/lib/tomcat8/webapps/ROOT, and set permissions on the file:

sudo chown -R tomcat8:tomcat8 /var/lib/tomcat8/webapps/ROOT
sudo chmod -R 750 /var/lib/tomcat8/webapps/ROOT

....http://12.34.567.8/index.cfm returns my index.cfm file correctly.

Does this mean my static files need to live in /web/default/wwwroot/ and my .cfm and .cfc files need to live in /var/lib/tomcat8/webapps/ROOT/? Or have I misconfigured something?

Any feedback that you could provide would be greatly appreciated.

Proxy for SES locations

I've created a fork of this project for CentOS. I've got a couple of improvements, but unfortunately I've had to make a lot of changes due to the differences between CentOS and Ubuntu.

I'm going to try to fork the project and migrate my fixes to both repos.

In the meantime, I did discover a bug in the SES routing, see this change:

dswitzer@075ca18

The problem is in the etc/nginx/lucee.conf file. The proxy is only loaded if the script ends in .cfm or .cfc, so if you have URLs like /index.cfm/ses/safe/urls/ the proxy is never loaded, so the URL rewrite rule is never applied.

The fix I came up with is pretty simple

#match cfm or cfc files and proxy them off to tomcat
location ~* (\.cfm(\/|$)|\.cfc$) {
  include lucee-proxy.conf;
}

Basically the proxy is loaded if the template ends in .cfm or matches the pattern .cfm/.

Lucee 5 and Ubuntu 16.04 LTS Support

This script needs to be updated for both Lucee 5 and Ubuntu 16.04 LTS.

My thoughts are to take the current master branch and create a new branch called lucee45-ubuntu14 and then update master to work with Lucee 5 and Ubuntu 16.04 - the main differences in 16.04 is that it includes Tomcat 8 instead of Tomcat 7.

Ideally the master (lucee 5) branch would still work with Ubuntu 14.04 as well.

Pull request #10 from @andyj adds Lucee 5 support but it uses the Viviotech installer which includes a bundled version of tomcat (so you have to patch tomcat manually).

Lucee is running on port 8080

Thanks for this installation!!! :)

Lucee is running on Port 8080, you might want to add that to the instructions.

Updating to use Lucee?

Will you be updating these scripts to use Lucee now that it doesn't appear that Railo will continue?

mod_cfml failing to download when running install.sh

Hi, this installer is providing the following error which appears to be preventing a working installation of lucee. I am using restore points on a Digital Ocean VM to roll back installation attempts in the hopes of having the installer run successfully.

Installing mod_cfml Valve for Automatic Virtual Host Configuration
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file
Warning: /opt/lucee/current/mod_cfml-valve_v1.1.05.jar: No such file or

I believe it may be related to scripts/300-tomcat.sh approx line 32:

 29 echo "Installing mod_cfml Valve for Automatic Virtual Host Configuration"
 30 if [ -f lib/mod_cfml-valve_v1.1.05.jar ]; then
 31   cp lib/mod_cfml-valve_v1.1.05.jar /opt/lucee/current/
 32 else
 33   curl --location -o /opt/lucee/current/mod_cfml-valve_v1.1.05.jar https://raw.githubusercontent.com/utdream/mod_cfml/master/java/mod_cfml-valve_v1.1.05.jar
 34 fi

Investigating further..

Unabe to install Tomcat8 - error in script

Trying to install on Ubuntu 14.04 server -

Installing Tomcat 8
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package tomcat8

Permissions issue

I don't think the permissions in the install scripts are quite up to par. I had to add quite a few more to get 'www-data' to access a new site made under /web

Furthermore, running a CF file for the first time and this error is encountered:

javax.servlet.ServletException: can't create directory /web/mywebsite/wwwroot/WEB-INF/lucee

So it seems that Lucee/Tomcat isn't allowed to touch the new directory? How do I resolve this?

Server Config for SSL?

I'm attempting to add HTTPS/SSL to my freshly-installed server. My default.conf is reading:

server {
  listen 80 default_server;
  server_name example_com;
  root /web/default/wwwroot/;
  index index.html;
  include lucee.conf;
}

server {                 
  listen 443;
  server_name example_com;
  ssl on;
  ssl_certificate /etc/ssl/certs/cert_chain.crt;
  ssl_certificate_key /etc/ssl/private/example_com.key;

  location / {
  root /web/default/wwwroot/;
  index index.html;
  }

  include lucee.conf;
 
}

The mod_cfml documentation for Nginx says I must add a $lucee_context parameter when I have "multiple server blocks with the same 'root' value."

However, it also says:

Make sure you give the $lucee_context variable a unique value. It cannot have the same value in multiple server blocks. Otherwise, multiple sites will share the same Lucee context!

This is the thing: I want the multiple sites to share the context. I want the port 80 and the port 443 to both redirect to the exact same folder. When I tried to use the same value for $lucee_context in the .conf file, mod_cfml started to poop out new web contexts whenever I'd restart the server, which were very messed up.

Is there a clear and concise way to setup the .conf file so that the same webroot can host both the SSL and HTTP requests? Without causing a scene?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.