When I actually upgrade this site from WordPress 4.4.2 to WordPress 4.5, I think it would be pretty cool to automate as much of the process as possible. To try it out, I’m going to install a Jenkins server, and to make it a little more interesting, I’m going to try to set up access to the Jenkins server through my Apache server so I have a more unified experience access resources on my server (i.e,. I don’t have to type in any ports).
Installing Jenkins
The official documentation is here, but for brevity, here are the commands I ran to get Jenkins installed:
- Add the Jenkins
apt
keywget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | sudo apt-key add -
- Add the stable
apt
repositorysudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
- Update
sudo apt-get update
- Install
sudo apt-get install jenkins
Configuring Jenkins To Sit Behind Apache
I wanted to access the Jenkins server via a subdirectory of my website (e.g., http://www.example.com/jenkins), so the only interface it needed to listen on was localhost
. The server also had to have a context root configured since it would be behind an Apache proxy.
The PREFIX
variable was already set in /etc/default/jenkins
, so all I had to do was add these two parameters to JENKINS_ARGS
:
- Listen only on localhost
--httpListenAddress=localhost
- Serve the application from a context root
--prefix=$PREFIX
I also removed the AJP connector.
Configuring Apache As A Proxy
To configure Apache as a proxy, I had to enable mod_proxy
and mod_http
and configure the proxy by adding the following to my virtual host:
ProxyPass /jenkins http://localhost:8080/jenkins nocanon ProxyPassReverse /jenkins http://localhost:8080/jenkins ProxyRequests Off AllowEncodedSlashes NoDecode <Proxy http://localhost:8080/jenkins*> Order deny,allow Allow from all </Proxy>
Note that the proxy location matches the context root of the Jenkins server.
Restart
After restarting Jenkins and Apache to pick up the configuration changes, everything worked beautifully!